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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 base::FilePath to_dir(temp_from_dir_.path()); | 270 base::FilePath to_dir(temp_from_dir_.path()); |
271 to_dir = to_dir.AppendASCII("To_Dir"); | 271 to_dir = to_dir.AppendASCII("To_Dir"); |
272 file_util::CreateDirectory(to_dir); | 272 file_util::CreateDirectory(to_dir); |
273 ASSERT_TRUE(file_util::PathExists(to_dir)); | 273 ASSERT_TRUE(file_util::PathExists(to_dir)); |
274 | 274 |
275 wchar_t exe_full_path_str[MAX_PATH]; | 275 wchar_t exe_full_path_str[MAX_PATH]; |
276 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); | 276 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); |
277 base::FilePath exe_full_path(exe_full_path_str); | 277 base::FilePath exe_full_path(exe_full_path_str); |
278 base::FilePath to_file(to_dir); | 278 base::FilePath to_file(to_dir); |
279 to_file = to_file.AppendASCII("To_File"); | 279 to_file = to_file.AppendASCII("To_File"); |
280 file_util::CopyFile(exe_full_path, to_file); | 280 base::CopyFile(exe_full_path, to_file); |
281 ASSERT_TRUE(file_util::PathExists(to_file)); | 281 ASSERT_TRUE(file_util::PathExists(to_file)); |
282 | 282 |
283 // Run the executable in destination path | 283 // Run the executable in destination path |
284 STARTUPINFOW si = {sizeof(si)}; | 284 STARTUPINFOW si = {sizeof(si)}; |
285 PROCESS_INFORMATION pi = {0}; | 285 PROCESS_INFORMATION pi = {0}; |
286 ASSERT_TRUE(::CreateProcess(NULL, | 286 ASSERT_TRUE(::CreateProcess(NULL, |
287 const_cast<wchar_t*>(to_file.value().c_str()), | 287 const_cast<wchar_t*>(to_file.value().c_str()), |
288 NULL, NULL, FALSE, | 288 NULL, NULL, FALSE, |
289 CREATE_NO_WINDOW | CREATE_SUSPENDED, | 289 CREATE_NO_WINDOW | CREATE_SUSPENDED, |
290 NULL, NULL, &si, &pi)); | 290 NULL, NULL, &si, &pi)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 base::FilePath from_dir(temp_from_dir_.path()); | 322 base::FilePath from_dir(temp_from_dir_.path()); |
323 from_dir = from_dir.AppendASCII("From_Dir"); | 323 from_dir = from_dir.AppendASCII("From_Dir"); |
324 file_util::CreateDirectory(from_dir); | 324 file_util::CreateDirectory(from_dir); |
325 ASSERT_TRUE(file_util::PathExists(from_dir)); | 325 ASSERT_TRUE(file_util::PathExists(from_dir)); |
326 | 326 |
327 wchar_t exe_full_path_str[MAX_PATH]; | 327 wchar_t exe_full_path_str[MAX_PATH]; |
328 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); | 328 ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); |
329 base::FilePath exe_full_path(exe_full_path_str); | 329 base::FilePath exe_full_path(exe_full_path_str); |
330 base::FilePath from_file(from_dir); | 330 base::FilePath from_file(from_dir); |
331 from_file = from_file.AppendASCII("From_File"); | 331 from_file = from_file.AppendASCII("From_File"); |
332 file_util::CopyFile(exe_full_path, from_file); | 332 base::CopyFile(exe_full_path, from_file); |
333 ASSERT_TRUE(file_util::PathExists(from_file)); | 333 ASSERT_TRUE(file_util::PathExists(from_file)); |
334 | 334 |
335 // Create a destination source dir and generate destination file name. | 335 // Create a destination source dir and generate destination file name. |
336 base::FilePath to_dir(temp_from_dir_.path()); | 336 base::FilePath to_dir(temp_from_dir_.path()); |
337 to_dir = to_dir.AppendASCII("To_Dir"); | 337 to_dir = to_dir.AppendASCII("To_Dir"); |
338 file_util::CreateDirectory(to_dir); | 338 file_util::CreateDirectory(to_dir); |
339 ASSERT_TRUE(file_util::PathExists(to_dir)); | 339 ASSERT_TRUE(file_util::PathExists(to_dir)); |
340 | 340 |
341 base::FilePath to_file(to_dir); | 341 base::FilePath to_file(to_dir); |
342 to_file = to_file.AppendASCII("To_File"); | 342 to_file = to_file.AppendASCII("To_File"); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // the source files. | 534 // the source files. |
535 EXPECT_TRUE(file_util::PathExists(from_dir1)); | 535 EXPECT_TRUE(file_util::PathExists(from_dir1)); |
536 EXPECT_TRUE(file_util::PathExists(to_dir)); | 536 EXPECT_TRUE(file_util::PathExists(to_dir)); |
537 EXPECT_TRUE(file_util::PathExists(orig_to_file)); | 537 EXPECT_TRUE(file_util::PathExists(orig_to_file)); |
538 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); | 538 EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(kTextContent1)); |
539 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); | 539 EXPECT_EQ(0, ReadTextFile(from_file).compare(kTextContent1)); |
540 | 540 |
541 // Also, after rollback the new "to" file should be gone. | 541 // Also, after rollback the new "to" file should be gone. |
542 EXPECT_FALSE(file_util::PathExists(new_to_file2)); | 542 EXPECT_FALSE(file_util::PathExists(new_to_file2)); |
543 } | 543 } |
OLD | NEW |