| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/chrome_paths_internal.h" | 5 #include "chrome/common/chrome_paths_internal.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "chrome/common/chrome_constants.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 // Test the behavior of chrome::GetUserCacheDirectory. | 15 // Test the behavior of chrome::GetUserCacheDirectory. |
| 15 // See that function's comments for discussion of the subtleties. | 16 // See that function's comments for discussion of the subtleties. |
| 16 TEST(ChromePaths, UserCacheDir) { | 17 TEST(ChromePaths, UserCacheDir) { |
| 17 FilePath test_profile_dir, cache_dir; | 18 FilePath test_profile_dir, cache_dir; |
| 18 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| 19 ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir)); | 20 ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir)); |
| 20 test_profile_dir = test_profile_dir.Append("foobar"); | 21 test_profile_dir = test_profile_dir.Append("foobar"); |
| 21 FilePath expected_cache_dir; | 22 FilePath expected_cache_dir; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); | 36 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); |
| 36 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); | 37 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 // Verify that a profile in some other random directory doesn't use | 40 // Verify that a profile in some other random directory doesn't use |
| 40 // the special cache dir. | 41 // the special cache dir. |
| 41 test_profile_dir = FilePath(FILE_PATH_LITERAL("/some/other/path")); | 42 test_profile_dir = FilePath(FILE_PATH_LITERAL("/some/other/path")); |
| 42 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); | 43 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); |
| 43 EXPECT_EQ(test_profile_dir.value(), cache_dir.value()); | 44 EXPECT_EQ(test_profile_dir.value(), cache_dir.value()); |
| 44 } | 45 } |
| 46 |
| 47 #if defined(OS_WINDOWS) |
| 48 TEST(ChromePaths, AlternateUserDataDir) { |
| 49 FilePath current_dir; |
| 50 FilePath alternate_dir; |
| 51 |
| 52 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, current_dir)); |
| 53 |
| 54 // Check that we can get the alternate dir. |
| 55 EXPECT_TRUE(PathService::Get(chrome::DIR_ALT_USER_DATA, alternate_dir)); |
| 56 |
| 57 // And that it's not the same as the current dir. |
| 58 EXPECTE_NE(current_dir.value(), alternate_dir.value()); |
| 59 |
| 60 // And that it's the metro dir. |
| 61 EXPECT_EQ(FilePath::StringType(kMetroChromeUserDataSubDir), |
| 62 alternate_dir.DirName().BaseName().value()); |
| 63 } |
| 64 #endif |
| OLD | NEW |