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

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: Rebase after base change landed. 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
« no previous file with comments | « chrome/browser/android/offline_pages/recent_tab_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c9626478f5cdfd0a4854ed755e20cc60122392c0..507bd801d594a705ca970ea5667d0079f50ab16d 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
@@ -887,4 +887,31 @@ TEST_F(RecentTabHelperTest, ReloadIsTrackedAsNavigationAndSavedOnlyUponLoad) {
ASSERT_EQ(1U, GetAllPages().size());
}
+// 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
« no previous file with comments | « chrome/browser/android/offline_pages/recent_tab_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698