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 #if defined(OS_MACOSX) | |
17 // Verify that ~/Library/Application Support/foobar maps to .cache/foobar. | |
18 FilePath homedir = FilePath(getenv("HOME")); | |
Mark Mentovai
2010/11/18 16:54:54
Why not file_util::GetHomeDir() as in non-Mac POSI
Evan Martin
2010/11/18 18:13:07
We only have a Linux impl. (If $HOME is unset you
Mark Mentovai
2010/11/18 19:11:48
Evan Martin wrote:
| |
19 FilePath user_data_dir = homedir.Append("Library/Application Support/foobar"); | |
20 FilePath cache_dir; | |
21 ASSERT_TRUE(chrome::GetUserCacheDirectory(user_data_dir, &cache_dir)); | |
22 EXPECT_EQ(homedir.Append("Library/Caches/foobar").value(), cache_dir.value()); | |
23 | |
24 // Verify that a custom user data dir doesn't get a custom cache dir. | |
Mark Mentovai
2010/11/18 16:54:54
This block is the same for Mac and non-Mac POSIX,
| |
25 user_data_dir = homedir.Append("some_other_dir"); | |
26 ASSERT_TRUE(chrome::GetUserCacheDirectory(user_data_dir, &cache_dir)); | |
27 EXPECT_EQ(user_data_dir.value(), cache_dir.value()); | |
28 | |
29 #elif(OS_POSIX) | |
30 // We assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their default settings. | |
31 FilePath homedir = file_util::GetHomeDir(); | |
32 | |
33 // Verify that .config/foobar maps to .cache/foobar. | |
34 FilePath user_data_dir = homedir.Append(".config/foobar"); | |
35 FilePath cache_dir; | |
36 ASSERT_TRUE(chrome::GetUserCacheDirectory(user_data_dir, &cache_dir)); | |
Mark Mentovai
2010/11/18 16:54:54
For that matter, maybe you can put this line outsi
Evan Martin
2010/11/18 18:13:07
Great idea, I've now rewritten the test to be much
| |
37 EXPECT_EQ(homedir.Append(".cache/foobar").value(), cache_dir.value()); | |
38 | |
39 // Verify that a custom user data dir doesn't get a custom cache dir. | |
40 user_data_dir = homedir.Append("some_other_dir"); | |
41 ASSERT_TRUE(chrome::GetUserCacheDirectory(user_data_dir, &cache_dir)); | |
42 EXPECT_EQ(user_data_dir.value(), cache_dir.value()); | |
43 #endif | |
44 } | |
OLD | NEW |