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/net/net_error_info.h" | 7 #include "chrome/common/net/net_error_info.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 "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/common/page_transition_types.h" | |
11 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/base/page_transition_types.h" |
13 | 13 |
14 using chrome_browser_net::NetErrorTabHelper; | 14 using chrome_browser_net::NetErrorTabHelper; |
15 using chrome_common_net::DnsProbeStatus; | 15 using chrome_common_net::DnsProbeStatus; |
16 | 16 |
17 class TestNetErrorTabHelper : public NetErrorTabHelper { | 17 class TestNetErrorTabHelper : public NetErrorTabHelper { |
18 public: | 18 public: |
19 TestNetErrorTabHelper() | 19 TestNetErrorTabHelper() |
20 : NetErrorTabHelper(NULL), | 20 : NetErrorTabHelper(NULL), |
21 mock_probe_running_(false), | 21 mock_probe_running_(false), |
22 last_status_sent_(chrome_common_net::DNS_PROBE_MAX), | 22 last_status_sent_(chrome_common_net::DNS_PROBE_MAX), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 (main_frame == MAIN_FRAME) ? main_rfh() : subframe_, | 69 (main_frame == MAIN_FRAME) ? main_rfh() : subframe_, |
70 bogus_url_, // validated_url | 70 bogus_url_, // validated_url |
71 (error_page == ERROR_PAGE), | 71 (error_page == ERROR_PAGE), |
72 false); // is_iframe_srcdoc | 72 false); // is_iframe_srcdoc |
73 } | 73 } |
74 | 74 |
75 void CommitProvisionalLoad(MainFrame main_frame) { | 75 void CommitProvisionalLoad(MainFrame main_frame) { |
76 tab_helper_->DidCommitProvisionalLoadForFrame( | 76 tab_helper_->DidCommitProvisionalLoadForFrame( |
77 (main_frame == MAIN_FRAME) ? main_rfh() : subframe_, | 77 (main_frame == MAIN_FRAME) ? main_rfh() : subframe_, |
78 bogus_url_, // url | 78 bogus_url_, // url |
79 content::PAGE_TRANSITION_TYPED); | 79 ui::PAGE_TRANSITION_TYPED); |
80 } | 80 } |
81 | 81 |
82 void FailProvisionalLoad(MainFrame main_frame, ErrorType error_type) { | 82 void FailProvisionalLoad(MainFrame main_frame, ErrorType error_type) { |
83 int net_error; | 83 int net_error; |
84 | 84 |
85 if (error_type == DNS_ERROR) | 85 if (error_type == DNS_ERROR) |
86 net_error = net::ERR_NAME_NOT_RESOLVED; | 86 net_error = net::ERR_NAME_NOT_RESOLVED; |
87 else | 87 else |
88 net_error = net::ERR_TIMED_OUT; | 88 net_error = net::ERR_TIMED_OUT; |
89 | 89 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 CommitProvisionalLoad(MAIN_FRAME); | 373 CommitProvisionalLoad(MAIN_FRAME); |
374 EXPECT_TRUE(probe_running()); | 374 EXPECT_TRUE(probe_running()); |
375 EXPECT_EQ(3, sent_count()); | 375 EXPECT_EQ(3, sent_count()); |
376 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent()); | 376 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, last_status_sent()); |
377 | 377 |
378 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN); | 378 FinishProbe(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN); |
379 EXPECT_FALSE(probe_running()); | 379 EXPECT_FALSE(probe_running()); |
380 EXPECT_EQ(4, sent_count()); | 380 EXPECT_EQ(4, sent_count()); |
381 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent()); | 381 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, last_status_sent()); |
382 } | 382 } |
OLD | NEW |