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

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

Issue 2810913002: [Offline pages] Add new Error page failure status inside the MHTML archiver and update correspondin… (Closed)
Patch Set: add comments and fix tests 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
Index: chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc
index 849998960d5ec578b5672c6cea558b1673ad7521..52197d076e3b17ec07a56d52d3b6aa5801f56c2d 100644
--- a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc
@@ -37,6 +37,8 @@ class TestMHTMLArchiver : public OfflinePageMHTMLArchiver {
NOT_ABLE_TO_ARCHIVE,
WEB_CONTENTS_MISSING,
CONNECTION_SECURITY_ERROR,
+ ERROR_PAGE,
+ INTERSTITIAL_PAGE,
};
TestMHTMLArchiver(const GURL& url, const TestScenario test_scenario);
@@ -46,6 +48,7 @@ class TestMHTMLArchiver : public OfflinePageMHTMLArchiver {
void GenerateMHTML(const base::FilePath& archives_dir,
const CreateArchiveParams& create_archive_params) override;
bool HasConnectionSecurityError() override;
+ content::PageType GetPageType() override;
const GURL url_;
const TestScenario test_scenario_;
@@ -86,6 +89,14 @@ bool TestMHTMLArchiver::HasConnectionSecurityError() {
return test_scenario_ == TestScenario::CONNECTION_SECURITY_ERROR;
}
+content::PageType TestMHTMLArchiver::GetPageType() {
+ if (test_scenario_ == TestScenario::ERROR_PAGE)
+ return content::PageType::PAGE_TYPE_ERROR;
+ if (test_scenario_ == TestScenario::INTERSTITIAL_PAGE)
+ return content::PageType::PAGE_TYPE_INTERSTITIAL;
+ return content::PageType::PAGE_TYPE_NORMAL;
+}
+
} // namespace
class OfflinePageMHTMLArchiverTest : public testing::Test {
@@ -217,6 +228,31 @@ TEST_F(OfflinePageMHTMLArchiverTest, ConnectionNotSecure) {
EXPECT_EQ(0LL, last_file_size());
}
+// Tests for archiver handling of an error page.
+TEST_F(OfflinePageMHTMLArchiverTest, PageError) {
+ GURL page_url = GURL(kTestURL);
+ std::unique_ptr<TestMHTMLArchiver> archiver(
+ CreateArchive(page_url, TestMHTMLArchiver::TestScenario::ERROR_PAGE));
+
+ EXPECT_EQ(archiver.get(), last_archiver());
+ EXPECT_EQ(OfflinePageArchiver::ArchiverResult::ERROR_ERROR_PAGE,
+ last_result());
+ EXPECT_EQ(base::FilePath(), last_file_path());
+ EXPECT_EQ(0LL, last_file_size());
+}
+
+// Tests for archiver handling of an interstitial page.
+TEST_F(OfflinePageMHTMLArchiverTest, InterstitialPage) {
+ GURL page_url = GURL(kTestURL);
+ std::unique_ptr<TestMHTMLArchiver> archiver(CreateArchive(
+ page_url, TestMHTMLArchiver::TestScenario::INTERSTITIAL_PAGE));
+ EXPECT_EQ(archiver.get(), last_archiver());
+ EXPECT_EQ(OfflinePageArchiver::ArchiverResult::ERROR_INTERSTITIAL_PAGE,
+ last_result());
+ EXPECT_EQ(base::FilePath(), last_file_path());
+ EXPECT_EQ(0LL, last_file_size());
+}
+
// Tests for successful creation of the offline page archive.
TEST_F(OfflinePageMHTMLArchiverTest, SuccessfullyCreateOfflineArchive) {
GURL page_url = GURL(kTestURL);

Powered by Google App Engine
This is Rietveld 408576698