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

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

Issue 2574953002: Fix Android unit_tests failures with PlzNavigate. (Closed)
Patch Set: fix last test and cleanup Created 4 years 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 | « no previous file | content/browser/frame_host/navigation_request.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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 content::RenderFrameHostTester::For(main_rfh())-> 162 content::RenderFrameHostTester::For(main_rfh())->
163 SimulateNavigationCommit(url); 163 SimulateNavigationCommit(url);
164 } else { 164 } else {
165 content::RenderFrameHostTester::For(main_rfh())-> 165 content::RenderFrameHostTester::For(main_rfh())->
166 SimulateNavigationError(url, net::ERR_TIMED_OUT); 166 SimulateNavigationError(url, net::ERR_TIMED_OUT);
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)
173 void NoDownloadPageLaterForNonHttpSchemes(const char* url_string,
174 bool succeeded) {
175 GURL url(url_string);
176 LoadURL(url, succeeded);
177 tab_helper()->DownloadPageLater();
178 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
179 }
180 #endif
181
172 bool probe_running() { return tab_helper_->mock_probe_running(); } 182 bool probe_running() { return tab_helper_->mock_probe_running(); }
173 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); } 183 DnsProbeStatus last_status_sent() { return tab_helper_->last_status_sent(); }
174 int sent_count() { return tab_helper_->mock_sent_count(); } 184 int sent_count() { return tab_helper_->mock_sent_count(); }
175 185
176 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); } 186 TestNetErrorTabHelper* tab_helper() { return tab_helper_.get(); }
177 187
178 private: 188 private:
179 content::RenderFrameHost* subframe_; 189 content::RenderFrameHost* subframe_;
180 std::unique_ptr<TestNetErrorTabHelper> tab_helper_; 190 std::unique_ptr<TestNetErrorTabHelper> tab_helper_;
181 GURL bogus_url_; 191 GURL bogus_url_;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 382
373 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) { 383 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) {
374 GURL url("http://somewhere:123/"); 384 GURL url("http://somewhere:123/");
375 LoadURL(url, true /*succeeded*/); 385 LoadURL(url, true /*succeeded*/);
376 tab_helper()->DownloadPageLater(); 386 tab_helper()->DownloadPageLater();
377 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); 387 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
378 } 388 }
379 389
380 // 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
381 // schemes. 391 // schemes.
382 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes) { 392 // NOTE: the test harness code in this file and in TestRendererHost don't always
383 const char* kUrls[] = { 393 // deal with pending RFH correctly. This works because most tests only load
384 "file:///blah/blah", 394 // once. So workaround it by puting each test case in a separate test.
arthursonzogni 2016/12/15 16:32:39 Nit: s/don't/doesn't Nit: s/puting/putting
385 "chrome://blah/", 395 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) {
386 "about:blank", 396 NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false);
387 }; 397 }
388 398
389 for (const char* url_string : kUrls) { 399 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) {
390 GURL url(url_string); 400 NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false);
391 LoadURL(url, false /*succeeded*/);
392 tab_helper()->DownloadPageLater();
393 EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
394 }
395 } 401 }
402
403 TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) {
404 // about:blank always succeeds, and the test harness won't handle URLs that
405 // don't go to the network failing.
406 NoDownloadPageLaterForNonHttpSchemes("about:blank", true);
407 }
408
396 #endif // BUILDFLAG(ANDROID_JAVA_UI) 409 #endif // BUILDFLAG(ANDROID_JAVA_UI)
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698