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

Side by Side Diff: base/path_service_unittest.cc

Issue 8825: Begin the first small step towards using FilePath everywhere: (Closed)
Patch Set: works on windows Created 12 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 unified diff | Download patch
« no previous file with comments | « base/path_service.cc ('k') | base/trace_event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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"
6
5 #include "base/basictypes.h" 7 #include "base/basictypes.h"
6 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/file_path.h"
7 #include "base/logging.h" 10 #include "base/logging.h"
8 #include "base/path_service.h"
9 #include "base/platform_test.h" 11 #include "base/platform_test.h"
10 #if defined(OS_WIN) 12 #if defined(OS_WIN)
11 #include "base/win_util.h" 13 #include "base/win_util.h"
12 #endif 14 #endif
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/gtest/include/gtest/gtest-spi.h" 16 #include "testing/gtest/include/gtest/gtest-spi.h"
15 17
16 namespace { 18 namespace {
17 19
18 // Returns true if PathService::Get returns true and sets the path parameter 20 // Returns true if PathService::Get returns true and sets the path parameter
19 // to non-empty for the given PathService::DirType enumeration value. 21 // to non-empty for the given PathService::DirType enumeration value.
20 bool ReturnsValidPath(int dir_type) { 22 bool ReturnsValidPath(int dir_type) {
21 std::wstring path; 23 FilePath path;
22 bool result = PathService::Get(dir_type, &path); 24 bool result = PathService::Get(dir_type, &path);
23 return result && !path.empty() && file_util::PathExists(path); 25 return result && !path.value().empty() && file_util::PathExists(path);
24 } 26 }
25 27
26 #if defined(OS_WIN) 28 #if defined(OS_WIN)
27 // Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails. 29 // Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails.
28 bool ReturnsInvalidPath(int dir_type) { 30 bool ReturnsInvalidPath(int dir_type) {
29 std::wstring path; 31 std::wstring path;
30 bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path); 32 bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path);
31 return !result && path.empty(); 33 return !result && path.empty();
32 } 34 }
33 #endif 35 #endif
(...skipping 19 matching lines...) Expand all
53 // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected to 55 // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected to
54 // fail. 56 // fail.
55 EXPECT_TRUE(ReturnsInvalidPath(key)) << key; 57 EXPECT_TRUE(ReturnsInvalidPath(key)) << key;
56 } else { 58 } else {
57 EXPECT_TRUE(ReturnsValidPath(key)) << key; 59 EXPECT_TRUE(ReturnsValidPath(key)) << key;
58 } 60 }
59 } 61 }
60 #endif 62 #endif
61 } 63 }
62 64
OLDNEW
« no previous file with comments | « base/path_service.cc ('k') | base/trace_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698