| 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/core/snapshot_controller.h" | 5 #include "components/offline_pages/core/snapshot_controller.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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/test/test_mock_time_task_runner.h" | 10 #include "base/test/test_mock_time_task_runner.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 SnapshotControllerTest::SnapshotControllerTest() | 48 SnapshotControllerTest::SnapshotControllerTest() |
| 49 : task_runner_(new base::TestMockTimeTaskRunner), | 49 : task_runner_(new base::TestMockTimeTaskRunner), |
| 50 snapshot_started_(true), | 50 snapshot_started_(true), |
| 51 snapshot_count_(0) {} | 51 snapshot_count_(0) {} |
| 52 | 52 |
| 53 SnapshotControllerTest::~SnapshotControllerTest() {} | 53 SnapshotControllerTest::~SnapshotControllerTest() {} |
| 54 | 54 |
| 55 void SnapshotControllerTest::SetUp() { | 55 void SnapshotControllerTest::SetUp() { |
| 56 controller_.reset(new SnapshotController(task_runner_, this)); | 56 controller_ = |
| 57 SnapshotController::CreateForForegroundOfflining(task_runner_, this); |
| 57 snapshot_started_ = true; | 58 snapshot_started_ = true; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void SnapshotControllerTest::TearDown() { | 61 void SnapshotControllerTest::TearDown() { |
| 61 controller_.reset(); | 62 controller_.reset(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void SnapshotControllerTest::StartSnapshot() { | 65 void SnapshotControllerTest::StartSnapshot() { |
| 65 snapshot_count_++; | 66 snapshot_count_++; |
| 66 } | 67 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 controller()->PendingSnapshotCompleted(); | 182 controller()->PendingSnapshotCompleted(); |
| 182 // Next snapshot should be initiated when new document is loaded. | 183 // Next snapshot should be initiated when new document is loaded. |
| 183 controller()->DocumentAvailableInMainFrame(); | 184 controller()->DocumentAvailableInMainFrame(); |
| 184 FastForwardBy(base::TimeDelta::FromMilliseconds( | 185 FastForwardBy(base::TimeDelta::FromMilliseconds( |
| 185 controller()->GetDelayAfterDocumentAvailableForTest())); | 186 controller()->GetDelayAfterDocumentAvailableForTest())); |
| 186 // No snapshot since session was reset. | 187 // No snapshot since session was reset. |
| 187 EXPECT_EQ(2, snapshot_count()); | 188 EXPECT_EQ(2, snapshot_count()); |
| 188 } | 189 } |
| 189 | 190 |
| 190 } // namespace offline_pages | 191 } // namespace offline_pages |
| OLD | NEW |