| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 std::unique_ptr<OfflinePageArchiver> archiver, | 45 std::unique_ptr<OfflinePageArchiver> archiver, |
| 46 const SavePageCallback& callback) override { | 46 const SavePageCallback& callback) override { |
| 47 mock_saving_ = true; | 47 mock_saving_ = true; |
| 48 save_page_callback_ = callback; | 48 save_page_callback_ = callback; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CompleteSavingAsArchiveCreationFailed() { | 51 void CompleteSavingAsArchiveCreationFailed() { |
| 52 DCHECK(mock_saving_); | 52 DCHECK(mock_saving_); |
| 53 mock_saving_ = false; | 53 mock_saving_ = false; |
| 54 base::ThreadTaskRunnerHandle::Get()->PostTask( | 54 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 55 FROM_HERE, base::Bind(save_page_callback_, | 55 FROM_HERE, |
| 56 SavePageResult::ARCHIVE_CREATION_FAILED, 0)); | 56 base::Bind(save_page_callback_, SavePageResult::ARCHIVE_CREATION_FAILED, |
| 57 0, base::FilePath())); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void CompleteSavingAsSuccess() { | 60 void CompleteSavingAsSuccess() { |
| 60 DCHECK(mock_saving_); | 61 DCHECK(mock_saving_); |
| 61 mock_saving_ = false; | 62 mock_saving_ = false; |
| 62 base::ThreadTaskRunnerHandle::Get()->PostTask( | 63 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 63 FROM_HERE, | 64 FROM_HERE, base::Bind(save_page_callback_, SavePageResult::SUCCESS, |
| 64 base::Bind(save_page_callback_, SavePageResult::SUCCESS, 123456)); | 65 123456, base::FilePath())); |
| 65 } | 66 } |
| 66 | 67 |
| 67 bool mock_saving() const { return mock_saving_; } | 68 bool mock_saving() const { return mock_saving_; } |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 bool mock_saving_; | 71 bool mock_saving_; |
| 71 SavePageCallback save_page_callback_; | 72 SavePageCallback save_page_callback_; |
| 72 | 73 |
| 73 DISALLOW_COPY_AND_ASSIGN(MockOfflinePageModel); | 74 DISALLOW_COPY_AND_ASSIGN(MockOfflinePageModel); |
| 74 }; | 75 }; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // NavigationHandle is always destroyed after finishing navigation. | 363 // NavigationHandle is always destroyed after finishing navigation. |
| 363 handle.reset(); | 364 handle.reset(); |
| 364 offliner()->DidStopLoading(); | 365 offliner()->DidStopLoading(); |
| 365 PumpLoop(); | 366 PumpLoop(); |
| 366 | 367 |
| 367 EXPECT_TRUE(completion_callback_called()); | 368 EXPECT_TRUE(completion_callback_called()); |
| 368 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED_NO_RETRY, request_status()); | 369 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED_NO_RETRY, request_status()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace offline_pages | 372 } // namespace offline_pages |
| OLD | NEW |