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

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

Issue 1159143008: Fix wrong initialization of renderer_initiated_creation parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing mmenke@'s comments Created 5 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 unified diff | Download patch
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/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 "content/public/test/test_renderer_host.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/base/page_transition_types.h" 13 #include "ui/base/page_transition_types.h"
13 14
14 using chrome_browser_net::NetErrorTabHelper; 15 using chrome_browser_net::NetErrorTabHelper;
15 using chrome_common_net::DnsProbeStatus; 16 using chrome_common_net::DnsProbeStatus;
16 17
17 class TestNetErrorTabHelper : public NetErrorTabHelper { 18 class TestNetErrorTabHelper : public NetErrorTabHelper {
18 public: 19 public:
19 TestNetErrorTabHelper() 20 TestNetErrorTabHelper()
(...skipping 29 matching lines...) Expand all
49 }; 50 };
50 51
51 class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness { 52 class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness {
52 protected: 53 protected:
53 enum MainFrame { SUB_FRAME, MAIN_FRAME }; 54 enum MainFrame { SUB_FRAME, MAIN_FRAME };
54 enum ErrorPage { NORMAL_PAGE, ERROR_PAGE }; 55 enum ErrorPage { NORMAL_PAGE, ERROR_PAGE };
55 enum ErrorType { DNS_ERROR, OTHER_ERROR }; 56 enum ErrorType { DNS_ERROR, OTHER_ERROR };
56 57
57 void SetUp() override { 58 void SetUp() override {
58 ChromeRenderViewHostTestHarness::SetUp(); 59 ChromeRenderViewHostTestHarness::SetUp();
60
61 // This will simulate the initialization of the RenderFrame in the renderer
62 // process. This is needed because WebContents does not initialize a
63 // RenderFrame on construction, and the tests expect one to exist.
64 content::RenderFrameHostTester::For(main_rfh())
65 ->InitializeRenderFrameIfNeeded();
66
59 subframe_ = content::RenderFrameHostTester::For(main_rfh()) 67 subframe_ = content::RenderFrameHostTester::For(main_rfh())
60 ->AppendChild("subframe"); 68 ->AppendChild("subframe");
61 69
62 tab_helper_.reset(new TestNetErrorTabHelper); 70 tab_helper_.reset(new TestNetErrorTabHelper);
63 NetErrorTabHelper::set_state_for_testing( 71 NetErrorTabHelper::set_state_for_testing(
64 NetErrorTabHelper::TESTING_FORCE_ENABLED); 72 NetErrorTabHelper::TESTING_FORCE_ENABLED);
65 } 73 }
66 74
67 void StartProvisionalLoad(MainFrame main_frame, ErrorPage error_page) { 75 void StartProvisionalLoad(MainFrame main_frame, ErrorPage error_page) {
68 tab_helper_->DidStartProvisionalLoadForFrame( 76 tab_helper_->DidStartProvisionalLoadForFrame(
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 CommitProvisionalLoad(MAIN_FRAME); 381 CommitProvisionalLoad(MAIN_FRAME);
374 EXPECT_TRUE(probe_running()); 382 EXPECT_TRUE(probe_running());
375 EXPECT_EQ(3, sent_count()); 383 EXPECT_EQ(3, sent_count());
376 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent()); 384 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent());
377 385
378 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN); 386 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN);
379 EXPECT_FALSE(probe_running()); 387 EXPECT_FALSE(probe_running());
380 EXPECT_EQ(4, sent_count()); 388 EXPECT_EQ(4, sent_count());
381 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent()); 389 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent());
382 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698