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

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

Issue 2454123003: count timeout as a completed attempt. (Closed)
Patch Set: Created 4 years, 1 month 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
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 PumpLoop(); 1067 PumpLoop();
1068 1068
1069 // Wait for timeout to expire. Use a TaskRunner with a DelayedTaskRunner 1069 // Wait for timeout to expire. Use a TaskRunner with a DelayedTaskRunner
1070 // which won't time out immediately, so the watchdog thread doesn't kill valid 1070 // which won't time out immediately, so the watchdog thread doesn't kill valid
1071 // tasks too soon. 1071 // tasks too soon.
1072 WaitForCallback(); 1072 WaitForCallback();
1073 PumpLoop(); 1073 PumpLoop();
1074 1074
1075 EXPECT_FALSE(is_starting()); 1075 EXPECT_FALSE(is_starting());
1076 EXPECT_TRUE(OfflinerWasCanceled()); 1076 EXPECT_TRUE(OfflinerWasCanceled());
1077 EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_TIMED_OUT,
1078 last_offlining_status());
1079 } 1077 }
1080 1078
1081 TEST_F(RequestCoordinatorTest, WatchdogTimeoutForImmediateProcessing) { 1079 TEST_F(RequestCoordinatorTest, WatchdogTimeoutForImmediateProcessing) {
1082 // If low end device, pretend it is not so that immediate start happens. 1080 // If low end device, pretend it is not so that immediate start happens.
1083 SetIsLowEndDeviceForTest(false); 1081 SetIsLowEndDeviceForTest(false);
1084 1082
1085 // Set good network connection so that adding request will trigger 1083 // Set good network connection so that adding request will trigger
1086 // immediate processing. 1084 // immediate processing.
1087 SetEffectiveConnectionTypeForTest( 1085 SetEffectiveConnectionTypeForTest(
1088 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); 1086 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G);
(...skipping 20 matching lines...) Expand all
1109 1107
1110 // Verify still busy. 1108 // Verify still busy.
1111 EXPECT_TRUE(coordinator()->is_busy()); 1109 EXPECT_TRUE(coordinator()->is_busy());
1112 EXPECT_FALSE(OfflinerWasCanceled()); 1110 EXPECT_FALSE(OfflinerWasCanceled());
1113 1111
1114 // Advance the mock clock past the watchdog timeout now. 1112 // Advance the mock clock past the watchdog timeout now.
1115 AdvanceClockBy(base::TimeDelta::FromSeconds(2)); 1113 AdvanceClockBy(base::TimeDelta::FromSeconds(2));
1116 PumpLoop(); 1114 PumpLoop();
1117 1115
1118 // Verify the request timed out. 1116 // Verify the request timed out.
1119 EXPECT_FALSE(coordinator()->is_busy());
1120 EXPECT_TRUE(OfflinerWasCanceled()); 1117 EXPECT_TRUE(OfflinerWasCanceled());
1121 EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_TIMED_OUT,
1122 last_offlining_status());
1123 } 1118 }
1124 1119
1125 TEST_F(RequestCoordinatorTest, TimeBudgetExceeded) { 1120 TEST_F(RequestCoordinatorTest, TimeBudgetExceeded) {
1126 // Build two requests to use with the pre-renderer, and put it on the queue. 1121 // Build two requests to use with the pre-renderer, and put it on the queue.
1127 offline_pages::SavePageRequest request1( 1122 offline_pages::SavePageRequest request1(
1128 kRequestId1, kUrl1, kClientId1, base::Time::Now(), kUserRequested); 1123 kRequestId1, kUrl1, kClientId1, base::Time::Now(), kUserRequested);
1129 offline_pages::SavePageRequest request2( 1124 offline_pages::SavePageRequest request2(
1130 kRequestId1 + 1, kUrl1, kClientId1, base::Time::Now(), kUserRequested); 1125 kRequestId1 + 1, kUrl1, kClientId1, base::Time::Now(), kUserRequested);
1131 request2.set_completed_attempt_count(kAttemptCount); 1126 request2.set_completed_attempt_count(kAttemptCount);
1132 coordinator()->queue()->AddRequest( 1127 coordinator()->queue()->AddRequest(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 // Now whether processing triggered immediately depends on whether test 1326 // Now whether processing triggered immediately depends on whether test
1332 // is run on svelte device or not. 1327 // is run on svelte device or not.
1333 if (base::SysInfo::IsLowEndDevice()) { 1328 if (base::SysInfo::IsLowEndDevice()) {
1334 EXPECT_FALSE(is_busy()); 1329 EXPECT_FALSE(is_busy());
1335 } else { 1330 } else {
1336 EXPECT_TRUE(is_busy()); 1331 EXPECT_TRUE(is_busy());
1337 } 1332 }
1338 } 1333 }
1339 1334
1340 } // namespace offline_pages 1335 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698