| 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/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const bool kUserRequested = true; | 33 const bool kUserRequested = true; |
| 34 | 34 |
| 35 // Mock OfflinePageModel for testing the SavePage calls | 35 // Mock OfflinePageModel for testing the SavePage calls |
| 36 class MockOfflinePageModel : public StubOfflinePageModel { | 36 class MockOfflinePageModel : public StubOfflinePageModel { |
| 37 public: | 37 public: |
| 38 MockOfflinePageModel() : mock_saving_(false) {} | 38 MockOfflinePageModel() : mock_saving_(false) {} |
| 39 ~MockOfflinePageModel() override {} | 39 ~MockOfflinePageModel() override {} |
| 40 | 40 |
| 41 void SavePage(const SavePageParams& save_page_params, | 41 void SavePage(const SavePageParams& save_page_params, |
| 42 std::unique_ptr<OfflinePageArchiver> archiver, | 42 std::unique_ptr<OfflinePageArchiver> archiver, |
| 43 const std::vector<std::string>& signal_data, |
| 43 const SavePageCallback& callback) override { | 44 const SavePageCallback& callback) override { |
| 44 mock_saving_ = true; | 45 mock_saving_ = true; |
| 45 save_page_callback_ = callback; | 46 save_page_callback_ = callback; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void CompleteSavingAsArchiveCreationFailed() { | 49 void CompleteSavingAsArchiveCreationFailed() { |
| 49 DCHECK(mock_saving_); | 50 DCHECK(mock_saving_); |
| 50 mock_saving_ = false; | 51 mock_saving_ = false; |
| 51 base::ThreadTaskRunnerHandle::Get()->PostTask( | 52 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 52 FROM_HERE, base::Bind(save_page_callback_, | 53 FROM_HERE, base::Bind(save_page_callback_, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, | 335 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, |
| 335 kUserRequested); | 336 kUserRequested); |
| 336 EXPECT_TRUE(offliner()->LoadAndSave(request, callback())); | 337 EXPECT_TRUE(offliner()->LoadAndSave(request, callback())); |
| 337 offliner()->WebContentsDestroyed(); | 338 offliner()->WebContentsDestroyed(); |
| 338 | 339 |
| 339 EXPECT_TRUE(completion_callback_called()); | 340 EXPECT_TRUE(completion_callback_called()); |
| 340 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status()); | 341 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status()); |
| 341 } | 342 } |
| 342 | 343 |
| 343 } // namespace offline_pages | 344 } // namespace offline_pages |
| OLD | NEW |