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

Unified Diff: components/offline_pages/snapshot_controller_unittest.cc

Issue 1936613002: Implementing recent pages snapshot capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clang is my friend Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/offline_pages/snapshot_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/snapshot_controller_unittest.cc
diff --git a/components/offline_pages/snapshot_controller_unittest.cc b/components/offline_pages/snapshot_controller_unittest.cc
index 2a455cf6f82a85020add61c547aa8920e6308076..d85ac7aeb959a70d7dc726fe94780d5e101adb35 100644
--- a/components/offline_pages/snapshot_controller_unittest.cc
+++ b/components/offline_pages/snapshot_controller_unittest.cc
@@ -22,7 +22,6 @@ class SnapshotControllerTest
~SnapshotControllerTest() override;
SnapshotController* controller() { return controller_.get(); }
- void set_snapshot_started(bool started) { snapshot_started_ = started; }
int snapshot_count() { return snapshot_count_; }
// testing::Test
@@ -30,7 +29,7 @@ class SnapshotControllerTest
void TearDown() override;
// SnapshotController::Client
- bool StartSnapshot() override;
+ void StartSnapshot() override;
// Utility methods.
// Runs until all of the tasks that are not delayed are gone from the task
@@ -65,9 +64,8 @@ void SnapshotControllerTest::TearDown() {
controller_.reset();
}
-bool SnapshotControllerTest::StartSnapshot() {
+void SnapshotControllerTest::StartSnapshot() {
snapshot_count_++;
- return snapshot_started_;
}
void SnapshotControllerTest::PumpLoop() {
@@ -144,16 +142,22 @@ TEST_F(SnapshotControllerTest, Stop) {
EXPECT_EQ(0, snapshot_count());
}
-TEST_F(SnapshotControllerTest, ClientDidntStartSnapshot) {
- // This will tell that Client did not start the snapshot
- set_snapshot_started(false);
+TEST_F(SnapshotControllerTest, ClientReset) {
controller()->DocumentAvailableInMainFrame();
+
+ controller()->Reset();
FastForwardBy(base::TimeDelta::FromMilliseconds(
controller()->GetDelayAfterDocumentAvailableForTest()));
- // Should have one snapshot requested, but not reported started.
- EXPECT_EQ(1, snapshot_count());
- // Should start another snapshot since previous did not start
+ // No snapshot since session was reset.
+ EXPECT_EQ(0, snapshot_count());
controller()->DocumentOnLoadCompletedInMainFrame();
+ EXPECT_EQ(1, snapshot_count());
+
+ controller()->Reset();
+ controller()->DocumentAvailableInMainFrame();
+ FastForwardBy(base::TimeDelta::FromMilliseconds(
+ controller()->GetDelayAfterDocumentAvailableForTest()));
+ // No snapshot since session was reset.
EXPECT_EQ(2, snapshot_count());
}
« no previous file with comments | « components/offline_pages/snapshot_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698