| 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" |
| 11 #include "base/files/memory_mapped_file.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "chrome/installer/util/installer_util_test_common.h" | 16 #include "chrome/installer/util/installer_util_test_common.h" |
| 16 #include "chrome/installer/util/move_tree_work_item.h" | 17 #include "chrome/installer/util/move_tree_work_item.h" |
| 17 #include "chrome/installer/util/work_item.h" | 18 #include "chrome/installer/util/work_item.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ASSERT_TRUE(file_util::PathExists(from_file)); | 406 ASSERT_TRUE(file_util::PathExists(from_file)); |
| 406 | 407 |
| 407 // // Create a file hierarchy identical to the one in the source directory. | 408 // // Create a file hierarchy identical to the one in the source directory. |
| 408 base::FilePath to_dir(temp_from_dir_.path()); | 409 base::FilePath to_dir(temp_from_dir_.path()); |
| 409 to_dir = to_dir.AppendASCII("To_Dir"); | 410 to_dir = to_dir.AppendASCII("To_Dir"); |
| 410 ASSERT_TRUE(installer::test::CopyFileHierarchy(from_dir1, to_dir)); | 411 ASSERT_TRUE(installer::test::CopyFileHierarchy(from_dir1, to_dir)); |
| 411 | 412 |
| 412 // Lock one of the files in the to destination directory to prevent moves. | 413 // Lock one of the files in the to destination directory to prevent moves. |
| 413 base::FilePath orig_to_file( | 414 base::FilePath orig_to_file( |
| 414 to_dir.AppendASCII("From_Dir2").AppendASCII("From_File")); | 415 to_dir.AppendASCII("From_Dir2").AppendASCII("From_File")); |
| 415 file_util::MemoryMappedFile mapped_file; | 416 base::MemoryMappedFile mapped_file; |
| 416 EXPECT_TRUE(mapped_file.Initialize(orig_to_file)); | 417 EXPECT_TRUE(mapped_file.Initialize(orig_to_file)); |
| 417 | 418 |
| 418 // First check that we can't do the regular Move(). | 419 // First check that we can't do the regular Move(). |
| 419 scoped_ptr<MoveTreeWorkItem> work_item( | 420 scoped_ptr<MoveTreeWorkItem> work_item( |
| 420 WorkItem::CreateMoveTreeWorkItem(from_dir1, | 421 WorkItem::CreateMoveTreeWorkItem(from_dir1, |
| 421 to_dir, | 422 to_dir, |
| 422 temp_to_dir_.path(), | 423 temp_to_dir_.path(), |
| 423 WorkItem::ALWAYS_MOVE)); | 424 WorkItem::ALWAYS_MOVE)); |
| 424 EXPECT_FALSE(work_item->Do()); | 425 EXPECT_FALSE(work_item->Do()); |
| 425 work_item->Rollback(); | 426 work_item->Rollback(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // the source files. | 534 // the source files. |
| 534 EXPECT_TRUE(file_util::PathExists(from_dir1)); | 535 EXPECT_TRUE(file_util::PathExists(from_dir1)); |
| 535 EXPECT_TRUE(file_util::PathExists(to_dir)); | 536 EXPECT_TRUE(file_util::PathExists(to_dir)); |
| 536 EXPECT_TRUE(file_util::PathExists(orig_to_file)); | 537 EXPECT_TRUE(file_util::PathExists(orig_to_file)); |
| 537 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); | 538 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); |
| 538 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); | 539 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); |
| 539 | 540 |
| 540 // Also, after rollback the new "to" file should be gone. | 541 // Also, after rollback the new "to" file should be gone. |
| 541 EXPECT_FALSE(file_util::PathExists(new_to_file2)); | 542 EXPECT_FALSE(file_util::PathExists(new_to_file2)); |
| 542 } | 543 } |
| OLD | NEW |