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

Side by Side Diff: chrome/installer/util/move_tree_work_item_unittest.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 6
7 #include <fstream> 7 #include <fstream>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const wchar_t kTextContent1[] = L"Gooooooooooooooooooooogle"; 53 const wchar_t kTextContent1[] = L"Gooooooooooooooooooooogle";
54 const wchar_t kTextContent2[] = L"Overwrite Me"; 54 const wchar_t kTextContent2[] = L"Overwrite Me";
55 }; // namespace 55 }; // namespace
56 56
57 // Move one directory from source to destination when destination does not 57 // Move one directory from source to destination when destination does not
58 // exist. 58 // exist.
59 TEST_F(MoveTreeWorkItemTest, MoveDirectory) { 59 TEST_F(MoveTreeWorkItemTest, MoveDirectory) {
60 // Create two level deep source dir 60 // Create two level deep source dir
61 base::FilePath from_dir1(temp_from_dir_.path()); 61 base::FilePath from_dir1(temp_from_dir_.path());
62 from_dir1 = from_dir1.AppendASCII("From_Dir1"); 62 from_dir1 = from_dir1.AppendASCII("From_Dir1");
63 file_util::CreateDirectory(from_dir1); 63 base::CreateDirectory(from_dir1);
64 ASSERT_TRUE(base::PathExists(from_dir1)); 64 ASSERT_TRUE(base::PathExists(from_dir1));
65 65
66 base::FilePath from_dir2(from_dir1); 66 base::FilePath from_dir2(from_dir1);
67 from_dir2 = from_dir2.AppendASCII("From_Dir2"); 67 from_dir2 = from_dir2.AppendASCII("From_Dir2");
68 file_util::CreateDirectory(from_dir2); 68 base::CreateDirectory(from_dir2);
69 ASSERT_TRUE(base::PathExists(from_dir2)); 69 ASSERT_TRUE(base::PathExists(from_dir2));
70 70
71 base::FilePath from_file(from_dir2); 71 base::FilePath from_file(from_dir2);
72 from_file = from_file.AppendASCII("From_File"); 72 from_file = from_file.AppendASCII("From_File");
73 CreateTextFile(from_file.value(), kTextContent1); 73 CreateTextFile(from_file.value(), kTextContent1);
74 ASSERT_TRUE(base::PathExists(from_file)); 74 ASSERT_TRUE(base::PathExists(from_file));
75 75
76 // Generate destination path 76 // Generate destination path
77 base::FilePath to_dir(temp_from_dir_.path()); 77 base::FilePath to_dir(temp_from_dir_.path());
78 to_dir = to_dir.AppendASCII("To_Dir"); 78 to_dir = to_dir.AppendASCII("To_Dir");
(...skipping 23 matching lines...) Expand all
102 EXPECT_TRUE(base::PathExists(from_file)); 102 EXPECT_TRUE(base::PathExists(from_file));
103 EXPECT_FALSE(base::PathExists(to_dir)); 103 EXPECT_FALSE(base::PathExists(to_dir));
104 } 104 }
105 105
106 // Move one directory from source to destination when destination already 106 // Move one directory from source to destination when destination already
107 // exists. 107 // exists.
108 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { 108 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) {
109 // Create two level deep source dir 109 // Create two level deep source dir
110 base::FilePath from_dir1(temp_from_dir_.path()); 110 base::FilePath from_dir1(temp_from_dir_.path());
111 from_dir1 = from_dir1.AppendASCII("From_Dir1"); 111 from_dir1 = from_dir1.AppendASCII("From_Dir1");
112 file_util::CreateDirectory(from_dir1); 112 base::CreateDirectory(from_dir1);
113 ASSERT_TRUE(base::PathExists(from_dir1)); 113 ASSERT_TRUE(base::PathExists(from_dir1));
114 114
115 base::FilePath from_dir2(from_dir1); 115 base::FilePath from_dir2(from_dir1);
116 from_dir2 = from_dir2.AppendASCII("From_Dir2"); 116 from_dir2 = from_dir2.AppendASCII("From_Dir2");
117 file_util::CreateDirectory(from_dir2); 117 base::CreateDirectory(from_dir2);
118 ASSERT_TRUE(base::PathExists(from_dir2)); 118 ASSERT_TRUE(base::PathExists(from_dir2));
119 119
120 base::FilePath from_file(from_dir2); 120 base::FilePath from_file(from_dir2);
121 from_file = from_file.AppendASCII("From_File"); 121 from_file = from_file.AppendASCII("From_File");
122 CreateTextFile(from_file.value(), kTextContent1); 122 CreateTextFile(from_file.value(), kTextContent1);
123 ASSERT_TRUE(base::PathExists(from_file)); 123 ASSERT_TRUE(base::PathExists(from_file));
124 124
125 // Create destination path 125 // Create destination path
126 base::FilePath to_dir(temp_from_dir_.path()); 126 base::FilePath to_dir(temp_from_dir_.path());
127 to_dir = to_dir.AppendASCII("To_Dir"); 127 to_dir = to_dir.AppendASCII("To_Dir");
128 file_util::CreateDirectory(to_dir); 128 base::CreateDirectory(to_dir);
129 ASSERT_TRUE(base::PathExists(to_dir)); 129 ASSERT_TRUE(base::PathExists(to_dir));
130 130
131 base::FilePath orig_to_file(to_dir); 131 base::FilePath orig_to_file(to_dir);
132 orig_to_file = orig_to_file.AppendASCII("To_File"); 132 orig_to_file = orig_to_file.AppendASCII("To_File");
133 CreateTextFile(orig_to_file.value(), kTextContent2); 133 CreateTextFile(orig_to_file.value(), kTextContent2);
134 ASSERT_TRUE(base::PathExists(orig_to_file)); 134 ASSERT_TRUE(base::PathExists(orig_to_file));
135 135
136 base::FilePath new_to_file(to_dir); 136 base::FilePath new_to_file(to_dir);
137 new_to_file = new_to_file.AppendASCII("From_Dir2"); 137 new_to_file = new_to_file.AppendASCII("From_Dir2");
138 new_to_file = new_to_file.AppendASCII("From_File"); 138 new_to_file = new_to_file.AppendASCII("From_File");
(...skipping 22 matching lines...) Expand all
161 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent2)); 161 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent2));
162 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); 162 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1));
163 } 163 }
164 164
165 // Move one file from source to destination when destination does not 165 // Move one file from source to destination when destination does not
166 // exist. 166 // exist.
167 TEST_F(MoveTreeWorkItemTest, MoveAFile) { 167 TEST_F(MoveTreeWorkItemTest, MoveAFile) {
168 // Create a file inside source dir 168 // Create a file inside source dir
169 base::FilePath from_dir(temp_from_dir_.path()); 169 base::FilePath from_dir(temp_from_dir_.path());
170 from_dir = from_dir.AppendASCII("From_Dir"); 170 from_dir = from_dir.AppendASCII("From_Dir");
171 file_util::CreateDirectory(from_dir); 171 base::CreateDirectory(from_dir);
172 ASSERT_TRUE(base::PathExists(from_dir)); 172 ASSERT_TRUE(base::PathExists(from_dir));
173 173
174 base::FilePath from_file(from_dir); 174 base::FilePath from_file(from_dir);
175 from_file = from_file.AppendASCII("From_File"); 175 from_file = from_file.AppendASCII("From_File");
176 CreateTextFile(from_file.value(), kTextContent1); 176 CreateTextFile(from_file.value(), kTextContent1);
177 ASSERT_TRUE(base::PathExists(from_file)); 177 ASSERT_TRUE(base::PathExists(from_file));
178 178
179 // Generate destination file name 179 // Generate destination file name
180 base::FilePath to_file(temp_from_dir_.path()); 180 base::FilePath to_file(temp_from_dir_.path());
181 to_file = to_file.AppendASCII("To_File"); 181 to_file = to_file.AppendASCII("To_File");
(...skipping 20 matching lines...) Expand all
202 EXPECT_FALSE(base::PathExists(to_file)); 202 EXPECT_FALSE(base::PathExists(to_file));
203 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); 203 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1));
204 } 204 }
205 205
206 // Move one file from source to destination when destination already 206 // Move one file from source to destination when destination already
207 // exists. 207 // exists.
208 TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { 208 TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) {
209 // Create a file inside source dir 209 // Create a file inside source dir
210 base::FilePath from_dir(temp_from_dir_.path()); 210 base::FilePath from_dir(temp_from_dir_.path());
211 from_dir = from_dir.AppendASCII("From_Dir"); 211 from_dir = from_dir.AppendASCII("From_Dir");
212 file_util::CreateDirectory(from_dir); 212 base::CreateDirectory(from_dir);
213 ASSERT_TRUE(base::PathExists(from_dir)); 213 ASSERT_TRUE(base::PathExists(from_dir));
214 214
215 base::FilePath from_file(from_dir); 215 base::FilePath from_file(from_dir);
216 from_file = from_file.AppendASCII("From_File"); 216 from_file = from_file.AppendASCII("From_File");
217 CreateTextFile(from_file.value(), kTextContent1); 217 CreateTextFile(from_file.value(), kTextContent1);
218 ASSERT_TRUE(base::PathExists(from_file)); 218 ASSERT_TRUE(base::PathExists(from_file));
219 219
220 // Create destination path 220 // Create destination path
221 base::FilePath to_dir(temp_from_dir_.path()); 221 base::FilePath to_dir(temp_from_dir_.path());
222 to_dir = to_dir.AppendASCII("To_Dir"); 222 to_dir = to_dir.AppendASCII("To_Dir");
223 file_util::CreateDirectory(to_dir); 223 base::CreateDirectory(to_dir);
224 ASSERT_TRUE(base::PathExists(to_dir)); 224 ASSERT_TRUE(base::PathExists(to_dir));
225 225
226 base::FilePath to_file(to_dir); 226 base::FilePath to_file(to_dir);
227 to_file = to_file.AppendASCII("To_File"); 227 to_file = to_file.AppendASCII("To_File");
228 CreateTextFile(to_file.value(), kTextContent2); 228 CreateTextFile(to_file.value(), kTextContent2);
229 ASSERT_TRUE(base::PathExists(to_file)); 229 ASSERT_TRUE(base::PathExists(to_file));
230 230
231 // test Do() 231 // test Do()
232 scoped_ptr<MoveTreeWorkItem> work_item( 232 scoped_ptr<MoveTreeWorkItem> work_item(
233 WorkItem::CreateMoveTreeWorkItem(from_file, 233 WorkItem::CreateMoveTreeWorkItem(from_file,
(...skipping 16 matching lines...) Expand all
250 EXPECT_TRUE(base::PathExists(to_dir)); 250 EXPECT_TRUE(base::PathExists(to_dir));
251 EXPECT_EQ(0, ReadTextFile(to_file).compare(kTextContent2)); 251 EXPECT_EQ(0, ReadTextFile(to_file).compare(kTextContent2));
252 } 252 }
253 253
254 // Move one file from source to destination when destination already 254 // Move one file from source to destination when destination already
255 // exists and is in use. 255 // exists and is in use.
256 TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { 256 TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) {
257 // Create a file inside source dir 257 // Create a file inside source dir
258 base::FilePath from_dir(temp_from_dir_.path()); 258 base::FilePath from_dir(temp_from_dir_.path());
259 from_dir = from_dir.AppendASCII("From_Dir"); 259 from_dir = from_dir.AppendASCII("From_Dir");
260 file_util::CreateDirectory(from_dir); 260 base::CreateDirectory(from_dir);
261 ASSERT_TRUE(base::PathExists(from_dir)); 261 ASSERT_TRUE(base::PathExists(from_dir));
262 262
263 base::FilePath from_file(from_dir); 263 base::FilePath from_file(from_dir);
264 from_file = from_file.AppendASCII("From_File"); 264 from_file = from_file.AppendASCII("From_File");
265 CreateTextFile(from_file.value(), kTextContent1); 265 CreateTextFile(from_file.value(), kTextContent1);
266 ASSERT_TRUE(base::PathExists(from_file)); 266 ASSERT_TRUE(base::PathExists(from_file));
267 267
268 // Create an executable in destination path by copying ourself to it. 268 // Create an executable in destination path by copying ourself to it.
269 base::FilePath to_dir(temp_from_dir_.path()); 269 base::FilePath to_dir(temp_from_dir_.path());
270 to_dir = to_dir.AppendASCII("To_Dir"); 270 to_dir = to_dir.AppendASCII("To_Dir");
271 file_util::CreateDirectory(to_dir); 271 base::CreateDirectory(to_dir);
272 ASSERT_TRUE(base::PathExists(to_dir)); 272 ASSERT_TRUE(base::PathExists(to_dir));
273 273
274 wchar_t exe_full_path_str[MAX_PATH]; 274 wchar_t exe_full_path_str[MAX_PATH];
275 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); 275 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
276 base::FilePath exe_full_path(exe_full_path_str); 276 base::FilePath exe_full_path(exe_full_path_str);
277 base::FilePath to_file(to_dir); 277 base::FilePath to_file(to_dir);
278 to_file = to_file.AppendASCII("To_File"); 278 to_file = to_file.AppendASCII("To_File");
279 base::CopyFile(exe_full_path, to_file); 279 base::CopyFile(exe_full_path, to_file);
280 ASSERT_TRUE(base::PathExists(to_file)); 280 ASSERT_TRUE(base::PathExists(to_file));
281 281
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 EXPECT_TRUE(WaitForSingleObject(pi.hProcess, 10000) == WAIT_OBJECT_0); 313 EXPECT_TRUE(WaitForSingleObject(pi.hProcess, 10000) == WAIT_OBJECT_0);
314 CloseHandle(pi.hProcess); 314 CloseHandle(pi.hProcess);
315 CloseHandle(pi.hThread); 315 CloseHandle(pi.hThread);
316 } 316 }
317 317
318 // Move one file that is in use to destination. 318 // Move one file that is in use to destination.
319 TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { 319 TEST_F(MoveTreeWorkItemTest, MoveFileInUse) {
320 // Create an executable for source by copying ourself to a new source dir. 320 // Create an executable for source by copying ourself to a new source dir.
321 base::FilePath from_dir(temp_from_dir_.path()); 321 base::FilePath from_dir(temp_from_dir_.path());
322 from_dir = from_dir.AppendASCII("From_Dir"); 322 from_dir = from_dir.AppendASCII("From_Dir");
323 file_util::CreateDirectory(from_dir); 323 base::CreateDirectory(from_dir);
324 ASSERT_TRUE(base::PathExists(from_dir)); 324 ASSERT_TRUE(base::PathExists(from_dir));
325 325
326 wchar_t exe_full_path_str[MAX_PATH]; 326 wchar_t exe_full_path_str[MAX_PATH];
327 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); 327 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
328 base::FilePath exe_full_path(exe_full_path_str); 328 base::FilePath exe_full_path(exe_full_path_str);
329 base::FilePath from_file(from_dir); 329 base::FilePath from_file(from_dir);
330 from_file = from_file.AppendASCII("From_File"); 330 from_file = from_file.AppendASCII("From_File");
331 base::CopyFile(exe_full_path, from_file); 331 base::CopyFile(exe_full_path, from_file);
332 ASSERT_TRUE(base::PathExists(from_file)); 332 ASSERT_TRUE(base::PathExists(from_file));
333 333
334 // Create a destination source dir and generate destination file name. 334 // Create a destination source dir and generate destination file name.
335 base::FilePath to_dir(temp_from_dir_.path()); 335 base::FilePath to_dir(temp_from_dir_.path());
336 to_dir = to_dir.AppendASCII("To_Dir"); 336 to_dir = to_dir.AppendASCII("To_Dir");
337 file_util::CreateDirectory(to_dir); 337 base::CreateDirectory(to_dir);
338 ASSERT_TRUE(base::PathExists(to_dir)); 338 ASSERT_TRUE(base::PathExists(to_dir));
339 339
340 base::FilePath to_file(to_dir); 340 base::FilePath to_file(to_dir);
341 to_file = to_file.AppendASCII("To_File"); 341 to_file = to_file.AppendASCII("To_File");
342 CreateTextFile(to_file.value(), kTextContent1); 342 CreateTextFile(to_file.value(), kTextContent1);
343 ASSERT_TRUE(base::PathExists(to_file)); 343 ASSERT_TRUE(base::PathExists(to_file));
344 344
345 // Run the executable in source path 345 // Run the executable in source path
346 STARTUPINFOW si = {sizeof(si)}; 346 STARTUPINFOW si = {sizeof(si)};
347 PROCESS_INFORMATION pi = {0}; 347 PROCESS_INFORMATION pi = {0};
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 EXPECT_TRUE(base::PathExists(to_dir)); 384 EXPECT_TRUE(base::PathExists(to_dir));
385 EXPECT_EQ(0, ReadTextFile(to_file).compare(kTextContent1)); 385 EXPECT_EQ(0, ReadTextFile(to_file).compare(kTextContent1));
386 } 386 }
387 387
388 // Move one directory from source to destination when destination already 388 // Move one directory from source to destination when destination already
389 // exists. 389 // exists.
390 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExistsCheckForDuplicatesFull) { 390 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExistsCheckForDuplicatesFull) {
391 // Create two level deep source dir 391 // Create two level deep source dir
392 base::FilePath from_dir1(temp_from_dir_.path()); 392 base::FilePath from_dir1(temp_from_dir_.path());
393 from_dir1 = from_dir1.AppendASCII("From_Dir1"); 393 from_dir1 = from_dir1.AppendASCII("From_Dir1");
394 file_util::CreateDirectory(from_dir1); 394 base::CreateDirectory(from_dir1);
395 ASSERT_TRUE(base::PathExists(from_dir1)); 395 ASSERT_TRUE(base::PathExists(from_dir1));
396 396
397 base::FilePath from_dir2(from_dir1); 397 base::FilePath from_dir2(from_dir1);
398 from_dir2 = from_dir2.AppendASCII("From_Dir2"); 398 from_dir2 = from_dir2.AppendASCII("From_Dir2");
399 file_util::CreateDirectory(from_dir2); 399 base::CreateDirectory(from_dir2);
400 ASSERT_TRUE(base::PathExists(from_dir2)); 400 ASSERT_TRUE(base::PathExists(from_dir2));
401 401
402 base::FilePath from_file(from_dir2); 402 base::FilePath from_file(from_dir2);
403 from_file = from_file.AppendASCII("From_File"); 403 from_file = from_file.AppendASCII("From_File");
404 CreateTextFile(from_file.value(), kTextContent1); 404 CreateTextFile(from_file.value(), kTextContent1);
405 ASSERT_TRUE(base::PathExists(from_file)); 405 ASSERT_TRUE(base::PathExists(from_file));
406 406
407 // // Create a file hierarchy identical to the one in the source directory. 407 // // Create a file hierarchy identical to the one in the source directory.
408 base::FilePath to_dir(temp_from_dir_.path()); 408 base::FilePath to_dir(temp_from_dir_.path());
409 to_dir = to_dir.AppendASCII("To_Dir"); 409 to_dir = to_dir.AppendASCII("To_Dir");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); 457 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1));
458 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); 458 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1));
459 } 459 }
460 460
461 // Move one directory from source to destination when destination already 461 // Move one directory from source to destination when destination already
462 // exists but contains only a subset of the files in source. 462 // exists but contains only a subset of the files in source.
463 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExistsCheckForDuplicatesPartial) { 463 TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExistsCheckForDuplicatesPartial) {
464 // Create two level deep source dir 464 // Create two level deep source dir
465 base::FilePath from_dir1(temp_from_dir_.path()); 465 base::FilePath from_dir1(temp_from_dir_.path());
466 from_dir1 = from_dir1.AppendASCII("From_Dir1"); 466 from_dir1 = from_dir1.AppendASCII("From_Dir1");
467 file_util::CreateDirectory(from_dir1); 467 base::CreateDirectory(from_dir1);
468 ASSERT_TRUE(base::PathExists(from_dir1)); 468 ASSERT_TRUE(base::PathExists(from_dir1));
469 469
470 base::FilePath from_dir2(from_dir1); 470 base::FilePath from_dir2(from_dir1);
471 from_dir2 = from_dir2.AppendASCII("From_Dir2"); 471 from_dir2 = from_dir2.AppendASCII("From_Dir2");
472 file_util::CreateDirectory(from_dir2); 472 base::CreateDirectory(from_dir2);
473 ASSERT_TRUE(base::PathExists(from_dir2)); 473 ASSERT_TRUE(base::PathExists(from_dir2));
474 474
475 base::FilePath from_file(from_dir2); 475 base::FilePath from_file(from_dir2);
476 from_file = from_file.AppendASCII("From_File"); 476 from_file = from_file.AppendASCII("From_File");
477 CreateTextFile(from_file.value(), kTextContent1); 477 CreateTextFile(from_file.value(), kTextContent1);
478 ASSERT_TRUE(base::PathExists(from_file)); 478 ASSERT_TRUE(base::PathExists(from_file));
479 479
480 base::FilePath from_file2(from_dir2); 480 base::FilePath from_file2(from_dir2);
481 from_file2 = from_file2.AppendASCII("From_File2"); 481 from_file2 = from_file2.AppendASCII("From_File2");
482 CreateTextFile(from_file2.value(), kTextContent2); 482 CreateTextFile(from_file2.value(), kTextContent2);
483 ASSERT_TRUE(base::PathExists(from_file2)); 483 ASSERT_TRUE(base::PathExists(from_file2));
484 484
485 // Create destination path 485 // Create destination path
486 base::FilePath to_dir(temp_from_dir_.path()); 486 base::FilePath to_dir(temp_from_dir_.path());
487 to_dir = to_dir.AppendASCII("To_Dir"); 487 to_dir = to_dir.AppendASCII("To_Dir");
488 file_util::CreateDirectory(to_dir); 488 base::CreateDirectory(to_dir);
489 ASSERT_TRUE(base::PathExists(to_dir)); 489 ASSERT_TRUE(base::PathExists(to_dir));
490 490
491 // Create a sub-directory of the same name as in the source directory. 491 // Create a sub-directory of the same name as in the source directory.
492 base::FilePath to_dir2(to_dir); 492 base::FilePath to_dir2(to_dir);
493 to_dir2 = to_dir2.AppendASCII("From_Dir2"); 493 to_dir2 = to_dir2.AppendASCII("From_Dir2");
494 file_util::CreateDirectory(to_dir2); 494 base::CreateDirectory(to_dir2);
495 ASSERT_TRUE(base::PathExists(to_dir2)); 495 ASSERT_TRUE(base::PathExists(to_dir2));
496 496
497 // Create one of the files in the to sub-directory, but not the other. 497 // Create one of the files in the to sub-directory, but not the other.
498 base::FilePath orig_to_file(to_dir2); 498 base::FilePath orig_to_file(to_dir2);
499 orig_to_file = orig_to_file.AppendASCII("From_File"); 499 orig_to_file = orig_to_file.AppendASCII("From_File");
500 CreateTextFile(orig_to_file.value(), kTextContent1); 500 CreateTextFile(orig_to_file.value(), kTextContent1);
501 ASSERT_TRUE(base::PathExists(orig_to_file)); 501 ASSERT_TRUE(base::PathExists(orig_to_file));
502 502
503 // test Do(), check for duplicates. 503 // test Do(), check for duplicates.
504 scoped_ptr<MoveTreeWorkItem> work_item( 504 scoped_ptr<MoveTreeWorkItem> work_item(
(...skipping 28 matching lines...) Expand all
533 // the source files. 533 // the source files.
534 EXPECT_TRUE(base::PathExists(from_dir1)); 534 EXPECT_TRUE(base::PathExists(from_dir1));
535 EXPECT_TRUE(base::PathExists(to_dir)); 535 EXPECT_TRUE(base::PathExists(to_dir));
536 EXPECT_TRUE(base::PathExists(orig_to_file)); 536 EXPECT_TRUE(base::PathExists(orig_to_file));
537 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); 537 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1));
538 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); 538 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1));
539 539
540 // Also, after rollback the new "to" file should be gone. 540 // Also, after rollback the new "to" file should be gone.
541 EXPECT_FALSE(base::PathExists(new_to_file2)); 541 EXPECT_FALSE(base::PathExists(new_to_file2));
542 } 542 }
OLDNEW
« no previous file with comments | « chrome/installer/util/lzma_util_unittest.cc ('k') | chrome/installer/util/self_cleaning_temp_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698