| 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
|
|
|