| 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 "chrome/browser/android/offline_pages/background_loader_offliner.h" | 5 #include "chrome/browser/android/offline_pages/background_loader_offliner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
| 10 #include "base/test/scoped_mock_time_message_loop_task_runner.h" | 10 #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 progress_(0LL), | 182 progress_(0LL), |
| 183 request_status_(Offliner::RequestStatus::UNKNOWN) {} | 183 request_status_(Offliner::RequestStatus::UNKNOWN) {} |
| 184 | 184 |
| 185 BackgroundLoaderOfflinerTest::~BackgroundLoaderOfflinerTest() {} | 185 BackgroundLoaderOfflinerTest::~BackgroundLoaderOfflinerTest() {} |
| 186 | 186 |
| 187 void BackgroundLoaderOfflinerTest::SetUp() { | 187 void BackgroundLoaderOfflinerTest::SetUp() { |
| 188 model_ = new MockOfflinePageModel(); | 188 model_ = new MockOfflinePageModel(); |
| 189 policy_.reset(new OfflinerPolicy()); | 189 policy_.reset(new OfflinerPolicy()); |
| 190 offliner_.reset( | 190 offliner_.reset( |
| 191 new TestBackgroundLoaderOffliner(profile(), policy_.get(), model_)); | 191 new TestBackgroundLoaderOffliner(profile(), policy_.get(), model_)); |
| 192 offliner_->SetPageDelayForTest(0L); | 192 offliner_->SetSnapshotControllerForTest(new SnapshotController( |
| 193 base::ThreadTaskRunnerHandle::Get(), offliner_.get(), |
| 194 0L /* DelayAfterDocumentAvailable */, 0L /* DelayAfterDocumentOnLoad */, |
| 195 false /* DocumentAvailableTriggersSnapshot */)); |
| 193 } | 196 } |
| 194 | 197 |
| 195 void BackgroundLoaderOfflinerTest::OnCompletion( | 198 void BackgroundLoaderOfflinerTest::OnCompletion( |
| 196 const SavePageRequest& request, | 199 const SavePageRequest& request, |
| 197 Offliner::RequestStatus status) { | 200 Offliner::RequestStatus status) { |
| 198 DCHECK(!completion_callback_called_); // Expect 1 callback per request. | 201 DCHECK(!completion_callback_called_); // Expect 1 callback per request. |
| 199 completion_callback_called_ = true; | 202 completion_callback_called_ = true; |
| 200 request_status_ = status; | 203 request_status_ = status; |
| 201 } | 204 } |
| 202 | 205 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), | 557 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), |
| 555 progress_callback())); | 558 progress_callback())); |
| 556 // Sets lowbar. | 559 // Sets lowbar. |
| 557 offliner()->DocumentAvailableInMainFrame(); | 560 offliner()->DocumentAvailableInMainFrame(); |
| 558 // Timeout | 561 // Timeout |
| 559 EXPECT_FALSE(offliner()->HandleTimeout(request)); | 562 EXPECT_FALSE(offliner()->HandleTimeout(request)); |
| 560 EXPECT_FALSE(SaveInProgress()); | 563 EXPECT_FALSE(SaveInProgress()); |
| 561 } | 564 } |
| 562 | 565 |
| 563 } // namespace offline_pages | 566 } // namespace offline_pages |
| OLD | NEW |