| OLD | NEW |
| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 WorkItem::CHECK_DUPLICATES)); | 432 WorkItem::CHECK_DUPLICATES)); |
| 433 EXPECT_TRUE(work_item->Do()); | 433 EXPECT_TRUE(work_item->Do()); |
| 434 | 434 |
| 435 // Make sure that we "moved" the files, i.e. that the source directory isn't | 435 // Make sure that we "moved" the files, i.e. that the source directory isn't |
| 436 // there anymore, | 436 // there anymore, |
| 437 EXPECT_FALSE(base::PathExists(from_dir1)); | 437 EXPECT_FALSE(base::PathExists(from_dir1)); |
| 438 // Make sure that the original directory structure and file are still present. | 438 // Make sure that the original directory structure and file are still present. |
| 439 EXPECT_TRUE(base::PathExists(to_dir)); | 439 EXPECT_TRUE(base::PathExists(to_dir)); |
| 440 EXPECT_TRUE(base::PathExists(orig_to_file)); | 440 EXPECT_TRUE(base::PathExists(orig_to_file)); |
| 441 // Make sure that the backup path is not empty. | 441 // Make sure that the backup path is not empty. |
| 442 EXPECT_FALSE(file_util::IsDirectoryEmpty(temp_to_dir_.path())); | 442 EXPECT_FALSE(base::IsDirectoryEmpty(temp_to_dir_.path())); |
| 443 | 443 |
| 444 // Check that the work item believes the source to have been moved. | 444 // Check that the work item believes the source to have been moved. |
| 445 EXPECT_TRUE(work_item->source_moved_to_backup_); | 445 EXPECT_TRUE(work_item->source_moved_to_backup_); |
| 446 EXPECT_FALSE(work_item->moved_to_dest_path_); | 446 EXPECT_FALSE(work_item->moved_to_dest_path_); |
| 447 EXPECT_FALSE(work_item->moved_to_backup_); | 447 EXPECT_FALSE(work_item->moved_to_backup_); |
| 448 | 448 |
| 449 // test rollback() | 449 // test rollback() |
| 450 work_item->Rollback(); | 450 work_item->Rollback(); |
| 451 | 451 |
| 452 // Once we rollback all the original files should still be there, as should | 452 // Once we rollback all the original files should still be there, as should |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 WorkItem::CHECK_DUPLICATES)); | 508 WorkItem::CHECK_DUPLICATES)); |
| 509 EXPECT_TRUE(work_item->Do()); | 509 EXPECT_TRUE(work_item->Do()); |
| 510 | 510 |
| 511 // Make sure that we "moved" the files, i.e. that the source directory isn't | 511 // Make sure that we "moved" the files, i.e. that the source directory isn't |
| 512 // there anymore, | 512 // there anymore, |
| 513 EXPECT_FALSE(base::PathExists(from_dir1)); | 513 EXPECT_FALSE(base::PathExists(from_dir1)); |
| 514 // Make sure that the original directory structure and file are still present. | 514 // Make sure that the original directory structure and file are still present. |
| 515 EXPECT_TRUE(base::PathExists(to_dir)); | 515 EXPECT_TRUE(base::PathExists(to_dir)); |
| 516 EXPECT_TRUE(base::PathExists(orig_to_file)); | 516 EXPECT_TRUE(base::PathExists(orig_to_file)); |
| 517 // Make sure that the backup path is not empty. | 517 // Make sure that the backup path is not empty. |
| 518 EXPECT_FALSE(file_util::IsDirectoryEmpty(temp_to_dir_.path())); | 518 EXPECT_FALSE(base::IsDirectoryEmpty(temp_to_dir_.path())); |
| 519 // Make sure that the "new" file is also present. | 519 // Make sure that the "new" file is also present. |
| 520 base::FilePath new_to_file2(to_dir2); | 520 base::FilePath new_to_file2(to_dir2); |
| 521 new_to_file2 = new_to_file2.AppendASCII("From_File2"); | 521 new_to_file2 = new_to_file2.AppendASCII("From_File2"); |
| 522 EXPECT_TRUE(base::PathExists(new_to_file2)); | 522 EXPECT_TRUE(base::PathExists(new_to_file2)); |
| 523 | 523 |
| 524 // Check that the work item believes that this was a regular move. | 524 // Check that the work item believes that this was a regular move. |
| 525 EXPECT_FALSE(work_item->source_moved_to_backup_); | 525 EXPECT_FALSE(work_item->source_moved_to_backup_); |
| 526 EXPECT_TRUE(work_item->moved_to_dest_path_); | 526 EXPECT_TRUE(work_item->moved_to_dest_path_); |
| 527 EXPECT_TRUE(work_item->moved_to_backup_); | 527 EXPECT_TRUE(work_item->moved_to_backup_); |
| 528 | 528 |
| 529 // test rollback() | 529 // test rollback() |
| 530 work_item->Rollback(); | 530 work_item->Rollback(); |
| 531 | 531 |
| 532 // Once we rollback all the original files should still be there, as should | 532 // Once we rollback all the original files should still be there, as should |
| 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 } |
| OLD | NEW |