OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 EXPECT_TRUE(mock_probe_running_); | 36 EXPECT_TRUE(mock_probe_running_); |
37 OnDnsProbeFinished(status); | 37 OnDnsProbeFinished(status); |
38 mock_probe_running_ = false; | 38 mock_probe_running_ = false; |
39 } | 39 } |
40 | 40 |
41 bool mock_probe_running() const { return mock_probe_running_; } | 41 bool mock_probe_running() const { return mock_probe_running_; } |
42 DnsProbeStatus last_status_sent() const { return last_status_sent_; } | 42 DnsProbeStatus last_status_sent() const { return last_status_sent_; } |
43 int mock_sent_count() const { return mock_sent_count_; } | 43 int mock_sent_count() const { return mock_sent_count_; } |
44 | 44 |
45 #if BUILDFLAG(ANDROID_JAVA_UI) | 45 #if BUILDFLAG(ANDROID_JAVA_UI) |
46 using NetErrorTabHelper::DownloadPageLater; | 46 using NetErrorTabHelper::OnDownloadPageLater; |
47 | 47 |
48 const GURL& download_page_later_url() const { | 48 const GURL& download_page_later_url() const { |
49 return download_page_later_url_; | 49 return download_page_later_url_; |
50 } | 50 } |
51 | 51 |
52 int times_download_page_later_invoked() const { | 52 int times_download_page_later_invoked() const { |
53 return times_download_page_later_invoked_; | 53 return times_download_page_later_invoked_; |
54 } | 54 } |
55 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 55 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
56 | 56 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 content::RenderFrameHostTester::For(main_rfh())-> | 167 content::RenderFrameHostTester::For(main_rfh())-> |
168 SimulateNavigationErrorPageCommit(); | 168 SimulateNavigationErrorPageCommit(); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 #if BUILDFLAG(ANDROID_JAVA_UI) | 172 #if BUILDFLAG(ANDROID_JAVA_UI) |
173 void NoDownloadPageLaterForNonHttpSchemes(const char* url_string, | 173 void NoDownloadPageLaterForNonHttpSchemes(const char* url_string, |
174 bool succeeded) { | 174 bool succeeded) { |
175 GURL url(url_string); | 175 GURL url(url_string); |
176 LoadURL(url, succeeded); | 176 LoadURL(url, succeeded); |
177 tab_helper()->DownloadPageLater(); | 177 tab_helper()->OnDownloadPageLater(); |
178 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); | 178 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); |
179 } | 179 } |
180 #endif | 180 #endif |
181 | 181 |
182 bool probe_running() { return tab_helper_->mock_probe_running(); } | 182 bool probe_running() { return tab_helper_->mock_probe_running(); } |
183 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); } | 183 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); } |
184 int sent_count() { return tab_helper_->mock_sent_count(); } | 184 int sent_count() { return tab_helper_->mock_sent_count(); } |
185 | 185 |
186 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); } | 186 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); } |
187 | 187 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 tab_helper()->network_diagnostics_interface() | 368 tab_helper()->network_diagnostics_interface() |
369 ->RunNetworkDiagnostics(GURL(url)); | 369 ->RunNetworkDiagnostics(GURL(url)); |
370 EXPECT_EQ(0, tab_helper()->times_diagnostics_dialog_invoked()); | 370 EXPECT_EQ(0, tab_helper()->times_diagnostics_dialog_invoked()); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 #if BUILDFLAG(ANDROID_JAVA_UI) | 374 #if BUILDFLAG(ANDROID_JAVA_UI) |
375 TEST_F(NetErrorTabHelperTest, DownloadPageLater) { | 375 TEST_F(NetErrorTabHelperTest, DownloadPageLater) { |
376 GURL url("http://somewhere:123/"); | 376 GURL url("http://somewhere:123/"); |
377 LoadURL(url, false /*succeeded*/); | 377 LoadURL(url, false /*succeeded*/); |
378 tab_helper()->DownloadPageLater(); | 378 tab_helper()->OnDownloadPageLater(); |
379 EXPECT_EQ(url, tab_helper()->download_page_later_url()); | 379 EXPECT_EQ(url, tab_helper()->download_page_later_url()); |
380 EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked()); | 380 EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked()); |
381 } | 381 } |
382 | 382 |
383 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) { | 383 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) { |
384 GURL url("http://somewhere:123/"); | 384 GURL url("http://somewhere:123/"); |
385 LoadURL(url, true /*succeeded*/); | 385 LoadURL(url, true /*succeeded*/); |
386 tab_helper()->DownloadPageLater(); | 386 tab_helper()->OnDownloadPageLater(); |
387 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); | 387 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); |
388 } | 388 } |
389 | 389 |
390 // Makes sure that "Download page later" isn't run on URLs with non-HTTP/HTTPS | 390 // Makes sure that "Download page later" isn't run on URLs with non-HTTP/HTTPS |
391 // schemes. | 391 // schemes. |
392 // NOTE: the test harness code in this file and in TestRendererHost don't always | 392 // NOTE: the test harness code in this file and in TestRendererHost don't always |
393 // deal with pending RFH correctly. This works because most tests only load | 393 // deal with pending RFH correctly. This works because most tests only load |
394 // once. So workaround it by puting each test case in a separate test. | 394 // once. So workaround it by puting each test case in a separate test. |
395 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) { | 395 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) { |
396 NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false); | 396 NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false); |
397 } | 397 } |
398 | 398 |
399 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) { | 399 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) { |
400 NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false); | 400 NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false); |
401 } | 401 } |
402 | 402 |
403 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) { | 403 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) { |
404 // about:blank always succeeds, and the test harness won't handle URLs that | 404 // about:blank always succeeds, and the test harness won't handle URLs that |
405 // don't go to the network failing. | 405 // don't go to the network failing. |
406 NoDownloadPageLaterForNonHttpSchemes("about:blank", true); | 406 NoDownloadPageLaterForNonHttpSchemes("about:blank", true); |
407 } | 407 } |
408 | 408 |
409 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 409 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
OLD | NEW |