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

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

Issue 2284933002: Remove OfflineURL from offline page (Closed)
Patch Set: Add comment per feedback Created 4 years, 2 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_utils.cc ('k') | chrome/browser/android/tab_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
index 2955b62cbe330a2ab8a23a8a3c649b559c43b1ca..68e52f24631f2391ce4596497428a1440ab4391a 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
@@ -64,15 +64,6 @@ class OfflinePageUtilsTest
// OfflinePageTestArchiver::Observer implementation:
void SetLastPathCreatedByArchiver(const base::FilePath& file_path) override;
- // Offline page URL for the first page.
- const GURL& offline_url_page_1() const { return offline_url_page_1_; }
- // Offline page URL for the second page.
- const GURL& offline_url_page_2() const { return offline_url_page_2_; }
- // Offline page URL not related to any page.
- const GURL& offline_url_missing() const { return offline_url_missing_; }
- // Offline page URL for expired page.
- const GURL& offline_url_expired() const { return offline_url_expired_; }
-
TestingProfile* profile() { return &profile_; }
int64_t offline_id() const { return offline_id_; }
@@ -83,11 +74,6 @@ class OfflinePageUtilsTest
const GURL& url,
const base::FilePath& file_name);
- GURL offline_url_page_1_;
- GURL offline_url_page_2_;
- GURL offline_url_missing_;
- GURL offline_url_expired_;
-
int64_t offline_id_;
GURL url_;
@@ -159,8 +145,6 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
kTestPage1Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
- offline_url_page_1_ =
- model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL();
// Create page 2.
archiver = BuildArchiver(kTestPage2Url,
@@ -170,16 +154,6 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
kTestPage2Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
- offline_url_page_2_ =
- model->MaybeGetPageByOfflineId(offline_id())->GetOfflineURL();
-
- // Page 3 is not created, as it is missing.
- // Create a file path that is not associated with any offline page.
- offline_url_missing_ = net::FilePathToFileURL(
- profile()
- ->GetPath()
- .Append(chrome::kOfflinePageArchivesDirname)
- .Append(FILE_PATH_LITERAL("missing_file.mhtml")));
// Create page 4 - expired page.
archiver = BuildArchiver(kTestPage4Url,
@@ -189,8 +163,6 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
kTestPage4Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
RunUntilIdle();
- const OfflinePageItem* page_4 = model->MaybeGetPageByOfflineId(offline_id());
- offline_url_expired_ = page_4->GetOfflineURL();
model->ExpirePages(
std::vector<int64_t>({offline_id()}), base::Time::Now(),
base::Bind(&OfflinePageUtilsTest::OnExpirePageDone, AsWeakPtr()));
@@ -207,38 +179,4 @@ std::unique_ptr<OfflinePageTestArchiver> OfflinePageUtilsTest::BuildArchiver(
return archiver;
}
-TEST_F(OfflinePageUtilsTest, MightBeOfflineURL) {
- // URL is invalid.
- EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("/test.mhtml")));
- // Scheme is not file.
- EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("http://test.com/")));
- // Does not end with .mhtml.
- EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.txt")));
- // Might still be an offline page.
- EXPECT_TRUE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.mhtml")));
-}
-
-TEST_F(OfflinePageUtilsTest, MaybeGetOnlineURLForOfflineURL) {
- EXPECT_EQ(kTestPage1Url, OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
- profile(), offline_url_page_1()));
- EXPECT_EQ(kTestPage2Url, OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
- profile(), offline_url_page_2()));
- EXPECT_EQ(GURL::EmptyGURL(), OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
- profile(), offline_url_missing()));
- EXPECT_EQ(kTestPage4Url, OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
- profile(), offline_url_expired()));
-}
-
-TEST_F(OfflinePageUtilsTest, IsOfflinePage) {
- EXPECT_TRUE(OfflinePageUtils::IsOfflinePage(profile(), offline_url_page_1()));
- EXPECT_TRUE(OfflinePageUtils::IsOfflinePage(profile(), offline_url_page_2()));
- EXPECT_FALSE(
- OfflinePageUtils::IsOfflinePage(profile(), offline_url_missing()));
- EXPECT_TRUE(
- OfflinePageUtils::IsOfflinePage(profile(), offline_url_expired()));
- EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage1Url));
- EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage2Url));
- EXPECT_FALSE(OfflinePageUtils::IsOfflinePage(profile(), kTestPage4Url));
-}
-
} // namespace offline_pages
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | chrome/browser/android/tab_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698