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

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

Issue 2713993002: RecentTabHelper: adds DVLOG and reload unit test. (Closed)
Patch Set: 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 2df851de6503f5e2b91e08e9cd43761449a59dc8..c9626478f5cdfd0a4854ed755e20cc60122392c0 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
@@ -23,6 +23,7 @@
#include "components/offline_pages/core/offline_page_test_archiver.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/reload_type.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/referrer.h"
#include "content/public/test/web_contents_tester.h"
@@ -855,4 +856,35 @@ TEST_F(RecentTabHelperTest, SaveSamePageNavigationSnapshots) {
EXPECT_EQ(offline_id, downloads_page->offline_id);
}
+// Tests that a page reloaded is tracked as an actual load and properly saved.
+TEST_F(RecentTabHelperTest, ReloadIsTrackedAsNavigationAndSavedOnlyUponLoad) {
+ // Navigates and load fully then hide the tab so that a snapshot is created.
+ NavigateAndCommit(kTestPageUrl);
+ recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
+ FastForwardSnapshotController();
+ recent_tab_helper()->WasHidden();
+ RunUntilIdle();
+ ASSERT_EQ(1U, GetAllPages().size());
+
+ // Starts a reload and hides the tab. No new snapshot should be saved.
+ controller().Reload(content::ReloadType::NORMAL, false);
+ content::WebContentsTester* web_contents_tester =
+ content::WebContentsTester::For(web_contents());
+ web_contents_tester->CommitPendingNavigation();
+ recent_tab_helper()->WasHidden();
+ RunUntilIdle();
+ EXPECT_EQ(1U, page_added_count());
+ EXPECT_EQ(0U, model_removed_count());
+ ASSERT_EQ(1U, GetAllPages().size());
+
+ // Finish loading and hide the tab. A new snapshot should be created.
+ recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
+ FastForwardSnapshotController();
+ recent_tab_helper()->WasHidden();
+ RunUntilIdle();
+ EXPECT_EQ(2U, page_added_count());
+ EXPECT_EQ(1U, 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