Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: components/offline_pages/core/snapshot_controller_unittest.cc

Issue 2655273003: Adds a first integration test for the Recent Tabs feature. (Closed)
Patch Set: Fix wrapping of comment text. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Onload should make snapshot after its delay. 77 // Onload should make snapshot after its delay.
78 controller()->DocumentOnLoadCompletedInMainFrame(); 78 controller()->DocumentOnLoadCompletedInMainFrame();
79 PumpLoop(); 79 PumpLoop();
80 EXPECT_EQ(0, snapshot_count()); 80 EXPECT_EQ(0, snapshot_count());
81 FastForwardBy(base::TimeDelta::FromMilliseconds( 81 FastForwardBy(base::TimeDelta::FromMilliseconds(
82 controller()->GetDelayAfterDocumentOnLoadCompletedForTest())); 82 controller()->GetDelayAfterDocumentOnLoadCompletedForTest()));
83 EXPECT_EQ(1, snapshot_count()); 83 EXPECT_EQ(1, snapshot_count());
84 } 84 }
85 85
86 TEST_F(SnapshotControllerTest, OnDocumentAvailable) { 86 TEST_F(SnapshotControllerTest, OnDocumentAvailable) {
87 EXPECT_GT(controller()->GetDelayAfterDocumentAvailableForTest(), 0UL); 87 EXPECT_GT(controller()->GetDelayAfterDocumentAvailableForTest(), 0LL);
88 // OnDOM should make snapshot after a delay. 88 // OnDOM should make snapshot after a delay.
89 controller()->DocumentAvailableInMainFrame(); 89 controller()->DocumentAvailableInMainFrame();
90 PumpLoop(); 90 PumpLoop();
91 EXPECT_EQ(0, snapshot_count()); 91 EXPECT_EQ(0, snapshot_count());
92 FastForwardBy(base::TimeDelta::FromMilliseconds( 92 FastForwardBy(base::TimeDelta::FromMilliseconds(
93 controller()->GetDelayAfterDocumentAvailableForTest())); 93 controller()->GetDelayAfterDocumentAvailableForTest()));
94 EXPECT_EQ(1, snapshot_count()); 94 EXPECT_EQ(1, snapshot_count());
95 } 95 }
96 96
97 TEST_F(SnapshotControllerTest, OnLoadSnapshotIsTheLastOne) { 97 TEST_F(SnapshotControllerTest, OnLoadSnapshotIsTheLastOne) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 controller()->PendingSnapshotCompleted(); 181 controller()->PendingSnapshotCompleted();
182 // Next snapshot should be initiated when new document is loaded. 182 // Next snapshot should be initiated when new document is loaded.
183 controller()->DocumentAvailableInMainFrame(); 183 controller()->DocumentAvailableInMainFrame();
184 FastForwardBy(base::TimeDelta::FromMilliseconds( 184 FastForwardBy(base::TimeDelta::FromMilliseconds(
185 controller()->GetDelayAfterDocumentAvailableForTest())); 185 controller()->GetDelayAfterDocumentAvailableForTest()));
186 // No snapshot since session was reset. 186 // No snapshot since session was reset.
187 EXPECT_EQ(2, snapshot_count()); 187 EXPECT_EQ(2, snapshot_count());
188 } 188 }
189 189
190 } // namespace offline_pages 190 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698