OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/offline_pages/core/background/request_coordinator.h" | 5 #include "components/offline_pages/core/background/request_coordinator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 &RequestCoordinatorTest::GetRequestsDone, base::Unretained(this))); | 777 &RequestCoordinatorTest::GetRequestsDone, base::Unretained(this))); |
778 PumpLoop(); | 778 PumpLoop(); |
779 | 779 |
780 // Now just one request in the queue since non-retryable failure. | 780 // Now just one request in the queue since non-retryable failure. |
781 EXPECT_EQ(1UL, last_requests().size()); | 781 EXPECT_EQ(1UL, last_requests().size()); |
782 // Check that the observer got the notification that we failed (and the | 782 // Check that the observer got the notification that we failed (and the |
783 // subsequent notification that the request was removed). | 783 // subsequent notification that the request was removed). |
784 EXPECT_TRUE(observer().completed_called()); | 784 EXPECT_TRUE(observer().completed_called()); |
785 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::LOADING_FAILURE, | 785 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::LOADING_FAILURE, |
786 observer().last_status()); | 786 observer().last_status()); |
| 787 // We should have a histogram entry for the effective network conditions |
| 788 // when this failed request began. |
| 789 histograms().ExpectBucketCount( |
| 790 "OfflinePages.Background.EffectiveConnectionType.OffliningStartType." |
| 791 "bookmark", |
| 792 net::NetworkChangeNotifier::CONNECTION_UNKNOWN, 1); |
787 } | 793 } |
788 | 794 |
789 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailedNoNextFailure) { | 795 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestFailedNoNextFailure) { |
790 // Add a request to the queue, wait for callbacks to finish. | 796 // Add a request to the queue, wait for callbacks to finish. |
791 offline_pages::SavePageRequest request(kRequestId1, kUrl1, kClientId1, | 797 offline_pages::SavePageRequest request(kRequestId1, kUrl1, kClientId1, |
792 base::Time::Now(), kUserRequested); | 798 base::Time::Now(), kUserRequested); |
793 SetupForOfflinerDoneCallbackTest(&request); | 799 SetupForOfflinerDoneCallbackTest(&request); |
794 EnableOfflinerCallback(false); | 800 EnableOfflinerCallback(false); |
795 | 801 |
796 // Add second request to the queue to check handling when first fails. | 802 // Add second request to the queue to check handling when first fails. |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 PumpLoop(); | 1579 PumpLoop(); |
1574 | 1580 |
1575 // The last time would trigger the snapshot on last retry and succeed. | 1581 // The last time would trigger the snapshot on last retry and succeed. |
1576 EXPECT_FALSE(OfflinerWasCanceled()); | 1582 EXPECT_FALSE(OfflinerWasCanceled()); |
1577 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::SUCCESS, | 1583 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::SUCCESS, |
1578 observer().last_status()); | 1584 observer().last_status()); |
1579 EXPECT_TRUE(observer().completed_called()); | 1585 EXPECT_TRUE(observer().completed_called()); |
1580 } | 1586 } |
1581 | 1587 |
1582 } // namespace offline_pages | 1588 } // namespace offline_pages |
OLD | NEW |