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

Side by Side Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 2282973003: [OfflinePages] Resuming a SavePageRequest now may start processing if network is connected. (Closed)
Patch Set: Added TODO for double loop Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 } 844 }
845 845
846 TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) { 846 TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) {
847 SetNetworkConditionsForTest( 847 SetNetworkConditionsForTest(
848 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE); 848 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE);
849 EXPECT_TRUE(coordinator()->SavePageLater(kUrl1, kClientId1, kUserRequested)); 849 EXPECT_TRUE(coordinator()->SavePageLater(kUrl1, kClientId1, kUserRequested));
850 PumpLoop(); 850 PumpLoop();
851 EXPECT_FALSE(is_busy()); 851 EXPECT_FALSE(is_busy());
852 } 852 }
853 853
854 TEST_F(RequestCoordinatorTest, ResumeStartsProcessingWhenConnected) {
855 SetNetworkConditionsForTest(
856 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE);
857
858 // Add a request to the queue.
859 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1,
860 base::Time::Now(), kUserRequested);
861 coordinator()->queue()->AddRequest(
862 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone,
863 base::Unretained(this)));
864 PumpLoop();
865 EXPECT_FALSE(is_busy());
866
867 // Pause the request.
868 std::vector<int64_t> request_ids;
869 request_ids.push_back(kRequestId1);
870 coordinator()->PauseRequests(request_ids);
871 PumpLoop();
872
873 // Resume the request while disconnected.
874 coordinator()->ResumeRequests(request_ids);
875 PumpLoop();
876 EXPECT_FALSE(is_busy());
877
878 // Pause the request again.
879 coordinator()->PauseRequests(request_ids);
880 PumpLoop();
881
882 // Now simulate being connected.
883 SetNetworkConditionsForTest(
884 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G);
885
886 // Resume the request while connected.
887 coordinator()->ResumeRequests(request_ids);
888 EXPECT_FALSE(is_busy());
889 PumpLoop();
890 EXPECT_TRUE(is_busy());
891 }
892
854 } // namespace offline_pages 893 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698