| 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/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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 void EnableOfflinerCallback(bool enable) { | 299 void EnableOfflinerCallback(bool enable) { |
| 300 offliner_->enable_callback(enable); | 300 offliner_->enable_callback(enable); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void SetNetworkConditionsForTest( | 303 void SetNetworkConditionsForTest( |
| 304 net::NetworkChangeNotifier::ConnectionType connection) { | 304 net::NetworkChangeNotifier::ConnectionType connection) { |
| 305 coordinator()->SetNetworkConditionsForTest(connection); | 305 coordinator()->SetNetworkConditionsForTest(connection); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void SetEffectiveConnectionTypeForTest(net::EffectiveConnectionType type) { |
| 309 network_quality_estimator_->SetEffectiveConnectionTypeForTest(type); |
| 310 } |
| 311 |
| 312 void SetNetworkConnected(bool connected) { |
| 313 if (connected) { |
| 314 SetNetworkConditionsForTest( |
| 315 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); |
| 316 SetEffectiveConnectionTypeForTest( |
| 317 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); |
| 318 } else { |
| 319 SetNetworkConditionsForTest( |
| 320 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE); |
| 321 SetEffectiveConnectionTypeForTest( |
| 322 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_OFFLINE); |
| 323 } |
| 324 } |
| 325 |
| 308 void SetIsLowEndDeviceForTest(bool is_low_end_device) { | 326 void SetIsLowEndDeviceForTest(bool is_low_end_device) { |
| 309 coordinator()->is_low_end_device_ = is_low_end_device; | 327 coordinator()->is_low_end_device_ = is_low_end_device; |
| 310 } | 328 } |
| 311 | 329 |
| 312 void SetProcessingStateForTest( | 330 void SetProcessingStateForTest( |
| 313 RequestCoordinator::ProcessingWindowState processing_state) { | 331 RequestCoordinator::ProcessingWindowState processing_state) { |
| 314 coordinator()->processing_state_ = processing_state; | 332 coordinator()->processing_state_ = processing_state; |
| 315 } | 333 } |
| 316 | 334 |
| 317 void SetOperationStartTimeForTest(base::Time start_time) { | 335 void SetOperationStartTimeForTest(base::Time start_time) { |
| 318 coordinator()->operation_start_time_ = start_time; | 336 coordinator()->operation_start_time_ = start_time; |
| 319 } | 337 } |
| 320 | 338 |
| 321 void SetEffectiveConnectionTypeForTest(net::EffectiveConnectionType type) { | |
| 322 network_quality_estimator_->SetEffectiveConnectionTypeForTest(type); | |
| 323 } | |
| 324 | |
| 325 void ScheduleForTest() { coordinator_->ScheduleAsNeeded(); } | 339 void ScheduleForTest() { coordinator_->ScheduleAsNeeded(); } |
| 326 | 340 |
| 327 void CallRequestNotPicked(bool non_user_requested_tasks_remaining, | 341 void CallRequestNotPicked(bool non_user_requested_tasks_remaining, |
| 328 bool disabled_tasks_remaining) { | 342 bool disabled_tasks_remaining) { |
| 329 if (disabled_tasks_remaining) | 343 if (disabled_tasks_remaining) |
| 330 coordinator_->disabled_requests_.insert(kRequestId1); | 344 coordinator_->disabled_requests_.insert(kRequestId1); |
| 331 else | 345 else |
| 332 coordinator_->disabled_requests_.clear(); | 346 coordinator_->disabled_requests_.clear(); |
| 333 | 347 |
| 334 coordinator_->RequestNotPicked(non_user_requested_tasks_remaining); | 348 coordinator_->RequestNotPicked(non_user_requested_tasks_remaining); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 reinterpret_cast<OfflinerStub*>(factory->GetOffliner(policy.get())); | 405 reinterpret_cast<OfflinerStub*>(factory->GetOffliner(policy.get())); |
| 392 std::unique_ptr<RequestQueueInMemoryStore> | 406 std::unique_ptr<RequestQueueInMemoryStore> |
| 393 store(new RequestQueueInMemoryStore()); | 407 store(new RequestQueueInMemoryStore()); |
| 394 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(store))); | 408 std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(store))); |
| 395 std::unique_ptr<Scheduler> scheduler_stub(new SchedulerStub()); | 409 std::unique_ptr<Scheduler> scheduler_stub(new SchedulerStub()); |
| 396 network_quality_estimator_.reset(new NetworkQualityEstimatorStub()); | 410 network_quality_estimator_.reset(new NetworkQualityEstimatorStub()); |
| 397 coordinator_.reset(new RequestCoordinator( | 411 coordinator_.reset(new RequestCoordinator( |
| 398 std::move(policy), std::move(factory), std::move(queue), | 412 std::move(policy), std::move(factory), std::move(queue), |
| 399 std::move(scheduler_stub), network_quality_estimator_.get())); | 413 std::move(scheduler_stub), network_quality_estimator_.get())); |
| 400 coordinator_->AddObserver(&observer_); | 414 coordinator_->AddObserver(&observer_); |
| 401 SetEffectiveConnectionTypeForTest( | 415 SetNetworkConnected(true); |
| 402 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_OFFLINE); | |
| 403 SetNetworkConditionsForTest( | |
| 404 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE); | |
| 405 } | 416 } |
| 406 | 417 |
| 407 void RequestCoordinatorTest::PumpLoop() { | 418 void RequestCoordinatorTest::PumpLoop() { |
| 408 task_runner_->RunUntilIdle(); | 419 task_runner_->RunUntilIdle(); |
| 409 } | 420 } |
| 410 | 421 |
| 411 void RequestCoordinatorTest::GetRequestsDone( | 422 void RequestCoordinatorTest::GetRequestsDone( |
| 412 RequestQueue::GetRequestsResult result, | 423 RequestQueue::GetRequestsResult result, |
| 413 std::vector<std::unique_ptr<SavePageRequest>> requests) { | 424 std::vector<std::unique_ptr<SavePageRequest>> requests) { |
| 414 last_get_requests_result_ = result; | 425 last_get_requests_result_ = result; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 513 |
| 503 // Now trying to start processing on another request should return false. | 514 // Now trying to start processing on another request should return false. |
| 504 EXPECT_FALSE(coordinator()->StartProcessing(device_conditions, callback)); | 515 EXPECT_FALSE(coordinator()->StartProcessing(device_conditions, callback)); |
| 505 } | 516 } |
| 506 | 517 |
| 507 TEST_F(RequestCoordinatorTest, SavePageLater) { | 518 TEST_F(RequestCoordinatorTest, SavePageLater) { |
| 508 // Set up device conditions for the test and enable the offliner. | 519 // Set up device conditions for the test and enable the offliner. |
| 509 DeviceConditions device_conditions(false, 75, | 520 DeviceConditions device_conditions(false, 75, |
| 510 net::NetworkChangeNotifier::CONNECTION_3G); | 521 net::NetworkChangeNotifier::CONNECTION_3G); |
| 511 SetDeviceConditionsForTest(device_conditions); | 522 SetDeviceConditionsForTest(device_conditions); |
| 512 // Set up the fake network conditions for the NetworkConnectionNotifier. | |
| 513 SetNetworkConditionsForTest( | |
| 514 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); | |
| 515 // Set up the fake network conditions for the network quality estimator. | |
| 516 SetEffectiveConnectionTypeForTest( | |
| 517 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); | |
| 518 EnableOfflinerCallback(true); | 523 EnableOfflinerCallback(true); |
| 519 base::Callback<void(bool)> callback = | 524 base::Callback<void(bool)> callback = |
| 520 base::Bind(&RequestCoordinatorTest::ImmediateScheduleCallbackFunction, | 525 base::Bind(&RequestCoordinatorTest::ImmediateScheduleCallbackFunction, |
| 521 base::Unretained(this)); | 526 base::Unretained(this)); |
| 522 | 527 |
| 523 // The user-requested request which gets processed by SavePageLater | 528 // The user-requested request which gets processed by SavePageLater |
| 524 // would invoke user request callback. | 529 // would invoke user request callback. |
| 525 coordinator()->SetImmediateScheduleCallbackForTest(callback); | 530 coordinator()->SetImmediateScheduleCallbackForTest(callback); |
| 526 | 531 |
| 527 EXPECT_NE( | 532 EXPECT_NE( |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 PumpLoop(); | 1094 PumpLoop(); |
| 1090 | 1095 |
| 1091 EXPECT_FALSE(is_starting()); | 1096 EXPECT_FALSE(is_starting()); |
| 1092 EXPECT_TRUE(OfflinerWasCanceled()); | 1097 EXPECT_TRUE(OfflinerWasCanceled()); |
| 1093 } | 1098 } |
| 1094 | 1099 |
| 1095 TEST_F(RequestCoordinatorTest, WatchdogTimeoutForImmediateProcessing) { | 1100 TEST_F(RequestCoordinatorTest, WatchdogTimeoutForImmediateProcessing) { |
| 1096 // If low end device, pretend it is not so that immediate start happens. | 1101 // If low end device, pretend it is not so that immediate start happens. |
| 1097 SetIsLowEndDeviceForTest(false); | 1102 SetIsLowEndDeviceForTest(false); |
| 1098 | 1103 |
| 1099 // Set up the fake network conditions for the NetworkConnectionNotifier. | |
| 1100 SetNetworkConditionsForTest( | |
| 1101 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); | |
| 1102 // Set up the fake network conditions for the network quality estimator. | |
| 1103 SetEffectiveConnectionTypeForTest( | |
| 1104 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); | |
| 1105 | |
| 1106 // Ensure that the new request does not finish - we simulate it being | 1104 // Ensure that the new request does not finish - we simulate it being |
| 1107 // in progress by asking it to skip making the completion callback. | 1105 // in progress by asking it to skip making the completion callback. |
| 1108 EnableOfflinerCallback(false); | 1106 EnableOfflinerCallback(false); |
| 1109 | 1107 |
| 1110 EXPECT_NE( | 1108 EXPECT_NE( |
| 1111 coordinator()->SavePageLater( | 1109 coordinator()->SavePageLater( |
| 1112 kUrl1, kClientId1, kUserRequested, | 1110 kUrl1, kClientId1, kUserRequested, |
| 1113 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); | 1111 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); |
| 1114 PumpLoop(); | 1112 PumpLoop(); |
| 1115 | 1113 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 // Verify the request gets removed from the queue, and wait for callbacks. | 1172 // Verify the request gets removed from the queue, and wait for callbacks. |
| 1175 coordinator()->queue()->GetRequests( | 1173 coordinator()->queue()->GetRequests( |
| 1176 base::Bind(&RequestCoordinatorTest::GetRequestsDone, | 1174 base::Bind(&RequestCoordinatorTest::GetRequestsDone, |
| 1177 base::Unretained(this))); | 1175 base::Unretained(this))); |
| 1178 PumpLoop(); | 1176 PumpLoop(); |
| 1179 | 1177 |
| 1180 // We should find one request in the queue. | 1178 // We should find one request in the queue. |
| 1181 EXPECT_EQ(1UL, last_requests().size()); | 1179 EXPECT_EQ(1UL, last_requests().size()); |
| 1182 } | 1180 } |
| 1183 | 1181 |
| 1182 TEST_F(RequestCoordinatorTest, TryNextRequestWithNoNetwork) { |
| 1183 // Build two requests to use with the pre-renderer, and put it on the queue. |
| 1184 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, |
| 1185 base::Time::Now(), kUserRequested); |
| 1186 offline_pages::SavePageRequest request2(kRequestId1 + 1, kUrl1, kClientId1, |
| 1187 base::Time::Now(), kUserRequested); |
| 1188 coordinator()->queue()->AddRequest( |
| 1189 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| 1190 base::Unretained(this))); |
| 1191 coordinator()->queue()->AddRequest( |
| 1192 request2, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| 1193 base::Unretained(this))); |
| 1194 PumpLoop(); |
| 1195 |
| 1196 // Set up for the call to StartProcessing. |
| 1197 DeviceConditions device_conditions(!kPowerRequired, kBatteryPercentageHigh, |
| 1198 net::NetworkChangeNotifier::CONNECTION_3G); |
| 1199 base::Callback<void(bool)> callback = base::Bind( |
| 1200 &RequestCoordinatorTest::WaitingCallbackFunction, base::Unretained(this)); |
| 1201 EnableOfflinerCallback(false); |
| 1202 |
| 1203 // Sending the request to the offliner. |
| 1204 EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback)); |
| 1205 PumpLoop(); |
| 1206 EXPECT_TRUE(coordinator()->is_busy()); |
| 1207 |
| 1208 // Now lose the network connection. |
| 1209 SetNetworkConnected(false); |
| 1210 |
| 1211 // Complete first request and then TryNextRequest should decide not |
| 1212 // to pick another request (because of no network connection). |
| 1213 SendOfflinerDoneCallback(request1, Offliner::RequestStatus::SAVED); |
| 1214 PumpLoop(); |
| 1215 |
| 1216 // Not starting nor busy with next request. |
| 1217 EXPECT_FALSE(coordinator()->is_starting()); |
| 1218 EXPECT_FALSE(coordinator()->is_busy()); |
| 1219 |
| 1220 // Get queued requests. |
| 1221 coordinator()->queue()->GetRequests(base::Bind( |
| 1222 &RequestCoordinatorTest::GetRequestsDone, base::Unretained(this))); |
| 1223 PumpLoop(); |
| 1224 |
| 1225 // We should find one request in the queue. |
| 1226 EXPECT_EQ(1UL, last_requests().size()); |
| 1227 } |
| 1228 |
| 1184 TEST_F(RequestCoordinatorTest, GetAllRequests) { | 1229 TEST_F(RequestCoordinatorTest, GetAllRequests) { |
| 1185 // Add two requests to the queue. | 1230 // Add two requests to the queue. |
| 1186 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, | 1231 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, |
| 1187 base::Time::Now(), kUserRequested); | 1232 base::Time::Now(), kUserRequested); |
| 1188 offline_pages::SavePageRequest request2(kRequestId1 + 1, kUrl2, kClientId2, | 1233 offline_pages::SavePageRequest request2(kRequestId1 + 1, kUrl2, kClientId2, |
| 1189 base::Time::Now(), kUserRequested); | 1234 base::Time::Now(), kUserRequested); |
| 1190 coordinator()->queue()->AddRequest( | 1235 coordinator()->queue()->AddRequest( |
| 1191 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, | 1236 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| 1192 base::Unretained(this))); | 1237 base::Unretained(this))); |
| 1193 coordinator()->queue()->AddRequest( | 1238 coordinator()->queue()->AddRequest( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 | 1306 |
| 1262 EXPECT_TRUE(observer().completed_called()); | 1307 EXPECT_TRUE(observer().completed_called()); |
| 1263 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::REMOVED, | 1308 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::REMOVED, |
| 1264 observer().last_status()); | 1309 observer().last_status()); |
| 1265 EXPECT_EQ(1UL, last_remove_results().size()); | 1310 EXPECT_EQ(1UL, last_remove_results().size()); |
| 1266 EXPECT_EQ(kRequestId1, std::get<0>(last_remove_results().at(0))); | 1311 EXPECT_EQ(kRequestId1, std::get<0>(last_remove_results().at(0))); |
| 1267 } | 1312 } |
| 1268 | 1313 |
| 1269 TEST_F(RequestCoordinatorTest, | 1314 TEST_F(RequestCoordinatorTest, |
| 1270 SavePageStartsProcessingWhenConnectedAndNotLowEndDevice) { | 1315 SavePageStartsProcessingWhenConnectedAndNotLowEndDevice) { |
| 1271 // Set up the fake network conditions for the NetworkConnectionNotifier. | |
| 1272 SetNetworkConditionsForTest( | |
| 1273 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); | |
| 1274 // Set up the fake network conditions for the network quality estimator. | |
| 1275 SetEffectiveConnectionTypeForTest( | |
| 1276 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); | |
| 1277 EXPECT_NE( | 1316 EXPECT_NE( |
| 1278 coordinator()->SavePageLater( | 1317 coordinator()->SavePageLater( |
| 1279 kUrl1, kClientId1, kUserRequested, | 1318 kUrl1, kClientId1, kUserRequested, |
| 1280 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); | 1319 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); |
| 1281 PumpLoop(); | 1320 PumpLoop(); |
| 1282 | 1321 |
| 1283 // Now whether processing triggered immediately depends on whether test | 1322 // Now whether processing triggered immediately depends on whether test |
| 1284 // is run on svelte device or not. | 1323 // is run on svelte device or not. |
| 1285 if (base::SysInfo::IsLowEndDevice()) { | 1324 if (base::SysInfo::IsLowEndDevice()) { |
| 1286 EXPECT_FALSE(is_busy()); | 1325 EXPECT_FALSE(is_busy()); |
| 1287 } else { | 1326 } else { |
| 1288 EXPECT_TRUE(is_busy()); | 1327 EXPECT_TRUE(is_busy()); |
| 1289 } | 1328 } |
| 1290 } | 1329 } |
| 1291 | 1330 |
| 1292 TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) { | 1331 TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) { |
| 1332 SetNetworkConnected(false); |
| 1293 EXPECT_NE( | 1333 EXPECT_NE( |
| 1294 coordinator()->SavePageLater( | 1334 coordinator()->SavePageLater( |
| 1295 kUrl1, kClientId1, kUserRequested, | 1335 kUrl1, kClientId1, kUserRequested, |
| 1296 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); | 1336 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); |
| 1297 PumpLoop(); | 1337 PumpLoop(); |
| 1298 EXPECT_FALSE(is_busy()); | 1338 EXPECT_FALSE(is_busy()); |
| 1299 } | 1339 } |
| 1300 | 1340 |
| 1301 TEST_F(RequestCoordinatorTest, | 1341 TEST_F(RequestCoordinatorTest, |
| 1302 SavePageDoesntStartProcessingWhenPoorlyConnected) { | 1342 SavePageDoesStartProcessingWhenPoorlyConnected) { |
| 1343 // Set specific network type for 2G with poor effective connection. |
| 1344 SetNetworkConditionsForTest( |
| 1345 net::NetworkChangeNotifier::ConnectionType::CONNECTION_2G); |
| 1303 SetEffectiveConnectionTypeForTest( | 1346 SetEffectiveConnectionTypeForTest( |
| 1304 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); | 1347 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); |
| 1305 EXPECT_NE( | 1348 EXPECT_NE( |
| 1306 coordinator()->SavePageLater( | 1349 coordinator()->SavePageLater( |
| 1307 kUrl1, kClientId1, kUserRequested, | 1350 kUrl1, kClientId1, kUserRequested, |
| 1308 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); | 1351 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); |
| 1309 PumpLoop(); | 1352 PumpLoop(); |
| 1310 EXPECT_FALSE(is_busy()); | 1353 EXPECT_TRUE(is_busy()); |
| 1311 } | 1354 } |
| 1312 | 1355 |
| 1313 TEST_F(RequestCoordinatorTest, | 1356 TEST_F(RequestCoordinatorTest, |
| 1314 ResumeStartsProcessingWhenConnectedAndNotLowEndDevice) { | 1357 ResumeStartsProcessingWhenConnectedAndNotLowEndDevice) { |
| 1358 // Start unconnected. |
| 1359 SetNetworkConnected(false); |
| 1360 |
| 1315 // Add a request to the queue. | 1361 // Add a request to the queue. |
| 1316 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, | 1362 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, |
| 1317 base::Time::Now(), kUserRequested); | 1363 base::Time::Now(), kUserRequested); |
| 1318 coordinator()->queue()->AddRequest( | 1364 coordinator()->queue()->AddRequest( |
| 1319 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, | 1365 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, |
| 1320 base::Unretained(this))); | 1366 base::Unretained(this))); |
| 1321 PumpLoop(); | 1367 PumpLoop(); |
| 1322 EXPECT_FALSE(is_busy()); | 1368 EXPECT_FALSE(is_busy()); |
| 1323 | 1369 |
| 1324 // Pause the request. | 1370 // Pause the request. |
| 1325 std::vector<int64_t> request_ids; | 1371 std::vector<int64_t> request_ids; |
| 1326 request_ids.push_back(kRequestId1); | 1372 request_ids.push_back(kRequestId1); |
| 1327 coordinator()->PauseRequests(request_ids); | 1373 coordinator()->PauseRequests(request_ids); |
| 1328 PumpLoop(); | 1374 PumpLoop(); |
| 1329 | 1375 |
| 1330 // Resume the request while disconnected. | 1376 // Resume the request while disconnected. |
| 1331 coordinator()->ResumeRequests(request_ids); | 1377 coordinator()->ResumeRequests(request_ids); |
| 1332 PumpLoop(); | 1378 PumpLoop(); |
| 1333 EXPECT_FALSE(is_busy()); | 1379 EXPECT_FALSE(is_busy()); |
| 1334 | 1380 |
| 1335 // Pause the request again. | 1381 // Pause the request again. |
| 1336 coordinator()->PauseRequests(request_ids); | 1382 coordinator()->PauseRequests(request_ids); |
| 1337 PumpLoop(); | 1383 PumpLoop(); |
| 1338 | 1384 |
| 1339 // Now simulate reasonable connection. | 1385 // Now simulate reasonable connection. |
| 1340 SetNetworkConditionsForTest( | 1386 SetNetworkConnected(true); |
| 1341 net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G); | |
| 1342 SetEffectiveConnectionTypeForTest( | |
| 1343 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G); | |
| 1344 | 1387 |
| 1345 // Resume the request while connected. | 1388 // Resume the request while connected. |
| 1346 coordinator()->ResumeRequests(request_ids); | 1389 coordinator()->ResumeRequests(request_ids); |
| 1347 EXPECT_FALSE(is_busy()); | 1390 EXPECT_FALSE(is_busy()); |
| 1348 PumpLoop(); | 1391 PumpLoop(); |
| 1349 | 1392 |
| 1350 // Now whether processing triggered immediately depends on whether test | 1393 // Now whether processing triggered immediately depends on whether test |
| 1351 // is run on svelte device or not. | 1394 // is run on svelte device or not. |
| 1352 if (base::SysInfo::IsLowEndDevice()) { | 1395 if (base::SysInfo::IsLowEndDevice()) { |
| 1353 EXPECT_FALSE(is_busy()); | 1396 EXPECT_FALSE(is_busy()); |
| 1354 } else { | 1397 } else { |
| 1355 EXPECT_TRUE(is_busy()); | 1398 EXPECT_TRUE(is_busy()); |
| 1356 } | 1399 } |
| 1357 } | 1400 } |
| 1358 | 1401 |
| 1359 } // namespace offline_pages | 1402 } // namespace offline_pages |
| OLD | NEW |