Chromium Code Reviews| Index: base/path_service_unittest.cc |
| diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc |
| index 81d1fef0b96c61379712f4c9ee2a87e720b2a37a..a4484522809ca2730ef19ff3cda2d01688abffe6 100644 |
| --- a/base/path_service_unittest.cc |
| +++ b/base/path_service_unittest.cc |
| @@ -8,13 +8,16 @@ |
| #include "base/file_util.h" |
| #include "base/file_path.h" |
| #include "base/scoped_temp_dir.h" |
| -#if defined(OS_WIN) |
| -#include "base/win/windows_version.h" |
| -#endif |
| +#include "base/string16.h" |
| +#include "build/build_config.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/gtest/include/gtest/gtest-spi.h" |
| #include "testing/platform_test.h" |
| +#if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
| +#endif |
| + |
| namespace { |
| // Returns true if PathService::Get returns true and sets the path parameter |
| @@ -26,9 +29,24 @@ bool ReturnsValidPath(int dir_type) { |
| // If chromium has never been started on this account, the cache path may not |
| // exist. |
| if (dir_type == base::DIR_CACHE) |
| - return result && !path.value().empty(); |
| + return result && !path.empty(); |
| #endif |
| - return result && !path.value().empty() && file_util::PathExists(path); |
| +#if defined(OS_LINUX) |
| + // On the linux try-bots: a path is returned (e.g. /home/chrome-bot/Desktop), |
| + // but it doesn't exist. |
| + if (dir_type == base::DIR_USER_DESKTOP) |
| + return (result && !path.empty() && |
| + path.value().find(L"Desktop") != string16::npos); |
|
grt (UTC plus 2)
2012/09/20 03:44:07
IMO, this looks like a test failure waiting to hap
gab
2012/09/20 04:15:36
Right, probably too dangerous, reverted.
|
| +#elif defined(OS_WIN) |
|
grt (UTC plus 2)
2012/09/20 03:44:07
the following is more consistent with lines 33 and
gab
2012/09/20 04:15:36
I debated doing that, thanks for making my life/de
|
| + // On Windows XP, the Quick Launch folder for the "Default User" doesn't exist |
| + // by default. |
| + if (dir_type == base::DIR_DEFAULT_USER_QUICK_LAUNCH && |
| + base::win::GetVersion() <= base::win::VERSION_XP) { |
|
grt (UTC plus 2)
2012/09/20 03:44:07
maybe this needs to be < base::win::VERSION_VISTA
gab
2012/09/20 04:15:36
Done.
|
| + return (result && !path.empty() && |
| + path.value().find(L"Default User") != string16::npos); |
|
gab
2012/09/20 03:12:07
Let me know what you think of adding the "find" to
grt (UTC plus 2)
2012/09/20 03:44:07
Since pulling in Userenv.lib shouldn't be a proble
|
| + } |
| +#endif |
| + return result && !path.empty() && file_util::PathExists(path); |
| } |
| #if defined(OS_WIN) |
| @@ -53,10 +71,10 @@ typedef PlatformTest PathServiceTest; |
| // later changes to Get broke the semantics of the function and yielded the |
| // correct value while returning false.) |
| TEST_F(PathServiceTest, Get) { |
| - for (int key = base::DIR_CURRENT; key < base::PATH_END; ++key) { |
| + for (int key = base::PATH_START + 1; key < base::PATH_END; ++key) { |
| #if defined(OS_ANDROID) |
| - if (key == base::FILE_MODULE) |
| - continue; // Android doesn't implement FILE_MODULE; |
| + if (key == base::FILE_MODULE || key == base::DIR_USER_DESKTOP) |
| + continue; // Android doesn't implement FILE_MODULE and DIR_USER_DESKTOP; |
| #endif |
| EXPECT_PRED1(ReturnsValidPath, key); |
| } |
| @@ -83,7 +101,17 @@ TEST_F(PathServiceTest, Get) { |
| } |
| #elif defined(OS_MACOSX) |
| for (int key = base::PATH_MAC_START + 1; key < base::PATH_MAC_END; ++key) { |
| - EXPECT_PRED1(ReturnsValidPath, key); |
| + EXPECT_PRED1(ReturnsValidPath, key); |
| + } |
| +#elif defined(OS_ANDROID) |
| + for (int key = base::PATH_ANDROID_START + 1; key < base::PATH_ANDROID_END; |
| + ++key) { |
| + EXPECT_PRED1(ReturnsValidPath, key); |
| + } |
| +#elif defined(OS_POSIX) |
| + for (int key = base::PATH_POSIX_START + 1; key < base::PATH_POSIX_END; |
| + ++key) { |
| + EXPECT_PRED1(ReturnsValidPath, key); |
| } |
| #endif |
| } |