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

Side by Side 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: akalin Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | chrome/common/chrome_paths_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "base/path_service.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 #if !defined(OS_WIN) // This function is a no-op on Windows.
15 // Test the behavior of chrome::GetUserCacheDirectory.
akalin 2010/11/22 23:54:28 May be worth testing that the function remains a n
16 // See that function's comments for discussion of the subtleties.
17 TEST(ChromePaths, UserCacheDir) {
18 #if defined(OS_MACOSX)
19 FilePath test_profile_dir;
20 ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir));
21 test_profile_dir = test_profile_dir.Append("foobar");
22 FilePath expected_cache_dir;
23 ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir));
24 expected_cache_dir = expected_cache_dir.Append("foobar");
25 #elif(OS_POSIX)
26 FilePath homedir = file_util::GetHomeDir();
27 // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their
28 // default settings.
29 FilePath test_profile_dir = homedir.Append(".config/foobar");
30 FilePath expected_cache_dir = homedir.Append(".cache/foobar");
31 #endif
32
33 // Verify that a profile in the special platform-specific source
34 // location ends up in the special target location.
35 FilePath cache_dir;
36 ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir));
37 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value());
38
39 // Verify that a profile in some other random directory doesn't use
40 // the special cache dir.
41 test_profile_dir = FilePath("/some/other/path");
42 ASSERT_TRUE(chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir));
43 EXPECT_EQ(test_profile_dir.value(), cache_dir.value());
44 }
45 #endif // OS_WIN
OLDNEW
« 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