Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3850)

Unified Diff: chrome/common/chrome_paths_unittest.cc

Issue 5123004: chrome_paths: refactor and sanitize cache directory handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more win Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | chrome/common/chrome_paths_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2390ce94f9d97298d15ac0e0db8f0728f5b07b6c
--- /dev/null
+++ b/chrome/common/chrome_paths_unittest.cc
@@ -0,0 +1,44 @@
+// 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 "base/path_service.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) {
+ FilePath test_profile_dir, cache_dir;
+#if defined(OS_MACOSX)
+ ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir));
+ test_profile_dir = test_profile_dir.Append("foobar");
+ FilePath expected_cache_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir));
+ expected_cache_dir = expected_cache_dir.Append("foobar");
+#elif(OS_POSIX)
+ FilePath homedir = file_util::GetHomeDir();
+ // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their
+ // default settings.
+ 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.
+#if !defined(OS_WIN) // No special behavior on Windows.
+ chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir);
+ EXPECT_EQ(expected_cache_dir.value(), cache_dir.value());
+#endif
+
+ // Verify that a profile in some other random directory doesn't use
+ // the special cache dir.
+ test_profile_dir = FilePath("/some/other/path");
+ chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir);
+ EXPECT_EQ(test_profile_dir.value(), cache_dir.value());
+}
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | chrome/common/chrome_paths_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698