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 "content/test/test_render_frame_host.h" | 5 #include "content/test/test_render_frame_host.h" |
6 | 6 |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/common/frame_messages.h" | 8 #include "content/common/frame_messages.h" |
9 #include "content/test/test_render_view_host.h" | 9 #include "content/test/test_render_view_host.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 } | 56 } |
57 | 57 |
58 void TestRenderFrameHost::SendNavigateWithTransitionAndResponseCode( | 58 void TestRenderFrameHost::SendNavigateWithTransitionAndResponseCode( |
59 int page_id, | 59 int page_id, |
60 const GURL& url, PageTransition transition, | 60 const GURL& url, PageTransition transition, |
61 int response_code) { | 61 int response_code) { |
62 // DidStartProvisionalLoad may delete the pending entry that holds |url|, | 62 // DidStartProvisionalLoad may delete the pending entry that holds |url|, |
63 // so we keep a copy of it to use in SendNavigateWithParameters. | 63 // so we keep a copy of it to use in SendNavigateWithParameters. |
64 GURL url_copy(url); | 64 GURL url_copy(url); |
65 OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url_copy); | 65 OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url_copy); |
66 SendNavigateWithParameters( | 66 SendNavigateWithParameters(page_id, |
67 page_id, url_copy, transition, url_copy, response_code, 0); | 67 url_copy, |
Charlie Reis
2014/04/05 00:09:10
Style nit: There's no need to put each function pa
Donn Denman
2014/04/09 21:09:21
Done.
| |
68 transition, | |
69 url_copy, | |
70 response_code, | |
71 0, | |
72 std::vector<GURL>()); | |
68 } | 73 } |
69 | 74 |
70 void TestRenderFrameHost::SendNavigateWithOriginalRequestURL( | 75 void TestRenderFrameHost::SendNavigateWithOriginalRequestURL( |
71 int page_id, | 76 int page_id, |
72 const GURL& url, | 77 const GURL& url, |
73 const GURL& original_request_url) { | 78 const GURL& original_request_url) { |
74 OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url); | 79 OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url); |
75 SendNavigateWithParameters( | 80 SendNavigateWithParameters(page_id, |
76 page_id, url, PAGE_TRANSITION_LINK, original_request_url, 200, 0); | 81 url, |
82 PAGE_TRANSITION_LINK, | |
83 original_request_url, | |
84 200, | |
85 0, | |
86 std::vector<GURL>()); | |
77 } | 87 } |
78 | 88 |
79 void TestRenderFrameHost::SendNavigateWithFile( | 89 void TestRenderFrameHost::SendNavigateWithFile( |
80 int page_id, | 90 int page_id, |
81 const GURL& url, | 91 const GURL& url, |
82 const base::FilePath& file_path) { | 92 const base::FilePath& file_path) { |
83 SendNavigateWithParameters( | 93 SendNavigateWithParameters(page_id, |
84 page_id, url, PAGE_TRANSITION_LINK, url, 200, &file_path); | 94 url, |
95 PAGE_TRANSITION_LINK, | |
96 url, | |
97 200, | |
98 &file_path, | |
99 std::vector<GURL>()); | |
85 } | 100 } |
86 | 101 |
87 void TestRenderFrameHost::SendNavigateWithParams( | 102 void TestRenderFrameHost::SendNavigateWithParams( |
88 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 103 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
89 params->frame_id = kFrameId; | 104 params->frame_id = kFrameId; |
90 FrameHostMsg_DidCommitProvisionalLoad msg(1, *params); | 105 FrameHostMsg_DidCommitProvisionalLoad msg(1, *params); |
91 OnNavigate(msg); | 106 OnNavigate(msg); |
92 } | 107 } |
108 void TestRenderFrameHost::SendNavigateWithRedirects( | |
109 int page_id, | |
110 const GURL& url, | |
111 const std::vector<GURL>& redirects) { | |
112 SendNavigateWithParameters( | |
113 page_id, url, PAGE_TRANSITION_LINK, url, 200, 0, redirects); | |
114 } | |
93 | 115 |
94 void TestRenderFrameHost::SendNavigateWithParameters( | 116 void TestRenderFrameHost::SendNavigateWithParameters( |
95 int page_id, | 117 int page_id, |
96 const GURL& url, | 118 const GURL& url, |
97 PageTransition transition, | 119 PageTransition transition, |
98 const GURL& original_request_url, | 120 const GURL& original_request_url, |
99 int response_code, | 121 int response_code, |
100 const base::FilePath* file_path_for_history_item) { | 122 const base::FilePath* file_path_for_history_item, |
123 const std::vector<GURL>& redirects) { | |
101 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 124 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
102 params.page_id = page_id; | 125 params.page_id = page_id; |
103 params.frame_id = kFrameId; | 126 params.frame_id = kFrameId; |
104 params.url = url; | 127 params.url = url; |
105 params.referrer = Referrer(); | 128 params.referrer = Referrer(); |
106 params.transition = transition; | 129 params.transition = transition; |
107 params.redirects = std::vector<GURL>(); | 130 params.redirects = redirects; |
108 params.should_update_history = true; | 131 params.should_update_history = true; |
109 params.searchable_form_url = GURL(); | 132 params.searchable_form_url = GURL(); |
110 params.searchable_form_encoding = std::string(); | 133 params.searchable_form_encoding = std::string(); |
111 params.security_info = std::string(); | 134 params.security_info = std::string(); |
112 params.gesture = NavigationGestureUser; | 135 params.gesture = NavigationGestureUser; |
113 params.contents_mime_type = contents_mime_type_; | 136 params.contents_mime_type = contents_mime_type_; |
114 params.is_post = false; | 137 params.is_post = false; |
115 params.was_within_same_page = false; | 138 params.was_within_same_page = false; |
116 params.http_status_code = response_code; | 139 params.http_status_code = response_code; |
117 params.socket_address.set_host("2001:db8::1"); | 140 params.socket_address.set_host("2001:db8::1"); |
118 params.socket_address.set_port(80); | 141 params.socket_address.set_port(80); |
119 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 142 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
120 params.original_request_url = original_request_url; | 143 params.original_request_url = original_request_url; |
121 | 144 |
122 params.page_state = PageState::CreateForTesting( | 145 params.page_state = PageState::CreateForTesting( |
123 url, | 146 url, |
124 false, | 147 false, |
125 file_path_for_history_item ? "data" : NULL, | 148 file_path_for_history_item ? "data" : NULL, |
126 file_path_for_history_item); | 149 file_path_for_history_item); |
127 | 150 |
128 FrameHostMsg_DidCommitProvisionalLoad msg(1, params); | 151 FrameHostMsg_DidCommitProvisionalLoad msg(1, params); |
129 OnNavigate(msg); | 152 OnNavigate(msg); |
130 } | 153 } |
131 | 154 |
132 } // namespace content | 155 } // namespace content |
OLD | NEW |