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

Unified Diff: chrome/browser/download/download_path_reservation_tracker_unittest.cc

Issue 2136673002: [Downloads] Path collision check should be case insensitive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_path_reservation_tracker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_path_reservation_tracker_unittest.cc
diff --git a/chrome/browser/download/download_path_reservation_tracker_unittest.cc b/chrome/browser/download/download_path_reservation_tracker_unittest.cc
index fa9f99cd09fddf49cba2eb839f5d910c53772089..7f6f2a5237df7af4ef81b35fdc9fa9280c168dc4 100644
--- a/chrome/browser/download/download_path_reservation_tracker_unittest.cc
+++ b/chrome/browser/download/download_path_reservation_tracker_unittest.cc
@@ -383,6 +383,40 @@ TEST_F(DownloadPathReservationTrackerTest, ConflictingReservations) {
SetDownloadItemState(item3.get(), DownloadItem::COMPLETE);
}
+// Two active downloads shouldn't be able to reserve paths that only differ by
+// case.
+TEST_F(DownloadPathReservationTrackerTest, ConflictingCaseReservations) {
+ std::unique_ptr<MockDownloadItem> item1(CreateDownloadItem(1));
+ std::unique_ptr<MockDownloadItem> item2(CreateDownloadItem(2));
+
+ base::FilePath path_foo =
+ GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt"));
+ base::FilePath path_Foo =
+ GetPathInDownloadsDirectory(FILE_PATH_LITERAL("Foo.txt"));
+
+ base::FilePath first_reservation;
+ bool verified = false;
+ CallGetReservedPath(item1.get(), path_foo, false,
+ DownloadPathReservationTracker::UNIQUIFY,
+ &first_reservation, &verified);
+ EXPECT_TRUE(IsPathInUse(path_foo));
+ EXPECT_TRUE(verified);
+ EXPECT_EQ(path_foo, first_reservation);
+
+ // Foo should also be in use at this point.
+ EXPECT_TRUE(IsPathInUse(path_Foo));
+
+ base::FilePath second_reservation;
+ CallGetReservedPath(item2.get(), path_Foo, false,
+ DownloadPathReservationTracker::UNIQUIFY,
+ &second_reservation, &verified);
+ EXPECT_TRUE(verified);
+ EXPECT_EQ(GetPathInDownloadsDirectory(FILE_PATH_LITERAL("Foo (1).txt")),
svaldez 2016/07/11 15:40:52 Should the original path also be checked?
asanka 2016/07/11 16:27:50 That case is covered in ConflictingReservations te
+ second_reservation);
+ SetDownloadItemState(item1.get(), DownloadItem::COMPLETE);
+ SetDownloadItemState(item2.get(), DownloadItem::COMPLETE);
+}
+
// If a unique path cannot be determined after trying kMaxUniqueFiles
// uniquifiers, then the callback should notified that verification failed, and
// the returned path should be set to the original requested path.
@@ -675,4 +709,4 @@ TEST_F(DownloadPathReservationTrackerTest, TruncationFail) {
SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
}
-#endif
+#endif // Platforms that support filename truncation.
« no previous file with comments | « chrome/browser/download/download_path_reservation_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698