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

Side by Side Diff: base/path_service_unittest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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/mac/mac_util_unittest.mm ('k') | base/process/memory_linux.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) 2012 The Chromium Authors. All rights reserved. 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 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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 // Check if multiple overrides can co-exist. 174 // Check if multiple overrides can co-exist.
175 TEST_F(PathServiceTest, OverrideMultiple) { 175 TEST_F(PathServiceTest, OverrideMultiple) {
176 int my_special_key = 666; 176 int my_special_key = 666;
177 base::ScopedTempDir temp_dir; 177 base::ScopedTempDir temp_dir;
178 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 178 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
179 base::FilePath fake_cache_dir1(temp_dir.path().AppendASCII("1")); 179 base::FilePath fake_cache_dir1(temp_dir.path().AppendASCII("1"));
180 EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir1)); 180 EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir1));
181 EXPECT_TRUE(base::PathExists(fake_cache_dir1)); 181 EXPECT_TRUE(base::PathExists(fake_cache_dir1));
182 ASSERT_EQ(1, file_util::WriteFile(fake_cache_dir1.AppendASCII("t1"), ".", 1)); 182 ASSERT_EQ(1, base::WriteFile(fake_cache_dir1.AppendASCII("t1"), ".", 1));
183 183
184 base::FilePath fake_cache_dir2(temp_dir.path().AppendASCII("2")); 184 base::FilePath fake_cache_dir2(temp_dir.path().AppendASCII("2"));
185 EXPECT_TRUE(PathService::Override(my_special_key + 1, fake_cache_dir2)); 185 EXPECT_TRUE(PathService::Override(my_special_key + 1, fake_cache_dir2));
186 EXPECT_TRUE(base::PathExists(fake_cache_dir2)); 186 EXPECT_TRUE(base::PathExists(fake_cache_dir2));
187 ASSERT_EQ(1, file_util::WriteFile(fake_cache_dir2.AppendASCII("t2"), ".", 1)); 187 ASSERT_EQ(1, base::WriteFile(fake_cache_dir2.AppendASCII("t2"), ".", 1));
188 188
189 base::FilePath result; 189 base::FilePath result;
190 EXPECT_TRUE(PathService::Get(my_special_key, &result)); 190 EXPECT_TRUE(PathService::Get(my_special_key, &result));
191 // Override might have changed the path representation but our test file 191 // Override might have changed the path representation but our test file
192 // should be still there. 192 // should be still there.
193 EXPECT_TRUE(base::PathExists(result.AppendASCII("t1"))); 193 EXPECT_TRUE(base::PathExists(result.AppendASCII("t1")));
194 EXPECT_TRUE(PathService::Get(my_special_key + 1, &result)); 194 EXPECT_TRUE(PathService::Get(my_special_key + 1, &result));
195 EXPECT_TRUE(base::PathExists(result.AppendASCII("t2"))); 195 EXPECT_TRUE(base::PathExists(result.AppendASCII("t2")));
196 } 196 }
197 197
(...skipping 10 matching lines...) Expand all
208 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 208 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
209 EXPECT_TRUE(PathService::Override(base::DIR_TEMP, temp_dir.path())); 209 EXPECT_TRUE(PathService::Override(base::DIR_TEMP, temp_dir.path()));
210 base::FilePath new_user_data_dir; 210 base::FilePath new_user_data_dir;
211 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); 211 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir));
212 EXPECT_NE(original_user_data_dir, new_user_data_dir); 212 EXPECT_NE(original_user_data_dir, new_user_data_dir);
213 213
214 EXPECT_TRUE(PathService::RemoveOverride(base::DIR_TEMP)); 214 EXPECT_TRUE(PathService::RemoveOverride(base::DIR_TEMP));
215 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); 215 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir));
216 EXPECT_EQ(original_user_data_dir, new_user_data_dir); 216 EXPECT_EQ(original_user_data_dir, new_user_data_dir);
217 } 217 }
OLDNEW
« no previous file with comments | « base/mac/mac_util_unittest.mm ('k') | base/process/memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698