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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 135723003: Move DidCommitProvisionalLoad code from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing final nits. Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/interstitial_page_impl.h" 7 #include "content/browser/frame_host/interstitial_page_impl.h"
8 #include "content/browser/frame_host/navigation_entry_impl.h" 8 #include "content/browser/frame_host/navigation_entry_impl.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
11 #include "content/browser/webui/web_ui_controller_factory_registry.h" 11 #include "content/browser/webui/web_ui_controller_factory_registry.h"
12 #include "content/common/frame_messages.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/browser/global_request_id.h" 14 #include "content/public/browser/global_request_id.h"
14 #include "content/public/browser/interstitial_page_delegate.h" 15 #include "content/public/browser/interstitial_page_delegate.h"
15 #include "content/public/browser/navigation_details.h" 16 #include "content/public/browser/navigation_details.h"
16 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/render_widget_host_view.h" 19 #include "content/public/browser/render_widget_host_view.h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/browser/web_ui_controller.h" 21 #include "content/public/browser/web_ui_controller.h"
21 #include "content/public/common/bindings_policy.h" 22 #include "content/public/common/bindings_policy.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int command_received_count() const { 145 int command_received_count() const {
145 return command_received_count_; 146 return command_received_count_;
146 } 147 }
147 148
148 void TestDomOperationResponse(const std::string& json_string) { 149 void TestDomOperationResponse(const std::string& json_string) {
149 if (enabled()) 150 if (enabled())
150 CommandReceived(); 151 CommandReceived();
151 } 152 }
152 153
153 void TestDidNavigate(int page_id, const GURL& url) { 154 void TestDidNavigate(int page_id, const GURL& url) {
154 ViewHostMsg_FrameNavigate_Params params; 155 FrameHostMsg_DidCommitProvisionalLoad_Params params;
155 InitNavigateParams(&params, page_id, url, PAGE_TRANSITION_TYPED); 156 InitNavigateParams(&params, page_id, url, PAGE_TRANSITION_TYPED);
156 DidNavigate(GetRenderViewHostForTesting(), params); 157 DidNavigate(GetRenderViewHostForTesting(), params);
157 } 158 }
158 159
159 void TestRenderViewTerminated(base::TerminationStatus status, 160 void TestRenderViewTerminated(base::TerminationStatus status,
160 int error_code) { 161 int error_code) {
161 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code); 162 RenderViewTerminated(GetRenderViewHostForTesting(), status, error_code);
162 } 163 }
163 164
164 bool is_showing() const { 165 bool is_showing() const {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 292
292 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); 293 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
293 }; 294 };
294 295
295 } // namespace 296 } // namespace
296 297
297 // Test to make sure that title updates get stripped of whitespace. 298 // Test to make sure that title updates get stripped of whitespace.
298 TEST_F(WebContentsImplTest, UpdateTitle) { 299 TEST_F(WebContentsImplTest, UpdateTitle) {
299 NavigationControllerImpl& cont = 300 NavigationControllerImpl& cont =
300 static_cast<NavigationControllerImpl&>(controller()); 301 static_cast<NavigationControllerImpl&>(controller());
301 ViewHostMsg_FrameNavigate_Params params; 302 FrameHostMsg_DidCommitProvisionalLoad_Params params;
302 InitNavigateParams(&params, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED); 303 InitNavigateParams(&params, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
303 304
304 LoadCommittedDetails details; 305 LoadCommittedDetails details;
305 cont.RendererDidNavigate(test_rvh(), params, &details); 306 cont.RendererDidNavigate(test_rvh(), params, &details);
306 307
307 contents()->UpdateTitle(rvh(), 0, 308 contents()->UpdateTitle(rvh(), 0,
308 base::ASCIIToUTF16(" Lots O' Whitespace\n"), 309 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
309 base::i18n::LEFT_TO_RIGHT); 310 base::i18n::LEFT_TO_RIGHT);
310 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 311 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
311 } 312 }
(...skipping 27 matching lines...) Expand all
339 340
340 process()->sink().ClearMessages(); 341 process()->sink().ClearMessages();
341 342
342 cont.LoadURL( 343 cont.LoadURL(
343 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 344 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
344 rvh()->GetDelegate()->RenderViewCreated(rvh()); 345 rvh()->GetDelegate()->RenderViewCreated(rvh());
345 // Did we get the expected message? 346 // Did we get the expected message?
346 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( 347 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
347 ViewMsg_EnableViewSourceMode::ID)); 348 ViewMsg_EnableViewSourceMode::ID));
348 349
349 ViewHostMsg_FrameNavigate_Params params; 350 FrameHostMsg_DidCommitProvisionalLoad_Params params;
350 InitNavigateParams(&params, 0, kGURL, PAGE_TRANSITION_TYPED); 351 InitNavigateParams(&params, 0, kGURL, PAGE_TRANSITION_TYPED);
351 LoadCommittedDetails details; 352 LoadCommittedDetails details;
352 cont.RendererDidNavigate(test_rvh(), params, &details); 353 cont.RendererDidNavigate(test_rvh(), params, &details);
353 // Also check title and url. 354 // Also check title and url.
354 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); 355 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle());
355 } 356 }
356 357
357 // Test to ensure UpdateMaxPageID is working properly. 358 // Test to ensure UpdateMaxPageID is working properly.
358 TEST_F(WebContentsImplTest, UpdateMaxPageID) { 359 TEST_F(WebContentsImplTest, UpdateMaxPageID) {
359 SiteInstance* instance1 = contents()->GetSiteInstance(); 360 SiteInstance* instance1 = contents()->GetSiteInstance();
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 std::vector<GURL> url_chain; 1087 std::vector<GURL> url_chain;
1087 url_chain.push_back(GURL()); 1088 url_chain.push_back(GURL());
1088 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse( 1089 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1089 pending_rvh, GlobalRequestID(0, 0), false, url_chain, Referrer(), 1090 pending_rvh, GlobalRequestID(0, 0), false, url_chain, Referrer(),
1090 PAGE_TRANSITION_TYPED, 1, false); 1091 PAGE_TRANSITION_TYPED, 1, false);
1091 1092
1092 // Suppose the original renderer navigates now, while the unload request is in 1093 // Suppose the original renderer navigates now, while the unload request is in
1093 // flight. We should ignore it, wait for the unload ack, and let the pending 1094 // flight. We should ignore it, wait for the unload ack, and let the pending
1094 // request continue. Otherwise, the contents may close spontaneously or stop 1095 // request continue. Otherwise, the contents may close spontaneously or stop
1095 // responding to navigation requests. (See bug 23942.) 1096 // responding to navigation requests. (See bug 23942.)
1096 ViewHostMsg_FrameNavigate_Params params1a; 1097 FrameHostMsg_DidCommitProvisionalLoad_Params params1a;
1097 InitNavigateParams(&params1a, 2, GURL("http://www.google.com/foo"), 1098 InitNavigateParams(&params1a, 2, GURL("http://www.google.com/foo"),
1098 PAGE_TRANSITION_TYPED); 1099 PAGE_TRANSITION_TYPED);
1099 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); 1100 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo"));
1100 1101
1101 // Verify that the pending navigation is still in progress. 1102 // Verify that the pending navigation is still in progress.
1102 EXPECT_TRUE(contents()->cross_navigation_pending()); 1103 EXPECT_TRUE(contents()->cross_navigation_pending());
1103 EXPECT_TRUE(contents()->GetPendingRenderViewHost() != NULL); 1104 EXPECT_TRUE(contents()->GetPendingRenderViewHost() != NULL);
1104 1105
1105 // DidNavigate from the pending page should commit it. 1106 // DidNavigate from the pending page should commit it.
1106 contents()->TestDidNavigate( 1107 contents()->TestDidNavigate(
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 TEST_F(WebContentsImplTest, PendingContents) { 2165 TEST_F(WebContentsImplTest, PendingContents) {
2165 scoped_ptr<TestWebContents> other_contents( 2166 scoped_ptr<TestWebContents> other_contents(
2166 static_cast<TestWebContents*>(CreateTestWebContents())); 2167 static_cast<TestWebContents*>(CreateTestWebContents()));
2167 contents()->AddPendingContents(other_contents.get()); 2168 contents()->AddPendingContents(other_contents.get());
2168 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2169 int route_id = other_contents->GetRenderViewHost()->GetRoutingID();
2169 other_contents.reset(); 2170 other_contents.reset();
2170 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); 2171 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id));
2171 } 2172 }
2172 2173
2173 } // namespace content 2174 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698