Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / chromecast / base / path_utils_unittest.cc
blob618bb0f3e4b2141a0addd5f2fffd4db6c236c566
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/files/file_path.h"
6 #include "base/path_service.h"
7 #include "chromecast/base/path_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace chromecast {
11 namespace {
12 const char kTestRelPath[] = "rel/path";
13 const char kTestAbsPath[] = "/abs/path/to/dir";
15 std::string GetTestString(int base_dir_key) {
16 base::FilePath basedir;
17 EXPECT_TRUE(PathService::Get(base_dir_key, &basedir));
18 return basedir.value() + "/" + kTestRelPath;
21 } // namespace
23 TEST(PathUtilsTest, GetHomePath) {
24 // Test with relative path.
25 std::string expected = GetTestString(base::DIR_HOME);
26 base::FilePath actual = GetHomePath(base::FilePath(kTestRelPath));
27 EXPECT_EQ(expected, actual.value());
29 // Test with absolute path.
30 actual = GetHomePath(base::FilePath(kTestAbsPath));
31 EXPECT_EQ(kTestAbsPath, actual.value());
34 TEST(PathUtilsTest, GetBinPath) {
35 // Test with relative path.
36 std::string expected = GetTestString(base::DIR_EXE);
37 base::FilePath actual = GetBinPath(base::FilePath(kTestRelPath));
38 EXPECT_EQ(expected, actual.value());
40 // Test with absolute path.
41 actual = GetBinPath(base::FilePath(kTestAbsPath));
42 EXPECT_EQ(kTestAbsPath, actual.value());
45 TEST(PathUtilsTest, GetTmpPath) {
46 // Test with relative path.
47 std::string expected = GetTestString(base::DIR_TEMP);
48 base::FilePath actual = GetTmpPath(base::FilePath(kTestRelPath));
49 EXPECT_EQ(expected, actual.value());
51 // Test with absolute path.
52 actual = GetTmpPath(base::FilePath(kTestAbsPath));
53 EXPECT_EQ(kTestAbsPath, actual.value());
56 } // chromecast