Chromium Code Reviews| 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..09cd725418d2ad55f3ffe77c839ba76e3f276477 100644 |
| --- a/components/offline_pages/downloads/download_notifying_observer_unittest.cc |
| +++ b/components/offline_pages/downloads/download_notifying_observer_unittest.cc |
| @@ -128,9 +128,22 @@ 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_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); |
|
Pete Williamson
2016/11/29 23:26:16
It may be overkill to verify all three of these on
dougarnett
2016/11/29 23:57:36
Done
|
| +} |
| + |
| +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()); |
| @@ -139,6 +152,18 @@ TEST_F(DownloadNotifyingObserverTest, OnAdded) { |
| EXPECT_EQ(kTestCreationTime, notifier()->download_item()->start_time); |
| } |
| +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); |
| + EXPECT_EQ(GURL(kTestUrl), notifier()->download_item()->url); |
| + EXPECT_EQ(kTestCreationTime, notifier()->download_item()->start_time); |
| +} |
| + |
| TEST_F(DownloadNotifyingObserverTest, OnChangedToPaused) { |
| SavePageRequest request(kTestOfflineId, GURL(kTestUrl), kTestClientId, |
| kTestCreationTime, kTestUserRequested); |
| @@ -156,6 +181,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); |