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

Side by Side 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, 9 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
« no previous file with comments | « chrome/browser/android/offline_pages/recent_tab_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/android/offline_pages/recent_tab_helper.h" 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 // Finish loading and hide the tab. A new snapshot should be created. 880 // Finish loading and hide the tab. A new snapshot should be created.
881 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame(); 881 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
882 FastForwardSnapshotController(); 882 FastForwardSnapshotController();
883 recent_tab_helper()->WasHidden(); 883 recent_tab_helper()->WasHidden();
884 RunUntilIdle(); 884 RunUntilIdle();
885 EXPECT_EQ(2U, page_added_count()); 885 EXPECT_EQ(2U, page_added_count());
886 EXPECT_EQ(1U, model_removed_count()); 886 EXPECT_EQ(1U, model_removed_count());
887 ASSERT_EQ(1U, GetAllPages().size()); 887 ASSERT_EQ(1U, GetAllPages().size());
888 } 888 }
889 889
890 // Checks that a closing tab doesn't trigger the creation of a snapshot. And
891 // also that if the closure is reverted, a snapshot is saved upon the next hide
892 // event.
893 TEST_F(RecentTabHelperTest, NoSaveIfTabIsClosing) {
894 // Navigates and fully load then close and hide the tab. No snapshots are
895 // expected.
896 NavigateAndCommit(kTestPageUrl);
897 recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
898 FastForwardSnapshotController();
899 // Note: These two next calls are always expected to happen in this order.
900 recent_tab_helper()->WillCloseTab();
901 recent_tab_helper()->WasHidden();
902 RunUntilIdle();
903 EXPECT_EQ(0U, page_added_count());
904 EXPECT_EQ(0U, model_removed_count());
905 ASSERT_EQ(0U, GetAllPages().size());
906
907 // Simulates the page being restored and shown again, then hidden. At this
908 // moment a snapshot should be created.
909 recent_tab_helper()->WasShown();
910 recent_tab_helper()->WasHidden();
911 RunUntilIdle();
912 EXPECT_EQ(1U, page_added_count());
913 EXPECT_EQ(0U, model_removed_count());
914 ASSERT_EQ(1U, GetAllPages().size());
915 }
916
890 } // namespace offline_pages 917 } // namespace offline_pages
OLDNEW
« 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