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

Side by Side Diff: base/path_service_unittest.cc

Issue 5344003: Revert 67191 - chrome_paths: refactor and sanitize cache directory handling... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | « base/path_service.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/path_service.h" 5 #include "base/path_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #endif 12 #endif
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/gtest/include/gtest/gtest-spi.h" 14 #include "testing/gtest/include/gtest/gtest-spi.h"
15 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Returns true if PathService::Get returns true and sets the path parameter 19 // Returns true if PathService::Get returns true and sets the path parameter
20 // to non-empty for the given PathService::DirType enumeration value. 20 // to non-empty for the given PathService::DirType enumeration value.
21 bool ReturnsValidPath(int dir_type) { 21 bool ReturnsValidPath(int dir_type) {
22 FilePath path; 22 FilePath path;
23 bool result = PathService::Get(dir_type, &path); 23 bool result = PathService::Get(dir_type, &path);
24 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
25 // If chromium has never been started on this account, the cache path may not 25 // If chromium has never been started on this account, the cache path will not
26 // exist. 26 // exist.
27 if (dir_type == base::DIR_CACHE) 27 if (dir_type == base::DIR_USER_CACHE)
28 return result && !path.value().empty(); 28 return result && !path.value().empty();
29 #endif 29 #endif
30 return result && !path.value().empty() && file_util::PathExists(path); 30 return result && !path.value().empty() && file_util::PathExists(path);
31 } 31 }
32 32
33 #if defined(OS_WIN) 33 #if defined(OS_WIN)
34 // Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails. 34 // Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails.
35 bool ReturnsInvalidPath(int dir_type) { 35 bool ReturnsInvalidPath(int dir_type) {
36 FilePath path; 36 FilePath path;
37 bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path); 37 bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path);
(...skipping 25 matching lines...) Expand all
63 } else { 63 } else {
64 EXPECT_TRUE(ReturnsValidPath(key)) << key; 64 EXPECT_TRUE(ReturnsValidPath(key)) << key;
65 } 65 }
66 } 66 }
67 #elif defined(OS_MACOSX) 67 #elif defined(OS_MACOSX)
68 for (int key = base::PATH_MAC_START + 1; key < base::PATH_MAC_END; ++key) { 68 for (int key = base::PATH_MAC_START + 1; key < base::PATH_MAC_END; ++key) {
69 EXPECT_PRED1(ReturnsValidPath, key); 69 EXPECT_PRED1(ReturnsValidPath, key);
70 } 70 }
71 #endif 71 #endif
72 } 72 }
OLDNEW
« no previous file with comments | « base/path_service.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698