Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: base/file_util_unittest.cc

Issue 11877016: Revert 176659 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698