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

Unified Diff: components/offline_pages/downloads/download_notifying_observer_unittest.cc

Issue 2537373004: [OfflinePages] Call NotifyInterrupted for pending requests (Closed)
Patch Set: Created 4 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
Index: components/offline_pages/downloads/download_notifying_observer_unittest.cc
diff --git a/components/offline_pages/downloads/download_notifying_observer_unittest.cc b/components/offline_pages/downloads/download_notifying_observer_unittest.cc
index 7d6f66117adc45ea9ee2a5e818f27a5461cebcc6..6943b129c08b952a6c79809c625d1209373645c7 100644
--- a/components/offline_pages/downloads/download_notifying_observer_unittest.cc
+++ b/components/offline_pages/downloads/download_notifying_observer_unittest.cc
@@ -128,17 +128,38 @@ void DownloadNotifyingObserverTest::SetUp() {
policy_controller_.get()));
}
-TEST_F(DownloadNotifyingObserverTest, OnAdded) {
+TEST_F(DownloadNotifyingObserverTest, OnAddedAsAvailable) {
SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId,
kTestCreationTime, kTestUserRequested);
+ request.set_request_state(SavePageRequest::RequestState::AVAILABLE);
observer()->OnAdded(request);
- EXPECT_EQ(LastNotificationType::DOWNLOAD_PROGRESS,
+ EXPECT_EQ(LastNotificationType::DOWNLOAD_INTERRUPTED,
notifier()->last_notification_type());
EXPECT_EQ(kTestGuid, notifier()->download_item()->guid);
EXPECT_EQ(GURL(kTestUrl), notifier()->download_item()->url);
EXPECT_EQ(kTestCreationTime, notifier()->download_item()->start_time);
}
+TEST_F(DownloadNotifyingObserverTest, OnAddedAsOffling) {
+ SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId,
+ kTestCreationTime, kTestUserRequested);
+ request.set_request_state(SavePageRequest::RequestState::OFFLINING);
+ observer()->OnAdded(request);
+ EXPECT_EQ(LastNotificationType::DOWNLOAD_PROGRESS,
+ notifier()->last_notification_type());
+ EXPECT_EQ(kTestGuid, notifier()->download_item()->guid);
+}
+
+TEST_F(DownloadNotifyingObserverTest, OnAddedAsPaused) {
+ SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId,
+ kTestCreationTime, kTestUserRequested);
+ request.set_request_state(SavePageRequest::RequestState::PAUSED);
+ observer()->OnAdded(request);
+ EXPECT_EQ(LastNotificationType::DOWNLOAD_PAUSED,
+ notifier()->last_notification_type());
+ EXPECT_EQ(kTestGuid, notifier()->download_item()->guid);
+}
+
TEST_F(DownloadNotifyingObserverTest, OnChangedToPaused) {
SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId,
kTestCreationTime, kTestUserRequested);
@@ -156,6 +177,18 @@ TEST_F(DownloadNotifyingObserverTest, OnChangedToAvailable) {
kTestCreationTime, kTestUserRequested);
request.set_request_state(SavePageRequest::RequestState::AVAILABLE);
observer()->OnChanged(request);
+ EXPECT_EQ(LastNotificationType::DOWNLOAD_INTERRUPTED,
+ notifier()->last_notification_type());
+ EXPECT_EQ(kTestGuid, notifier()->download_item()->guid);
+ EXPECT_EQ(GURL(kTestUrl), notifier()->download_item()->url);
+ EXPECT_EQ(kTestCreationTime, notifier()->download_item()->start_time);
+}
+
+TEST_F(DownloadNotifyingObserverTest, OnChangedToOfflining) {
+ SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId,
+ kTestCreationTime, kTestUserRequested);
+ request.set_request_state(SavePageRequest::RequestState::OFFLINING);
+ observer()->OnChanged(request);
EXPECT_EQ(LastNotificationType::DOWNLOAD_PROGRESS,
notifier()->last_notification_type());
EXPECT_EQ(kTestGuid, notifier()->download_item()->guid);

Powered by Google App Engine
This is Rietveld 408576698