Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / common / chrome_paths_unittest.cc
blob5d1dfc0b4a7db0fe10206d54721b3e3f1b6a1f1f
1 // Copyright (c) 2012 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.
5 #include "chrome/common/chrome_paths_internal.h"
7 #include <stdlib.h>
9 #include "base/base_paths.h"
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
12 #include "base/path_service.h"
13 #include "chrome/common/chrome_constants.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 // Test the behavior of chrome::GetUserCacheDirectory.
17 // See that function's comments for discussion of the subtleties.
18 TEST(ChromePaths, UserCacheDir) {
19 base::FilePath test_profile_dir, cache_dir;
20 #if defined(OS_MACOSX)
21 ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir));
22 test_profile_dir = test_profile_dir.Append("foobar");
23 base::FilePath expected_cache_dir;
24 ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir));
25 expected_cache_dir = expected_cache_dir.Append("foobar");
26 #elif(OS_ANDROID)
27 // No matter what the test_profile_dir is, Android always use the
28 // application's cache directory since multiple profiles are not
29 // supported.
30 base::FilePath expected_cache_dir;
31 ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir));
32 #elif(OS_POSIX)
33 base::FilePath homedir;
34 PathService::Get(base::DIR_HOME, &homedir);
35 // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their
36 // default settings.
37 test_profile_dir = homedir.Append(".config/foobar");
38 base::FilePath expected_cache_dir = homedir.Append(".cache/foobar");
39 #endif
41 // Verify that a profile in the special platform-specific source
42 // location ends up in the special target location.
43 #if !defined(OS_WIN) // No special behavior on Windows.
44 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir);
45 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value());
46 #endif
48 // Verify that a profile in some other random directory doesn't use
49 // the special cache dir.
50 test_profile_dir = base::FilePath(FILE_PATH_LITERAL("/some/other/path"));
51 chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir);
52 #if defined(OS_ANDROID)
53 EXPECT_EQ(expected_cache_dir.value(), cache_dir.value());
54 #else
55 EXPECT_EQ(test_profile_dir.value(), cache_dir.value());
56 #endif