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

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

Issue 18332014: Move Copy* into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows Created 7 years, 5 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
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 <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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); 330 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
331 base::FilePath exe_full_path(exe_full_path_str); 331 base::FilePath exe_full_path(exe_full_path_str);
332 332
333 base::FilePath dir_name_to(test_dir_.path()); 333 base::FilePath dir_name_to(test_dir_.path());
334 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); 334 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
335 file_util::CreateDirectory(dir_name_to); 335 file_util::CreateDirectory(dir_name_to);
336 ASSERT_TRUE(file_util::PathExists(dir_name_to)); 336 ASSERT_TRUE(file_util::PathExists(dir_name_to));
337 337
338 base::FilePath file_name_to(dir_name_to); 338 base::FilePath file_name_to(dir_name_to);
339 file_name_to = file_name_to.AppendASCII("File_To"); 339 file_name_to = file_name_to.AppendASCII("File_To");
340 file_util::CopyFile(exe_full_path, file_name_to); 340 base::CopyFile(exe_full_path, file_name_to);
341 ASSERT_TRUE(file_util::PathExists(file_name_to)); 341 ASSERT_TRUE(file_util::PathExists(file_name_to));
342 342
343 VLOG(1) << "copy ourself from " << exe_full_path.value() 343 VLOG(1) << "copy ourself from " << exe_full_path.value()
344 << " to " << file_name_to.value(); 344 << " to " << file_name_to.value();
345 345
346 // Run the executable in destination path 346 // Run the executable in destination path
347 STARTUPINFOW si = {sizeof(si)}; 347 STARTUPINFOW si = {sizeof(si)};
348 PROCESS_INFORMATION pi = {0}; 348 PROCESS_INFORMATION pi = {0};
349 ASSERT_TRUE( 349 ASSERT_TRUE(
350 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), 350 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 base::FilePath exe_full_path(exe_full_path_str); 410 base::FilePath exe_full_path(exe_full_path_str);
411 411
412 base::FilePath dir_name_to(test_dir_.path()); 412 base::FilePath dir_name_to(test_dir_.path());
413 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); 413 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
414 file_util::CreateDirectory(dir_name_to); 414 file_util::CreateDirectory(dir_name_to);
415 ASSERT_TRUE(file_util::PathExists(dir_name_to)); 415 ASSERT_TRUE(file_util::PathExists(dir_name_to));
416 416
417 base::FilePath file_name_to(dir_name_to), alternate_to(dir_name_to); 417 base::FilePath file_name_to(dir_name_to), alternate_to(dir_name_to);
418 file_name_to = file_name_to.AppendASCII("File_To"); 418 file_name_to = file_name_to.AppendASCII("File_To");
419 alternate_to = alternate_to.AppendASCII("Alternate_To"); 419 alternate_to = alternate_to.AppendASCII("Alternate_To");
420 file_util::CopyFile(exe_full_path, file_name_to); 420 base::CopyFile(exe_full_path, file_name_to);
421 ASSERT_TRUE(file_util::PathExists(file_name_to)); 421 ASSERT_TRUE(file_util::PathExists(file_name_to));
422 422
423 VLOG(1) << "copy ourself from " << exe_full_path.value() 423 VLOG(1) << "copy ourself from " << exe_full_path.value()
424 << " to " << file_name_to.value(); 424 << " to " << file_name_to.value();
425 425
426 // Run the executable in destination path 426 // Run the executable in destination path
427 STARTUPINFOW si = {sizeof(si)}; 427 STARTUPINFOW si = {sizeof(si)};
428 PROCESS_INFORMATION pi = {0}; 428 PROCESS_INFORMATION pi = {0};
429 ASSERT_TRUE( 429 ASSERT_TRUE(
430 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), 430 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 wchar_t exe_full_path_str[MAX_PATH]; 519 wchar_t exe_full_path_str[MAX_PATH];
520 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); 520 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
521 base::FilePath exe_full_path(exe_full_path_str); 521 base::FilePath exe_full_path(exe_full_path_str);
522 522
523 base::FilePath dir_name_to(test_dir_.path()); 523 base::FilePath dir_name_to(test_dir_.path());
524 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); 524 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
525 file_util::CreateDirectory(dir_name_to); 525 file_util::CreateDirectory(dir_name_to);
526 ASSERT_TRUE(file_util::PathExists(dir_name_to)); 526 ASSERT_TRUE(file_util::PathExists(dir_name_to));
527 base::FilePath file_name_to(dir_name_to); 527 base::FilePath file_name_to(dir_name_to);
528 file_name_to = file_name_to.AppendASCII("File_To"); 528 file_name_to = file_name_to.AppendASCII("File_To");
529 file_util::CopyFile(exe_full_path, file_name_to); 529 base::CopyFile(exe_full_path, file_name_to);
530 ASSERT_TRUE(file_util::PathExists(file_name_to)); 530 ASSERT_TRUE(file_util::PathExists(file_name_to));
531 531
532 // Get the path of backup file 532 // Get the path of backup file
533 base::FilePath backup_file(temp_dir_.path()); 533 base::FilePath backup_file(temp_dir_.path());
534 backup_file = backup_file.AppendASCII("File_To"); 534 backup_file = backup_file.AppendASCII("File_To");
535 535
536 // test Do(). 536 // test Do().
537 scoped_ptr<CopyTreeWorkItem> work_item( 537 scoped_ptr<CopyTreeWorkItem> work_item(
538 WorkItem::CreateCopyTreeWorkItem( 538 WorkItem::CreateCopyTreeWorkItem(
539 file_name_from, 539 file_name_from,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); 602 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
603 base::FilePath exe_full_path(exe_full_path_str); 603 base::FilePath exe_full_path(exe_full_path_str);
604 604
605 base::FilePath dir_name_to(test_dir_.path()); 605 base::FilePath dir_name_to(test_dir_.path());
606 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); 606 dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
607 file_util::CreateDirectory(dir_name_to); 607 file_util::CreateDirectory(dir_name_to);
608 ASSERT_TRUE(file_util::PathExists(dir_name_to)); 608 ASSERT_TRUE(file_util::PathExists(dir_name_to));
609 609
610 base::FilePath file_name_to(dir_name_to); 610 base::FilePath file_name_to(dir_name_to);
611 file_name_to = file_name_to.AppendASCII("File_To"); 611 file_name_to = file_name_to.AppendASCII("File_To");
612 file_util::CopyFile(exe_full_path, file_name_to); 612 base::CopyFile(exe_full_path, file_name_to);
613 ASSERT_TRUE(file_util::PathExists(file_name_to)); 613 ASSERT_TRUE(file_util::PathExists(file_name_to));
614 614
615 VLOG(1) << "copy ourself from " << exe_full_path.value() 615 VLOG(1) << "copy ourself from " << exe_full_path.value()
616 << " to " << file_name_to.value(); 616 << " to " << file_name_to.value();
617 617
618 // Run the executable in destination path 618 // Run the executable in destination path
619 STARTUPINFOW si = {sizeof(si)}; 619 STARTUPINFOW si = {sizeof(si)};
620 PROCESS_INFORMATION pi = {0}; 620 PROCESS_INFORMATION pi = {0};
621 ASSERT_TRUE( 621 ASSERT_TRUE(
622 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), 622 ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1)); 714 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1));
715 715
716 base::FilePath file_name_to_2(dir_name_to); 716 base::FilePath file_name_to_2(dir_name_to);
717 file_name_to_2 = file_name_to_2.AppendASCII("2"); 717 file_name_to_2 = file_name_to_2.AppendASCII("2");
718 file_name_to_2 = file_name_to_2.AppendASCII("File_2.txt"); 718 file_name_to_2 = file_name_to_2.AppendASCII("File_2.txt");
719 EXPECT_TRUE(file_util::PathExists(file_name_to_2)); 719 EXPECT_TRUE(file_util::PathExists(file_name_to_2));
720 VLOG(1) << "compare " << file_name_from_2.value() 720 VLOG(1) << "compare " << file_name_from_2.value()
721 << " and " << file_name_to_2.value(); 721 << " and " << file_name_to_2.value();
722 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2)); 722 EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2));
723 } 723 }
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item.cc ('k') | chrome/installer/util/delete_tree_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698