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("Copy_To_Subdir")); |
| 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 |
1469 TEST_F(FileUtilTest, CopyFile) { | 1506 TEST_F(FileUtilTest, CopyFile) { |
1470 // Create a directory | 1507 // Create a directory |
1471 FilePath dir_name_from = | 1508 FilePath dir_name_from = |
1472 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); | 1509 temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); |
1473 file_util::CreateDirectory(dir_name_from); | 1510 file_util::CreateDirectory(dir_name_from); |
1474 ASSERT_TRUE(file_util::PathExists(dir_name_from)); | 1511 ASSERT_TRUE(file_util::PathExists(dir_name_from)); |
1475 | 1512 |
1476 // Create a file under the directory | 1513 // Create a file under the directory |
1477 FilePath file_name_from = | 1514 FilePath file_name_from = |
1478 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | 1515 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 file_util::VerifyPathControlledByUser( | 2442 file_util::VerifyPathControlledByUser( |
2406 base_dir_, text_file_, uid_, ok_gids_)); | 2443 base_dir_, text_file_, uid_, ok_gids_)); |
2407 EXPECT_TRUE( | 2444 EXPECT_TRUE( |
2408 file_util::VerifyPathControlledByUser( | 2445 file_util::VerifyPathControlledByUser( |
2409 sub_dir_, text_file_, uid_, ok_gids_)); | 2446 sub_dir_, text_file_, uid_, ok_gids_)); |
2410 } | 2447 } |
2411 | 2448 |
2412 #endif // defined(OS_POSIX) | 2449 #endif // defined(OS_POSIX) |
2413 | 2450 |
2414 } // namespace | 2451 } // namespace |
OLD | NEW |