| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // If the target directory is unwriteable, then callback should be notified that | 439 // If the target directory is unwriteable, then callback should be notified that |
| 440 // verification failed. | 440 // verification failed. |
| 441 TEST_F(DownloadPathReservationTrackerTest, UnwriteableDirectory) { | 441 TEST_F(DownloadPathReservationTrackerTest, UnwriteableDirectory) { |
| 442 scoped_ptr<MockDownloadItem> item(CreateDownloadItem(1)); | 442 scoped_ptr<MockDownloadItem> item(CreateDownloadItem(1)); |
| 443 base::FilePath path( | 443 base::FilePath path( |
| 444 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt"))); | 444 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt"))); |
| 445 base::FilePath dir(path.DirName()); | 445 base::FilePath dir(path.DirName()); |
| 446 ASSERT_FALSE(IsPathInUse(path)); | 446 ASSERT_FALSE(IsPathInUse(path)); |
| 447 | 447 |
| 448 { | 448 { |
| 449 // Scope for PermissionRestorer | 449 // Scope for FilePermissionRestorer |
| 450 file_util::PermissionRestorer restorer(dir); | 450 base::FilePermissionRestorer restorer(dir); |
| 451 EXPECT_TRUE(file_util::MakeFileUnwritable(dir)); | 451 EXPECT_TRUE(base::MakeFileUnwritable(dir)); |
| 452 base::FilePath reserved_path; | 452 base::FilePath reserved_path; |
| 453 bool verified = true; | 453 bool verified = true; |
| 454 DownloadPathReservationTracker::FilenameConflictAction conflict_action = | 454 DownloadPathReservationTracker::FilenameConflictAction conflict_action = |
| 455 DownloadPathReservationTracker::OVERWRITE; | 455 DownloadPathReservationTracker::OVERWRITE; |
| 456 bool create_directory = false; | 456 bool create_directory = false; |
| 457 CallGetReservedPath( | 457 CallGetReservedPath( |
| 458 item.get(), | 458 item.get(), |
| 459 path, | 459 path, |
| 460 create_directory, | 460 create_directory, |
| 461 conflict_action, | 461 conflict_action, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 create_directory, | 665 create_directory, |
| 666 conflict_action, | 666 conflict_action, |
| 667 &reserved_path, | 667 &reserved_path, |
| 668 &verified); | 668 &verified); |
| 669 // We cannot truncate a path with very long extension. | 669 // We cannot truncate a path with very long extension. |
| 670 EXPECT_FALSE(verified); | 670 EXPECT_FALSE(verified); |
| 671 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); | 671 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); |
| 672 } | 672 } |
| 673 | 673 |
| 674 #endif | 674 #endif |
| OLD | NEW |