OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/common/chrome_paths_internal.h" |
| 6 |
| 7 #include <stdlib.h> |
| 8 |
| 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 // Test the behavior of chrome::GetUserCacheDirectory. |
| 14 // See that function's comments for discussion of the subtleties. |
| 15 TEST(ChromePaths, UserCacheDir) { |
| 16 |
| 17 #if defined(OS_MACOSX) |
| 18 FilePath homedir = FilePath(getenv("HOME")); |
| 19 FilePath test_profile_dir = homedir.Append( |
| 20 "Library/Application Support/foobar"); |
| 21 FilePath expected_cache_dir = homedir.Append("Library/Caches/foobar"); |
| 22 #elif(OS_POSIX) |
| 23 FilePath homedir = file_util::GetHomeDir(); |
| 24 // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their |
| 25 // default settings. |
| 26 FilePath test_profile_dir = homedir.Append(".config/foobar"); |
| 27 FilePath expected_cache_dir = homedir.Append(".cache/foobar"); |
| 28 #endif |
| 29 |
| 30 // Verify that a profile in the special platform-specific source |
| 31 // location ends up in the special target location. |
| 32 FilePath cache_dir; |
| 33 ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir)); |
| 34 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); |
| 35 |
| 36 // Verify that a profile in some other random directory doesn't use |
| 37 // the special cache dir. |
| 38 test_profile_dir = homedir.Append("some_other_dir"); |
| 39 ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir)); |
| 40 EXPECT_EQ(test_profile_dir.value(), cache_dir.value()); |
| 41 } |
OLD | NEW |