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