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

Unified Diff: chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc

Issue 2705323006: Last_n: Do not save a snapshot of a closing tab. (Closed)
Patch Set: Minor comment changes. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
diff --git a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
index 2df851de6503f5e2b91e08e9cd43761449a59dc8..13d1f95dec530bd78a89ee60ae667188e34fb964 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
@@ -855,4 +855,31 @@ TEST_F(RecentTabHelperTest, SaveSamePageNavigationSnapshots) {
EXPECT_EQ(offline_id, downloads_page->offline_id);
}
+// Checks that a closing tab doesn't trigger the creation of a snapshot. And
+// also that if the closure is reverted, a snapshot is saved upon the next hide
+// event.
+TEST_F(RecentTabHelperTest, NoSaveIfTabIsClosing) {
+ // Navigates and fully load then close and hide the tab. No snapshots are
+ // expected.
+ NavigateAndCommit(kTestPageUrl);
+ recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
+ FastForwardSnapshotController();
+ // Note: These two next calls are always expected to happen in this order.
+ recent_tab_helper()->WillCloseTab();
+ recent_tab_helper()->WasHidden();
+ RunUntilIdle();
+ EXPECT_EQ(0U, page_added_count());
+ EXPECT_EQ(0U, model_removed_count());
+ ASSERT_EQ(0U, GetAllPages().size());
+
+ // Simulates the page being restored and shown again, then hidden. At this
+ // moment a snapshot should be created.
+ recent_tab_helper()->WasShown();
+ recent_tab_helper()->WasHidden();
+ RunUntilIdle();
+ EXPECT_EQ(1U, page_added_count());
+ EXPECT_EQ(0U, model_removed_count());
+ ASSERT_EQ(1U, GetAllPages().size());
+}
+
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698