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

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

Issue 2824623002: Last_n: Delete previously saved snapshot when navigating. (Closed)
Patch Set: Annotated method with @MainThread; comment updates Created 3 years, 8 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 7f97d15f115362267b22a11fe9b614dec5c8e899..3e4c5355be6ac98bfb05b4a9732bb96f75866ea8 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
@@ -375,8 +375,8 @@ TEST_F(RecentTabHelperTest, LastNDisabledOnSvelte) {
ASSERT_EQ(1U, GetAllPages().size());
}
-// Checks that last_n will not save a snapshot if the tab while the tab is
-// presented as a custom tab. Download requests should be unaffected though.
+// Checks that last_n will not save a snapshot while the tab is being presented
+// as a custom tab. Download requests should be unaffected though.
TEST_F(RecentTabHelperTest, LastNWontSaveCustomTab) {
// Simulates the tab running as a custom tab.
default_test_delegate()->set_is_custom_tab(true);
@@ -500,15 +500,16 @@ TEST_F(RecentTabHelperTest, TwoCapturesDifferentPageLoadsSameUrl) {
EXPECT_EQ(kTestPageUrl, GetAllPages()[0].url);
int64_t first_offline_id = GetAllPages()[0].offline_id;
- // Navigate with the same URL until the page is minimally loaded then hide the
- // tab. The previous snapshot should be removed and a new one taken.
+ // Reload the same URL until the page is minimally loaded. The previous
+ // snapshot should have been removed.
NavigateAndCommitTyped(kTestPageUrl);
recent_tab_helper()->DocumentAvailableInMainFrame();
FastForwardSnapshotController();
EXPECT_EQ(1U, page_added_count());
- EXPECT_EQ(0U, model_removed_count());
- ASSERT_EQ(1U, GetAllPages().size());
+ EXPECT_EQ(1U, model_removed_count());
+ ASSERT_EQ(0U, GetAllPages().size());
+ // Hide the tab and a new snapshot should be taken.
recent_tab_helper()->WasHidden();
RunUntilIdle();
EXPECT_EQ(2U, page_added_count());
@@ -565,15 +566,15 @@ TEST_F(RecentTabHelperTest, TwoCapturesDifferentPageLoadsDifferentUrls) {
ASSERT_EQ(1U, GetAllPages().size());
EXPECT_EQ(kTestPageUrl, GetAllPages()[0].url);
- // Fully load the second URL then hide the tab and check for a single snapshot
- // of the new page.
+ // Fully load the second URL. The previous snapshot should have been deleted.
NavigateAndCommitTyped(kTestPageUrlOther);
recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
FastForwardSnapshotController();
EXPECT_EQ(1U, page_added_count());
- EXPECT_EQ(0U, model_removed_count());
- ASSERT_EQ(1U, GetAllPages().size());
+ EXPECT_EQ(1U, model_removed_count());
+ ASSERT_EQ(0U, GetAllPages().size());
+ // Then hide the tab and check for a single snapshot of the new page.
recent_tab_helper()->WasHidden();
RunUntilIdle();
EXPECT_EQ(2U, page_added_count());
@@ -731,7 +732,7 @@ TEST_F(RecentTabHelperTest, DownloadRequestLaterInLoad) {
}
// Simulates a download request to offline the current page made after loading
-// is completed. Should end up with one offline pages.
+// is completed. Should end up with one offline page.
TEST_F(RecentTabHelperTest, DownloadRequestAfterFullyLoad) {
NavigateAndCommit(kTestPageUrl);
recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
@@ -897,7 +898,8 @@ TEST_F(RecentTabHelperTest, ReloadIsTrackedAsNavigationAndSavedOnlyUponLoad) {
RunUntilIdle();
ASSERT_EQ(1U, GetAllPages().size());
- // Starts a reload and hides the tab. No new snapshot should be saved.
+ // Starts a reload and hides the tab before it minimally load. The previous
+ // snapshot should be removed.
controller().Reload(content::ReloadType::NORMAL, false);
content::WebContentsTester* web_contents_tester =
content::WebContentsTester::For(web_contents());
@@ -905,8 +907,8 @@ TEST_F(RecentTabHelperTest, ReloadIsTrackedAsNavigationAndSavedOnlyUponLoad) {
recent_tab_helper()->WasHidden();
RunUntilIdle();
EXPECT_EQ(1U, page_added_count());
- EXPECT_EQ(0U, model_removed_count());
- ASSERT_EQ(1U, GetAllPages().size());
+ EXPECT_EQ(1U, model_removed_count());
+ ASSERT_EQ(0U, GetAllPages().size());
// Finish loading and hide the tab. A new snapshot should be created.
recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
« 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