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

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

Issue 2150103002: [Offline Pages] Allows offline redirection to offline pages with Aync Loading namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/offline_page_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/offline_page_tab_helper_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc b/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
index 2918b3803e73d48571bbcb212141a987ca65f113..919ddbff6b14278ddf244b520feefa599dd95dc7 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc
@@ -350,4 +350,36 @@ TEST_F(OfflinePageTabHelperTest, SelectBestPageForCurrentTab) {
EXPECT_EQ(kLastNNamespace, item->client_id.name_space);
EXPECT_EQ(kTabId, item->client_id.id);
}
+
+// This test saves another copy of page from Async Loading namespace
+// and verifies it is redirected to it (as it is more recent).
+TEST_F(OfflinePageTabHelperTest, SwitchToOfflineAsyncLoadedPageOnNoNetwork) {
+ // Saves an offline page.
+ OfflinePageModel* model =
+ OfflinePageModelFactory::GetForBrowserContext(browser_context());
+ std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
+ kTestPageUrl,
+ base::FilePath(FILE_PATH_LITERAL("AsyncLoadedPage.mhtml"))));
+
+ // We expect this Async Loading Namespace copy to be used.
+ ClientId client_id(kAsyncNamespace, kTabId);
+ model->SavePage(
+ kTestPageUrl, client_id, std::move(archiver),
+ base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr()));
+ RunUntilIdle();
+ const int64_t expected_offline_id = offline_id();
+ const GURL expected_offline_url = offline_url();
+
+ SimulateHasNetworkConnectivity(false);
+ StartLoad(kTestPageUrl);
+ // Gives a chance to run delayed task to do redirection.
+ RunUntilIdle();
+
+ const OfflinePageItem* item =
+ OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
+ EXPECT_EQ(expected_offline_id, item->offline_id);
+ EXPECT_EQ(expected_offline_url, item->GetOfflineURL());
+ EXPECT_EQ(kAsyncNamespace, item->client_id.name_space);
+}
+
} // namespace offline_pages
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_tab_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698