Index: chrome/common/chrome_paths_unittest.cc |
diff --git a/chrome/common/chrome_paths_unittest.cc b/chrome/common/chrome_paths_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d7c44c6a1b474ac41154cf4a397750e7ab1ca173 |
--- /dev/null |
+++ b/chrome/common/chrome_paths_unittest.cc |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/common/chrome_paths_internal.h" |
+ |
+#include <stdlib.h> |
+ |
+#include "base/file_path.h" |
+#include "base/file_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+// Test the behavior of chrome::GetUserCacheDirectory. |
+// See that function's comments for discussion of the subtleties. |
+TEST(ChromePaths, UserCacheDir) { |
+ |
+#if defined(OS_MACOSX) |
+ FilePath homedir = FilePath(getenv("HOME")); |
+ FilePath test_profile_dir = homedir.Append( |
+ "Library/Application Support/foobar"); |
+ FilePath expected_cache_dir = homedir.Append("Library/Caches/foobar"); |
+#elif(OS_POSIX) |
+ FilePath homedir = file_util::GetHomeDir(); |
+ // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their |
+ // default settings. |
+ FilePath test_profile_dir = homedir.Append(".config/foobar"); |
+ FilePath expected_cache_dir = homedir.Append(".cache/foobar"); |
+#endif |
+ |
+ // Verify that a profile in the special platform-specific source |
+ // location ends up in the special target location. |
+ FilePath cache_dir; |
+ ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir)); |
+ EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); |
+ |
+ // Verify that a profile in some other random directory doesn't use |
+ // the special cache dir. |
+ test_profile_dir = homedir.Append("some_other_dir"); |
+ ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir)); |
+ EXPECT_EQ(test_profile_dir.value(), cache_dir.value()); |
+} |