| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // Check the request queue is as expected. | 368 // Check the request queue is as expected. |
| 369 EXPECT_EQ(1UL, last_requests().size()); | 369 EXPECT_EQ(1UL, last_requests().size()); |
| 370 EXPECT_EQ(kUrl1, last_requests()[0].url()); | 370 EXPECT_EQ(kUrl1, last_requests()[0].url()); |
| 371 EXPECT_EQ(kClientId1, last_requests()[0].client_id()); | 371 EXPECT_EQ(kClientId1, last_requests()[0].client_id()); |
| 372 | 372 |
| 373 // Expect that the scheduler got notified. | 373 // Expect that the scheduler got notified. |
| 374 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( | 374 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( |
| 375 coordinator()->scheduler()); | 375 coordinator()->scheduler()); |
| 376 EXPECT_TRUE(scheduler_stub->schedule_called()); | 376 EXPECT_TRUE(scheduler_stub->schedule_called()); |
| 377 EXPECT_EQ(coordinator() | 377 EXPECT_EQ(coordinator() |
| 378 ->GetTriggerConditionsForUserRequest() | 378 ->GetTriggerConditions(last_requests()[0].user_requested()) |
| 379 .minimum_battery_percentage, | 379 .minimum_battery_percentage, |
| 380 scheduler_stub->conditions()->minimum_battery_percentage); | 380 scheduler_stub->conditions()->minimum_battery_percentage); |
| 381 | 381 |
| 382 // Check that the observer got the notification that a page is available | 382 // Check that the observer got the notification that a page is available |
| 383 EXPECT_TRUE(observer().added_called()); | 383 EXPECT_TRUE(observer().added_called()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) { | 386 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) { |
| 387 // Add a request to the queue, wait for callbacks to finish. | 387 // Add a request to the queue, wait for callbacks to finish. |
| 388 offline_pages::SavePageRequest request( | 388 offline_pages::SavePageRequest request( |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 request_ids.push_back(kRequestId1); | 769 request_ids.push_back(kRequestId1); |
| 770 coordinator()->RemoveRequests(request_ids); | 770 coordinator()->RemoveRequests(request_ids); |
| 771 PumpLoop(); | 771 PumpLoop(); |
| 772 | 772 |
| 773 EXPECT_TRUE(observer().completed_called()); | 773 EXPECT_TRUE(observer().completed_called()); |
| 774 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED, | 774 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED, |
| 775 observer().last_status()); | 775 observer().last_status()); |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace offline_pages | 778 } // namespace offline_pages |
| OLD | NEW |