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

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

Issue 2503073002: [OfflinePages] Fix 2 RequestCoordinator tests for low end devices (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
« no previous file with comments | « no previous file | 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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 EXPECT_EQ(SavePageRequest::RequestState::PAUSED, observer().state()); 1304 EXPECT_EQ(SavePageRequest::RequestState::PAUSED, observer().state());
1305 1305
1306 // Clear out the observer before the next call. 1306 // Clear out the observer before the next call.
1307 observer().Clear(); 1307 observer().Clear();
1308 1308
1309 // Resume the request. 1309 // Resume the request.
1310 coordinator()->ResumeRequests(request_ids); 1310 coordinator()->ResumeRequests(request_ids);
1311 PumpLoop(); 1311 PumpLoop();
1312 1312
1313 EXPECT_TRUE(observer().changed_called()); 1313 EXPECT_TRUE(observer().changed_called());
1314 EXPECT_EQ(SavePageRequest::RequestState::OFFLINING, observer().state()); 1314
1315 // Now whether request is offlining or just available depends on whether test
1316 // is run on svelte device or not.
1317 if (base::SysInfo::IsLowEndDevice()) {
1318 EXPECT_EQ(SavePageRequest::RequestState::AVAILABLE, observer().state());
1319 } else {
1320 EXPECT_EQ(SavePageRequest::RequestState::OFFLINING, observer().state());
1321 }
1315 } 1322 }
1316 1323
1317 TEST_F(RequestCoordinatorTest, RemoveRequest) { 1324 TEST_F(RequestCoordinatorTest, RemoveRequest) {
1318 // Add a request to the queue. 1325 // Add a request to the queue.
1319 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, 1326 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1,
1320 base::Time::Now(), kUserRequested); 1327 base::Time::Now(), kUserRequested);
1321 coordinator()->queue()->AddRequest( 1328 coordinator()->queue()->AddRequest(
1322 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, 1329 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone,
1323 base::Unretained(this))); 1330 base::Unretained(this)));
1324 PumpLoop(); 1331 PumpLoop();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 EXPECT_NE( 1409 EXPECT_NE(
1403 coordinator()->SavePageLater( 1410 coordinator()->SavePageLater(
1404 kUrl1, kClientId1, kUserRequested, 1411 kUrl1, kClientId1, kUserRequested,
1405 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); 1412 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0);
1406 PumpLoop(); 1413 PumpLoop();
1407 EXPECT_FALSE(is_busy()); 1414 EXPECT_FALSE(is_busy());
1408 } 1415 }
1409 1416
1410 TEST_F(RequestCoordinatorTest, 1417 TEST_F(RequestCoordinatorTest,
1411 SavePageDoesStartProcessingWhenPoorlyConnected) { 1418 SavePageDoesStartProcessingWhenPoorlyConnected) {
1419 // If low end device, pretend it is not so that immediate start can happen.
1420 SetIsLowEndDeviceForTest(false);
1412 // Set specific network type for 2G with poor effective connection. 1421 // Set specific network type for 2G with poor effective connection.
1413 SetNetworkConditionsForTest( 1422 SetNetworkConditionsForTest(
1414 net::NetworkChangeNotifier::ConnectionType::CONNECTION_2G); 1423 net::NetworkChangeNotifier::ConnectionType::CONNECTION_2G);
1415 SetEffectiveConnectionTypeForTest( 1424 SetEffectiveConnectionTypeForTest(
1416 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); 1425 net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
1417 EXPECT_NE( 1426 EXPECT_NE(
1418 coordinator()->SavePageLater( 1427 coordinator()->SavePageLater(
1419 kUrl1, kClientId1, kUserRequested, 1428 kUrl1, kClientId1, kUserRequested,
1420 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0); 1429 RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER), 0);
1421 PumpLoop(); 1430 PumpLoop();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 // Now whether processing triggered immediately depends on whether test 1471 // Now whether processing triggered immediately depends on whether test
1463 // is run on svelte device or not. 1472 // is run on svelte device or not.
1464 if (base::SysInfo::IsLowEndDevice()) { 1473 if (base::SysInfo::IsLowEndDevice()) {
1465 EXPECT_FALSE(is_busy()); 1474 EXPECT_FALSE(is_busy());
1466 } else { 1475 } else {
1467 EXPECT_TRUE(is_busy()); 1476 EXPECT_TRUE(is_busy());
1468 } 1477 }
1469 } 1478 }
1470 1479
1471 } // namespace offline_pages 1480 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698