| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 base::Bind( | 147 base::Bind( |
| 148 &RequestCoordinatorTest::EmptyCallbackFunction, | 148 &RequestCoordinatorTest::EmptyCallbackFunction, |
| 149 base::Unretained(this)); | 149 base::Unretained(this)); |
| 150 EXPECT_FALSE(coordinator()->StartProcessing(callback)); | 150 EXPECT_FALSE(coordinator()->StartProcessing(callback)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 TEST_F(RequestCoordinatorTest, SavePageLater) { | 153 TEST_F(RequestCoordinatorTest, SavePageLater) { |
| 154 EXPECT_TRUE(coordinator()->SavePageLater(kUrl, kClientId)); | 154 EXPECT_TRUE(coordinator()->SavePageLater(kUrl, kClientId)); |
| 155 | 155 |
| 156 // Expect that a request got placed on the queue. | 156 // Expect that a request got placed on the queue. |
| 157 coordinator()->GetQueue()->GetRequests( | 157 coordinator()->queue()->GetRequests( |
| 158 base::Bind(&RequestCoordinatorTest::GetRequestsDone, | 158 base::Bind(&RequestCoordinatorTest::GetRequestsDone, |
| 159 base::Unretained(this))); | 159 base::Unretained(this))); |
| 160 | 160 |
| 161 // Wait for callbacks to finish, both request queue and offliner. | 161 // Wait for callbacks to finish, both request queue and offliner. |
| 162 PumpLoop(); | 162 PumpLoop(); |
| 163 | 163 |
| 164 // Check the request queue is as expected. | 164 // Check the request queue is as expected. |
| 165 EXPECT_EQ(1UL, last_requests().size()); | 165 EXPECT_EQ(1UL, last_requests().size()); |
| 166 EXPECT_EQ(kUrl, last_requests()[0].url()); | 166 EXPECT_EQ(kUrl, last_requests()[0].url()); |
| 167 EXPECT_EQ(kClientId, last_requests()[0].client_id()); | 167 EXPECT_EQ(kClientId, last_requests()[0].client_id()); |
| 168 | 168 |
| 169 // Expect that the scheduler got notified. | 169 // Expect that the scheduler got notified. |
| 170 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( | 170 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( |
| 171 coordinator()->GetSchedulerForTesting()); | 171 coordinator()->scheduler()); |
| 172 EXPECT_TRUE(scheduler_stub->schedule_called()); | 172 EXPECT_TRUE(scheduler_stub->schedule_called()); |
| 173 | 173 |
| 174 // Check that the offliner callback got a response. | 174 // Check that the offliner callback got a response. |
| 175 EXPECT_EQ(Offliner::SAVED, coordinator()->last_offlining_status()); | 175 EXPECT_EQ(Offliner::SAVED, coordinator()->last_offlining_status()); |
| 176 | 176 |
| 177 // TODO(petewil): Expect that the scheduler got notified. | 177 // TODO(petewil): Expect that the scheduler got notified. |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace offline_pages | 180 } // namespace offline_pages |
| OLD | NEW |