| 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/snapshot_controller.h" | 5 #include "components/offline_pages/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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 EXPECT_EQ(1, snapshot_count()); | 154 EXPECT_EQ(1, snapshot_count()); |
| 155 | 155 |
| 156 controller()->Reset(); | 156 controller()->Reset(); |
| 157 controller()->DocumentAvailableInMainFrame(); | 157 controller()->DocumentAvailableInMainFrame(); |
| 158 FastForwardBy(base::TimeDelta::FromMilliseconds( | 158 FastForwardBy(base::TimeDelta::FromMilliseconds( |
| 159 controller()->GetDelayAfterDocumentAvailableForTest())); | 159 controller()->GetDelayAfterDocumentAvailableForTest())); |
| 160 // No snapshot since session was reset. | 160 // No snapshot since session was reset. |
| 161 EXPECT_EQ(2, snapshot_count()); | 161 EXPECT_EQ(2, snapshot_count()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // This simulated a Reset while there is ongoing snapshot, which is reported |
| 165 // as done later. That reporting should have no effect nor crash. |
| 166 TEST_F(SnapshotControllerTest, ClientResetWhileSnapshotting) { |
| 167 controller()->DocumentOnLoadCompletedInMainFrame(); |
| 168 EXPECT_EQ(1, snapshot_count()); |
| 169 // This normally happens when navigation starts. |
| 170 controller()->Reset(); |
| 171 controller()->PendingSnapshotCompleted(); |
| 172 // Next snapshot should be initiated when new document is loaded. |
| 173 controller()->DocumentAvailableInMainFrame(); |
| 174 FastForwardBy(base::TimeDelta::FromMilliseconds( |
| 175 controller()->GetDelayAfterDocumentAvailableForTest())); |
| 176 // No snapshot since session was reset. |
| 177 EXPECT_EQ(2, snapshot_count()); |
| 178 } |
| 179 |
| 164 } // namespace offline_pages | 180 } // namespace offline_pages |
| OLD | NEW |