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/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
8 #include "components/error_page/common/net_error_info.h" | 8 #include "components/error_page/common/net_error_info.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 }; | 49 }; |
50 | 50 |
51 class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness { | 51 class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness { |
52 protected: | 52 protected: |
53 enum MainFrame { SUB_FRAME, MAIN_FRAME }; | 53 enum MainFrame { SUB_FRAME, MAIN_FRAME }; |
54 enum ErrorPage { NORMAL_PAGE, ERROR_PAGE }; | 54 enum ErrorPage { NORMAL_PAGE, ERROR_PAGE }; |
55 enum ErrorType { DNS_ERROR, OTHER_ERROR }; | 55 enum ErrorType { DNS_ERROR, OTHER_ERROR }; |
56 | 56 |
57 void SetUp() override { | 57 void SetUp() override { |
58 ChromeRenderViewHostTestHarness::SetUp(); | 58 ChromeRenderViewHostTestHarness::SetUp(); |
| 59 |
| 60 content::RenderViewHostTester::For(rvh())->CreateTestRenderView( |
| 61 base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, -1, false); |
| 62 |
59 subframe_ = content::RenderFrameHostTester::For(main_rfh()) | 63 subframe_ = content::RenderFrameHostTester::For(main_rfh()) |
60 ->AppendChild("subframe"); | 64 ->AppendChild("subframe"); |
61 | 65 |
62 tab_helper_.reset(new TestNetErrorTabHelper); | 66 tab_helper_.reset(new TestNetErrorTabHelper); |
63 NetErrorTabHelper::set_state_for_testing( | 67 NetErrorTabHelper::set_state_for_testing( |
64 NetErrorTabHelper::TESTING_FORCE_ENABLED); | 68 NetErrorTabHelper::TESTING_FORCE_ENABLED); |
65 } | 69 } |
66 | 70 |
67 void StartProvisionalLoad(MainFrame main_frame, ErrorPage error_page) { | 71 void StartProvisionalLoad(MainFrame main_frame, ErrorPage error_page) { |
68 tab_helper_->DidStartProvisionalLoadForFrame( | 72 tab_helper_->DidStartProvisionalLoadForFrame( |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 CommitProvisionalLoad(MAIN_FRAME); | 377 CommitProvisionalLoad(MAIN_FRAME); |
374 EXPECT_TRUE(probe_running()); | 378 EXPECT_TRUE(probe_running()); |
375 EXPECT_EQ(3, sent_count()); | 379 EXPECT_EQ(3, sent_count()); |
376 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent()); | 380 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent()); |
377 | 381 |
378 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN); | 382 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN); |
379 EXPECT_FALSE(probe_running()); | 383 EXPECT_FALSE(probe_running()); |
380 EXPECT_EQ(4, sent_count()); | 384 EXPECT_EQ(4, sent_count()); |
381 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent()); | 385 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent()); |
382 } | 386 } |
OLD | NEW |