| OLD | NEW |
| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 ASSERT_TRUE(file_util::PathExists(dir_name_to)); | 1459 ASSERT_TRUE(file_util::PathExists(dir_name_to)); |
| 1460 FilePath file_name_to = | 1460 FilePath file_name_to = |
| 1461 dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | 1461 dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); |
| 1462 | 1462 |
| 1463 EXPECT_TRUE(file_util::CopyDirectory(file_name_from, dir_name_to, true)); | 1463 EXPECT_TRUE(file_util::CopyDirectory(file_name_from, dir_name_to, true)); |
| 1464 | 1464 |
| 1465 // Check the has been copied | 1465 // Check the has been copied |
| 1466 EXPECT_TRUE(file_util::PathExists(file_name_to)); | 1466 EXPECT_TRUE(file_util::PathExists(file_name_to)); |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) { | |
| 1470 // Create a directory. | |
| 1471 FilePath dir_name_from = | |
| 1472 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); | |
| 1473 file_util::CreateDirectory(dir_name_from); | |
| 1474 ASSERT_TRUE(file_util::PathExists(dir_name_from)); | |
| 1475 | |
| 1476 // Create a file under the directory. | |
| 1477 FilePath file_name_from = | |
| 1478 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | |
| 1479 CreateTextFile(file_name_from, L"Gooooooooooooooooooooogle"); | |
| 1480 ASSERT_TRUE(file_util::PathExists(file_name_from)); | |
| 1481 | |
| 1482 // Copy the directory recursively. | |
| 1483 FilePath dir_name_to = | |
| 1484 temp_dir_.path().Append(FILE_PATH_LITERAL("Destination")); | |
| 1485 FilePath file_name_to = | |
| 1486 dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | |
| 1487 | |
| 1488 // Create from path with trailing separators. | |
| 1489 #if defined(OS_WIN) | |
| 1490 FilePath from_path = | |
| 1491 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir\\\\\\")); | |
| 1492 #elif defined(OS_POSIX) | |
| 1493 FilePath from_path = | |
| 1494 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir///")); | |
| 1495 #endif | |
| 1496 | |
| 1497 EXPECT_TRUE(file_util::CopyDirectory(from_path, dir_name_to, true)); | |
| 1498 | |
| 1499 // Check everything has been copied. | |
| 1500 EXPECT_TRUE(file_util::PathExists(dir_name_from)); | |
| 1501 EXPECT_TRUE(file_util::PathExists(file_name_from)); | |
| 1502 EXPECT_TRUE(file_util::PathExists(dir_name_to)); | |
| 1503 EXPECT_TRUE(file_util::PathExists(file_name_to)); | |
| 1504 } | |
| 1505 | |
| 1506 TEST_F(FileUtilTest, CopyFile) { | 1469 TEST_F(FileUtilTest, CopyFile) { |
| 1507 // Create a directory | 1470 // Create a directory |
| 1508 FilePath dir_name_from = | 1471 FilePath dir_name_from = |
| 1509 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); | 1472 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); |
| 1510 file_util::CreateDirectory(dir_name_from); | 1473 file_util::CreateDirectory(dir_name_from); |
| 1511 ASSERT_TRUE(file_util::PathExists(dir_name_from)); | 1474 ASSERT_TRUE(file_util::PathExists(dir_name_from)); |
| 1512 | 1475 |
| 1513 // Create a file under the directory | 1476 // Create a file under the directory |
| 1514 FilePath file_name_from = | 1477 FilePath file_name_from = |
| 1515 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | 1478 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2477 file_util::VerifyPathControlledByUser( | 2440 file_util::VerifyPathControlledByUser( |
| 2478 base_dir_, text_file_, uid_, ok_gids_)); | 2441 base_dir_, text_file_, uid_, ok_gids_)); |
| 2479 EXPECT_TRUE( | 2442 EXPECT_TRUE( |
| 2480 file_util::VerifyPathControlledByUser( | 2443 file_util::VerifyPathControlledByUser( |
| 2481 sub_dir_, text_file_, uid_, ok_gids_)); | 2444 sub_dir_, text_file_, uid_, ok_gids_)); |
| 2482 } | 2445 } |
| 2483 | 2446 |
| 2484 #endif // defined(OS_POSIX) | 2447 #endif // defined(OS_POSIX) |
| 2485 | 2448 |
| 2486 } // namespace | 2449 } // namespace |
| OLD | NEW |