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 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1464 FilePath file_name_from = | 1464 FilePath file_name_from = |
1465 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); | 1465 dir_name_from.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); |
1466 const std::wstring file_contents(L"Gooooooooooooooooooooogle"); | 1466 const std::wstring file_contents(L"Gooooooooooooooooooooogle"); |
1467 CreateTextFile(file_name_from, file_contents); | 1467 CreateTextFile(file_name_from, file_contents); |
1468 ASSERT_TRUE(PathExists(file_name_from)); | 1468 ASSERT_TRUE(PathExists(file_name_from)); |
1469 | 1469 |
1470 // Copy the file. | 1470 // Copy the file. |
1471 FilePath dest_file = dir_name_from.Append(FILE_PATH_LITERAL("DestFile.txt")); | 1471 FilePath dest_file = dir_name_from.Append(FILE_PATH_LITERAL("DestFile.txt")); |
1472 ASSERT_TRUE(CopyFile(file_name_from, dest_file)); | 1472 ASSERT_TRUE(CopyFile(file_name_from, dest_file)); |
1473 | 1473 |
1474 // Copy the file to another location using '..' in the path. | 1474 // Try to copy the file to another location using '..' in the path. |
1475 FilePath dest_file2(dir_name_from); | 1475 FilePath dest_file2(dir_name_from); |
1476 dest_file2 = dest_file2.AppendASCII(".."); | 1476 dest_file2 = dest_file2.AppendASCII(".."); |
1477 dest_file2 = dest_file2.AppendASCII("DestFile.txt"); | 1477 dest_file2 = dest_file2.AppendASCII("DestFile.txt"); |
1478 ASSERT_FALSE(CopyFile(file_name_from, dest_file2)); | 1478 ASSERT_FALSE(CopyFile(file_name_from, dest_file2)); |
1479 ASSERT_TRUE(internal::CopyFileUnsafe(file_name_from, dest_file2)); | 1479 ASSERT_FALSE(internal::CopyFileUnsafe(file_name_from, dest_file2)); |
rvargas (doing something else)
2014/11/11 23:40:49
Aha!. So the code was already there :)
What we ne
| |
1480 | 1480 |
1481 FilePath dest_file2_test(dir_name_from); | 1481 FilePath dest_file2_test(dir_name_from); |
1482 dest_file2_test = dest_file2_test.DirName(); | 1482 dest_file2_test = dest_file2_test.DirName(); |
1483 dest_file2_test = dest_file2_test.AppendASCII("DestFile.txt"); | 1483 dest_file2_test = dest_file2_test.AppendASCII("DestFile.txt"); |
1484 | 1484 |
1485 // Check everything has been copied. | 1485 // Check everything has been copied. |
1486 EXPECT_TRUE(PathExists(file_name_from)); | 1486 EXPECT_TRUE(PathExists(file_name_from)); |
1487 EXPECT_TRUE(PathExists(dest_file)); | 1487 EXPECT_TRUE(PathExists(dest_file)); |
1488 const std::wstring read_contents = ReadTextFile(dest_file); | 1488 const std::wstring read_contents = ReadTextFile(dest_file); |
1489 EXPECT_EQ(file_contents, read_contents); | 1489 EXPECT_EQ(file_contents, read_contents); |
1490 EXPECT_TRUE(PathExists(dest_file2_test)); | 1490 EXPECT_FALSE(PathExists(dest_file2_test)); |
1491 EXPECT_TRUE(PathExists(dest_file2)); | 1491 EXPECT_FALSE(PathExists(dest_file2)); |
1492 } | 1492 } |
1493 | 1493 |
1494 TEST_F(FileUtilTest, CopyFileACL) { | 1494 TEST_F(FileUtilTest, CopyFileACL) { |
1495 // While FileUtilTest.CopyFile asserts the content is correctly copied over, | 1495 // While FileUtilTest.CopyFile asserts the content is correctly copied over, |
1496 // this test case asserts the access control bits are meeting expectations in | 1496 // this test case asserts the access control bits are meeting expectations in |
1497 // CopyFileUnsafe(). | 1497 // CopyFileUnsafe(). |
1498 FilePath src = temp_dir_.path().Append(FILE_PATH_LITERAL("src.txt")); | 1498 FilePath src = temp_dir_.path().Append(FILE_PATH_LITERAL("src.txt")); |
1499 const std::wstring file_contents(L"Gooooooooooooooooooooogle"); | 1499 const std::wstring file_contents(L"Gooooooooooooooooooooogle"); |
1500 CreateTextFile(src, file_contents); | 1500 CreateTextFile(src, file_contents); |
1501 | 1501 |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2607 // Trying to close it should crash. This is important for security. | 2607 // Trying to close it should crash. This is important for security. |
2608 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2608 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
2609 #endif | 2609 #endif |
2610 } | 2610 } |
2611 | 2611 |
2612 #endif // defined(OS_POSIX) | 2612 #endif // defined(OS_POSIX) |
2613 | 2613 |
2614 } // namespace | 2614 } // namespace |
2615 | 2615 |
2616 } // namespace base | 2616 } // namespace base |
OLD | NEW |