| 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 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 base::ScopedTempDir temp_from_dir_; | 28 base::ScopedTempDir temp_from_dir_; |
| 29 base::ScopedTempDir temp_to_dir_; | 29 base::ScopedTempDir temp_to_dir_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // Simple function to dump some text into a new file. | 32 // Simple function to dump some text into a new file. |
| 33 void CreateTextFile(const std::wstring& filename, | 33 void CreateTextFile(const std::wstring& filename, |
| 34 const std::wstring& contents) { | 34 const std::wstring& contents) { |
| 35 std::wofstream file; | 35 std::wofstream file; |
| 36 file.open(WideToASCII(filename).c_str()); | 36 file.open(base::WideToASCII(filename).c_str()); |
| 37 ASSERT_TRUE(file.is_open()); | 37 ASSERT_TRUE(file.is_open()); |
| 38 file << contents; | 38 file << contents; |
| 39 file.close(); | 39 file.close(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Simple function to read text from a file. | 42 // Simple function to read text from a file. |
| 43 std::wstring ReadTextFile(const base::FilePath& path) { | 43 std::wstring ReadTextFile(const base::FilePath& path) { |
| 44 WCHAR contents[64]; | 44 WCHAR contents[64]; |
| 45 std::wifstream file; | 45 std::wifstream file; |
| 46 file.open(WideToASCII(path.value()).c_str()); | 46 file.open(base::WideToASCII(path.value()).c_str()); |
| 47 EXPECT_TRUE(file.is_open()); | 47 EXPECT_TRUE(file.is_open()); |
| 48 file.getline(contents, arraysize(contents)); | 48 file.getline(contents, arraysize(contents)); |
| 49 file.close(); | 49 file.close(); |
| 50 return std::wstring(contents); | 50 return std::wstring(contents); |
| 51 } | 51 } |
| 52 | 52 |
| 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 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // the source files. | 533 // the source files. |
| 534 EXPECT_TRUE(file_util::PathExists(from_dir1)); | 534 EXPECT_TRUE(file_util::PathExists(from_dir1)); |
| 535 EXPECT_TRUE(file_util::PathExists(to_dir)); | 535 EXPECT_TRUE(file_util::PathExists(to_dir)); |
| 536 EXPECT_TRUE(file_util::PathExists(orig_to_file)); | 536 EXPECT_TRUE(file_util::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(file_util::PathExists(new_to_file2)); | 541 EXPECT_FALSE(file_util::PathExists(new_to_file2)); |
| 542 } | 542 } |
| OLD | NEW |