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

Side by Side Diff: chrome/browser/net/net_error_tab_helper_unittest.cc

Issue 2588253002: Enable download page action for error page (Closed)
Patch Set: Address download feedback Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/net/net_error_tab_helper.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/net_error_tab_helper.h" 5 #include "chrome/browser/net/net_error_tab_helper.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 #include "components/error_page/common/net_error_info.h" 9 #include "components/error_page/common/net_error_info.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 26 matching lines...) Expand all
37 EXPECT_TRUE(mock_probe_running_); 37 EXPECT_TRUE(mock_probe_running_);
38 OnDnsProbeFinished(status); 38 OnDnsProbeFinished(status);
39 mock_probe_running_ = false; 39 mock_probe_running_ = false;
40 } 40 }
41 41
42 bool mock_probe_running() const { return mock_probe_running_; } 42 bool mock_probe_running() const { return mock_probe_running_; }
43 DnsProbeStatus last_status_sent() const { return last_status_sent_; } 43 DnsProbeStatus last_status_sent() const { return last_status_sent_; }
44 int mock_sent_count() const { return mock_sent_count_; } 44 int mock_sent_count() const { return mock_sent_count_; }
45 45
46 #if defined(OS_ANDROID) 46 #if defined(OS_ANDROID)
47 using NetErrorTabHelper::DownloadPageLater; 47 using NetErrorTabHelper::OnDownloadPageLater;
48 48
49 const GURL& download_page_later_url() const { 49 const GURL& download_page_later_url() const {
50 return download_page_later_url_; 50 return download_page_later_url_;
51 } 51 }
52 52
53 int times_download_page_later_invoked() const { 53 int times_download_page_later_invoked() const {
54 return times_download_page_later_invoked_; 54 return times_download_page_later_invoked_;
55 } 55 }
56 #endif // defined(OS_ANDROID) 56 #endif // defined(OS_ANDROID)
57 57
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 content::RenderFrameHostTester::For(main_rfh())-> 168 content::RenderFrameHostTester::For(main_rfh())->
169 SimulateNavigationErrorPageCommit(); 169 SimulateNavigationErrorPageCommit();
170 } 170 }
171 } 171 }
172 172
173 #if defined(OS_ANDROID) 173 #if defined(OS_ANDROID)
174 void NoDownloadPageLaterForNonHttpSchemes(const char* url_string, 174 void NoDownloadPageLaterForNonHttpSchemes(const char* url_string,
175 bool succeeded) { 175 bool succeeded) {
176 GURL url(url_string); 176 GURL url(url_string);
177 LoadURL(url, succeeded); 177 LoadURL(url, succeeded);
178 tab_helper()->DownloadPageLater(); 178 tab_helper()->OnDownloadPageLater();
179 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); 179 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
180 } 180 }
181 #endif 181 #endif
182 182
183 bool probe_running() { return tab_helper_->mock_probe_running(); } 183 bool probe_running() { return tab_helper_->mock_probe_running(); }
184 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); } 184 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); }
185 int sent_count() { return tab_helper_->mock_sent_count(); } 185 int sent_count() { return tab_helper_->mock_sent_count(); }
186 186
187 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); } 187 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); }
188 188
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 tab_helper()->network_diagnostics_interface() 369 tab_helper()->network_diagnostics_interface()
370 ->RunNetworkDiagnostics(GURL(url)); 370 ->RunNetworkDiagnostics(GURL(url));
371 EXPECT_EQ(0, tab_helper()->times_diagnostics_dialog_invoked()); 371 EXPECT_EQ(0, tab_helper()->times_diagnostics_dialog_invoked());
372 } 372 }
373 } 373 }
374 374
375 #if defined(OS_ANDROID) 375 #if defined(OS_ANDROID)
376 TEST_F(NetErrorTabHelperTest, DownloadPageLater) { 376 TEST_F(NetErrorTabHelperTest, DownloadPageLater) {
377 GURL url("http://somewhere:123/"); 377 GURL url("http://somewhere:123/");
378 LoadURL(url, false /*succeeded*/); 378 LoadURL(url, false /*succeeded*/);
379 tab_helper()->DownloadPageLater(); 379 tab_helper()->OnDownloadPageLater();
380 EXPECT_EQ(url, tab_helper()->download_page_later_url()); 380 EXPECT_EQ(url, tab_helper()->download_page_later_url());
381 EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked()); 381 EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked());
382 } 382 }
383 383
384 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) { 384 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) {
385 GURL url("http://somewhere:123/"); 385 GURL url("http://somewhere:123/");
386 LoadURL(url, true /*succeeded*/); 386 LoadURL(url, true /*succeeded*/);
387 tab_helper()->DownloadPageLater(); 387 tab_helper()->OnDownloadPageLater();
388 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); 388 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
389 } 389 }
390 390
391 // Makes sure that "Download page later" isn't run on URLs with non-HTTP/HTTPS 391 // Makes sure that "Download page later" isn't run on URLs with non-HTTP/HTTPS
392 // schemes. 392 // schemes.
393 // NOTE: the test harness code in this file and in TestRendererHost don't always 393 // NOTE: the test harness code in this file and in TestRendererHost don't always
394 // deal with pending RFH correctly. This works because most tests only load 394 // deal with pending RFH correctly. This works because most tests only load
395 // once. So workaround it by puting each test case in a separate test. 395 // once. So workaround it by puting each test case in a separate test.
396 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) { 396 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) {
397 NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false); 397 NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false);
398 } 398 }
399 399
400 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) { 400 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) {
401 NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false); 401 NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false);
402 } 402 }
403 403
404 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) { 404 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) {
405 // about:blank always succeeds, and the test harness won't handle URLs that 405 // about:blank always succeeds, and the test harness won't handle URLs that
406 // don't go to the network failing. 406 // don't go to the network failing.
407 NoDownloadPageLaterForNonHttpSchemes("about:blank", true); 407 NoDownloadPageLaterForNonHttpSchemes("about:blank", true);
408 } 408 }
409 409
410 #endif // defined(OS_ANDROID) 410 #endif // defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « chrome/browser/net/net_error_tab_helper.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698