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

Unified Diff: content/browser/download/download_item_impl_unittest.cc

Issue 1544743003: Revert of [Download] Treat RESUMING_INTERNAL as IN_PROGRESS in DownloadItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unify-downloader-core
Patch Set: Created 5 years 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 | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl_unittest.cc
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index 9ba2d1777ec8f60544a0afb20856d0b1ca56264f..75fce50d7a8c3dca6153bbf7270e571afa147e3e 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -291,8 +291,7 @@
EXPECT_EQ(expected_state, item->GetState());
if (expected_state == DownloadItem::IN_PROGRESS) {
- if (download_file)
- EXPECT_CALL(*download_file, Cancel());
+ EXPECT_CALL(*download_file, Cancel());
item->Cancel(true);
loop_.RunUntilIdle();
}
@@ -421,9 +420,7 @@
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR);
ASSERT_TRUE(observer.CheckAndResetDownloadUpdated());
- // Since the download is resumed automatically, the interrupt count doesn't
- // increase.
- ASSERT_EQ(0, observer.interrupt_count());
+ ASSERT_EQ(1, observer.interrupt_count());
// Test expectations verify that ResumeInterruptedDownload() is called (by way
// of MockResumeInterruptedDownload) after the download is interrupted. But
@@ -432,9 +429,7 @@
// the automatic resumption was triggered.
RunAllPendingInMessageLoops();
- // The download item is currently in RESUMING_INTERNAL state, which maps to
- // IN_PROGRESS.
- CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS);
+ CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
}
// Same as above, but with a non-continuable interrupt.
@@ -454,7 +449,7 @@
ASSERT_EQ(0, observer.resume_count());
RunAllPendingInMessageLoops();
- CleanupItem(item, nullptr, DownloadItem::INTERRUPTED);
+ CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
}
// Check we do correct cleanup for RESUME_MODE_INVALID interrupts.
@@ -481,7 +476,7 @@
ASSERT_EQ(1, observer.interrupt_count());
ASSERT_EQ(0, observer.resume_count());
- CleanupItem(item, nullptr, DownloadItem::INTERRUPTED);
+ CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
}
TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) {
@@ -529,16 +524,17 @@
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path);
RunAllPendingInMessageLoops();
}
+ ASSERT_EQ(i, observer.resume_count());
// Use a continuable interrupt.
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR);
+ ASSERT_EQ(i + 1, observer.interrupt_count());
::testing::Mock::VerifyAndClearExpectations(mock_download_file);
}
- EXPECT_EQ(1, observer.interrupt_count());
- CleanupItem(item, nullptr, DownloadItem::INTERRUPTED);
+ CleanupItem(item, mock_download_file, DownloadItem::INTERRUPTED);
}
// Test that resumption uses the final URL in a URL chain when resuming.
@@ -569,6 +565,8 @@
.Times(1);
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR);
+ ASSERT_TRUE(observer.CheckAndResetDownloadUpdated());
+ ASSERT_EQ(1, observer.interrupt_count());
// Test expectations verify that ResumeInterruptedDownload() is called (by way
// of MockResumeInterruptedDownload) after the download is interrupted. But
@@ -577,8 +575,7 @@
// the resumption was triggered.
RunAllPendingInMessageLoops();
- // The download is currently in RESUMING_INTERNAL, which maps to IN_PROGRESS.
- CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS);
+ CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
}
TEST_F(DownloadItemTest, NotificationAfterRemove) {
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698