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

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

Issue 2093543002: Do not snapshot error pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 4abafab1cc229eb139a51a7797d7dd2b49b0851b..ad872ca1b519de8e5c4e3576b47d1dee38fc67e1 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper_unittest.cc
@@ -20,6 +20,10 @@
namespace offline_pages {
+namespace {
+const GURL kTestPageUrl("http://mystery.site/foo.html");
+}
+
class TestArchiveFactoryImpl : public RecentTabHelper::TestArchiveFactory {
public:
explicit TestArchiveFactoryImpl(OfflinePageTestArchiver::Observer* observer);
@@ -44,6 +48,8 @@ class RecentTabHelperTest
void SetUpMockTaskRunner();
const std::vector<OfflinePageItem>& GetAllPages();
+ void FailLoad(const GURL& url);
+
// Runs default thread.
void RunUntilIdle();
// Moves forward the snapshot controller's task runner.
@@ -129,6 +135,16 @@ void RecentTabHelperTest::SetUp() {
model_->AddObserver(this);
}
+void RecentTabHelperTest::FailLoad(const GURL& url) {
+ controller().LoadURL(url, content::Referrer(), ui::PAGE_TRANSITION_TYPED,
+ std::string());
+ content::RenderFrameHostTester::For(main_rfh())->SimulateNavigationStart(url);
+ content::RenderFrameHostTester::For(main_rfh())->
+ SimulateNavigationError(url, net::ERR_INTERNET_DISCONNECTED);
+ content::RenderFrameHostTester::For(main_rfh())->
+ SimulateNavigationErrorPageCommit();
+}
+
const std::vector<OfflinePageItem>& RecentTabHelperTest::GetAllPages() {
model()->GetAllPages(
base::Bind(&RecentTabHelperTest::OnGetAllPagesDone,
@@ -156,19 +172,17 @@ TEST_F(RecentTabHelperTest, Basic) {
}
TEST_F(RecentTabHelperTest, SimpleCapture) {
- const GURL url("http://mystery.site/foo.html");
- NavigateAndCommit(url);
+ NavigateAndCommit(kTestPageUrl);
recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
RunUntilIdle();
EXPECT_TRUE(model()->is_loaded());
GetAllPages();
EXPECT_EQ(1U, all_pages().size());
- EXPECT_EQ(url, all_pages()[0].url);
+ EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
}
TEST_F(RecentTabHelperTest, TwoCaptures) {
- const GURL url("http://mystery.site/foo.html");
- NavigateAndCommit(url);
+ NavigateAndCommit(kTestPageUrl);
// Triggers snapshot after a time delay.
recent_tab_helper()->DocumentAvailableInMainFrame();
RunUntilIdle();
@@ -181,7 +195,7 @@ TEST_F(RecentTabHelperTest, TwoCaptures) {
EXPECT_EQ(0U, model_removed_count());
GetAllPages();
EXPECT_EQ(1U, all_pages().size());
- EXPECT_EQ(url, all_pages()[0].url);
+ EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
// Triggers snapshot immediately;
recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
@@ -191,7 +205,16 @@ TEST_F(RecentTabHelperTest, TwoCaptures) {
// the same page should be simply overridden.
GetAllPages();
EXPECT_EQ(1U, all_pages().size());
- EXPECT_EQ(url, all_pages()[0].url);
+ EXPECT_EQ(kTestPageUrl, all_pages()[0].url);
+}
+
+TEST_F(RecentTabHelperTest, NoCaptureOnErrorPage) {
+ FailLoad(kTestPageUrl);
+ recent_tab_helper()->DocumentOnLoadCompletedInMainFrame();
+ RunUntilIdle();
+ EXPECT_TRUE(model()->is_loaded());
+ GetAllPages();
+ EXPECT_EQ(0U, all_pages().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