OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/path_service.h" | 5 #include "base/path_service.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 | 23 |
24 // Returns true if PathService::Get returns true and sets the path parameter | 24 // Returns true if PathService::Get returns true and sets the path parameter |
25 // to non-empty for the given PathService::DirType enumeration value. | 25 // to non-empty for the given PathService::DirType enumeration value. |
26 bool ReturnsValidPath(int dir_type) { | 26 bool ReturnsValidPath(int dir_type) { |
27 FilePath path; | 27 FilePath path; |
28 bool result = PathService::Get(dir_type, &path); | 28 bool result = PathService::Get(dir_type, &path); |
29 | 29 |
30 // Some paths might not exist on some platforms in which case confirming | 30 // Some paths might not exist on some platforms in which case confirming |
31 // |result| is true and !path.empty() is the best we can do. | 31 // |result| is true and !path.empty() is the best we can do. |
32 bool check_path_exists = true; | 32 bool check_path_exists = true; |
33 #if defined(OS_POSIX) | 33 #if defined(OS_POSIX) && !defined(OS_FUCHSIA) |
Lei Zhang
2017/05/24 23:28:34
Are we going to eventually testing Fuchsia here? D
scottmg
2017/05/24 23:42:29
This should test all paths that go through here, r
| |
34 // If chromium has never been started on this account, the cache path may not | 34 // If chromium has never been started on this account, the cache path may not |
35 // exist. | 35 // exist. |
36 if (dir_type == DIR_CACHE) | 36 if (dir_type == DIR_CACHE) |
37 check_path_exists = false; | 37 check_path_exists = false; |
38 #endif | 38 #endif |
39 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) |
40 // On the linux try-bots: a path is returned (e.g. /home/chrome-bot/Desktop), | 40 // On the linux try-bots: a path is returned (e.g. /home/chrome-bot/Desktop), |
41 // but it doesn't exist. | 41 // but it doesn't exist. |
42 if (dir_type == DIR_USER_DESKTOP) | 42 if (dir_type == DIR_USER_DESKTOP) |
43 check_path_exists = false; | 43 check_path_exists = false; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 } | 108 } |
109 #elif defined(OS_MACOSX) | 109 #elif defined(OS_MACOSX) |
110 for (int key = PATH_MAC_START + 1; key < PATH_MAC_END; ++key) { | 110 for (int key = PATH_MAC_START + 1; key < PATH_MAC_END; ++key) { |
111 EXPECT_PRED1(ReturnsValidPath, key); | 111 EXPECT_PRED1(ReturnsValidPath, key); |
112 } | 112 } |
113 #elif defined(OS_ANDROID) | 113 #elif defined(OS_ANDROID) |
114 for (int key = PATH_ANDROID_START + 1; key < PATH_ANDROID_END; | 114 for (int key = PATH_ANDROID_START + 1; key < PATH_ANDROID_END; |
115 ++key) { | 115 ++key) { |
116 EXPECT_PRED1(ReturnsValidPath, key); | 116 EXPECT_PRED1(ReturnsValidPath, key); |
117 } | 117 } |
118 #elif defined(OS_POSIX) | 118 #elif defined(OS_POSIX) && !defined(OS_FUCHSIA) |
scottmg
2017/05/24 23:42:29
This part just avoids testing the POSIX_ specific
| |
119 for (int key = PATH_POSIX_START + 1; key < PATH_POSIX_END; | 119 for (int key = PATH_POSIX_START + 1; key < PATH_POSIX_END; |
120 ++key) { | 120 ++key) { |
121 EXPECT_PRED1(ReturnsValidPath, key); | 121 EXPECT_PRED1(ReturnsValidPath, key); |
122 } | 122 } |
123 #endif | 123 #endif |
124 } | 124 } |
125 | 125 |
126 // Test that all versions of the Override function of PathService do what they | 126 // Test that all versions of the Override function of PathService do what they |
127 // are supposed to do. | 127 // are supposed to do. |
128 TEST_F(PathServiceTest, Override) { | 128 TEST_F(PathServiceTest, Override) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 EXPECT_TRUE(PathService::Get(DIR_PROGRAM_FILES6432, | 267 EXPECT_TRUE(PathService::Get(DIR_PROGRAM_FILES6432, |
268 &programfiles_dir)); | 268 &programfiles_dir)); |
269 EXPECT_EQ(programfiles_dir.value(), | 269 EXPECT_EQ(programfiles_dir.value(), |
270 FILE_PATH_LITERAL("C:\\Program Files")); | 270 FILE_PATH_LITERAL("C:\\Program Files")); |
271 } | 271 } |
272 #endif | 272 #endif |
273 } | 273 } |
274 #endif | 274 #endif |
275 | 275 |
276 } // namespace base | 276 } // namespace base |
OLD | NEW |