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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/navigation_controller_impl.h" 6 #include "content/browser/frame_host/navigation_controller_impl.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/frame_host/render_frame_host_manager.h" 8 #include "content/browser/frame_host/render_frame_host_manager.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/webui/web_ui_controller_factory_registry.h" 10 #include "content/browser/webui/web_ui_controller_factory_registry.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) { 253 TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) {
254 const GURL kChromeURL("chrome://foo"); 254 const GURL kChromeURL("chrome://foo");
255 const GURL kDestUrl("http://www.google.com/"); 255 const GURL kDestUrl("http://www.google.com/");
256 256
257 // Navigate our first tab to a chrome url and then to the destination. 257 // Navigate our first tab to a chrome url and then to the destination.
258 NavigateActiveAndCommit(kChromeURL); 258 NavigateActiveAndCommit(kChromeURL);
259 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( 259 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>(
260 contents()->GetRenderManagerForTesting()->current_host()); 260 contents()->GetRenderManagerForTesting()->current_host());
261 261
262 // Send an update title message and make sure it works. 262 // Send an update title message and make sure it works.
263 const base::string16 ntp_title = ASCIIToUTF16("NTP Title"); 263 const base::string16 ntp_title = base::ASCIIToUTF16("NTP Title");
264 blink::WebTextDirection direction = blink::WebTextDirectionLeftToRight; 264 blink::WebTextDirection direction = blink::WebTextDirectionLeftToRight;
265 EXPECT_TRUE(ntp_rvh->OnMessageReceived( 265 EXPECT_TRUE(ntp_rvh->OnMessageReceived(
266 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); 266 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction)));
267 EXPECT_EQ(ntp_title, contents()->GetTitle()); 267 EXPECT_EQ(ntp_title, contents()->GetTitle());
268 268
269 // Navigate to a cross-site URL. 269 // Navigate to a cross-site URL.
270 contents()->GetController().LoadURL( 270 contents()->GetController().LoadURL(
271 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); 271 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string());
272 EXPECT_TRUE(contents()->cross_navigation_pending()); 272 EXPECT_TRUE(contents()->cross_navigation_pending());
273 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( 273 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>(
274 contents()->GetRenderManagerForTesting()->pending_render_view_host()); 274 contents()->GetRenderManagerForTesting()->pending_render_view_host());
275 ASSERT_TRUE(dest_rvh); 275 ASSERT_TRUE(dest_rvh);
276 EXPECT_NE(ntp_rvh, dest_rvh); 276 EXPECT_NE(ntp_rvh, dest_rvh);
277 277
278 // Create one more view in the same SiteInstance where dest_rvh2 278 // Create one more view in the same SiteInstance where dest_rvh2
279 // exists so that it doesn't get deleted on navigation to another 279 // exists so that it doesn't get deleted on navigation to another
280 // site. 280 // site.
281 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())-> 281 static_cast<SiteInstanceImpl*>(ntp_rvh->GetSiteInstance())->
282 increment_active_view_count(); 282 increment_active_view_count();
283 283
284 // BeforeUnload finishes. 284 // BeforeUnload finishes.
285 ntp_rvh->SendShouldCloseACK(true); 285 ntp_rvh->SendShouldCloseACK(true);
286 286
287 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits. 287 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits.
288 dest_rvh->SendNavigate(101, kDestUrl); 288 dest_rvh->SendNavigate(101, kDestUrl);
289 289
290 // The new RVH should be able to update its title. 290 // The new RVH should be able to update its title.
291 const base::string16 dest_title = ASCIIToUTF16("Google"); 291 const base::string16 dest_title = base::ASCIIToUTF16("Google");
292 EXPECT_TRUE(dest_rvh->OnMessageReceived( 292 EXPECT_TRUE(dest_rvh->OnMessageReceived(
293 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 101, dest_title, 293 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 101, dest_title,
294 direction))); 294 direction)));
295 EXPECT_EQ(dest_title, contents()->GetTitle()); 295 EXPECT_EQ(dest_title, contents()->GetTitle());
296 296
297 // The old renderer, being slow, now updates the title. It should be filtered 297 // The old renderer, being slow, now updates the title. It should be filtered
298 // out and not take effect. 298 // out and not take effect.
299 EXPECT_TRUE(ntp_rvh->is_swapped_out()); 299 EXPECT_TRUE(ntp_rvh->is_swapped_out());
300 EXPECT_TRUE(ntp_rvh->OnMessageReceived( 300 EXPECT_TRUE(ntp_rvh->OnMessageReceived(
301 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); 301 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction)));
302 EXPECT_EQ(dest_title, contents()->GetTitle()); 302 EXPECT_EQ(dest_title, contents()->GetTitle());
303 303
304 // We cannot filter out synchronous IPC messages, because the renderer would 304 // We cannot filter out synchronous IPC messages, because the renderer would
305 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example 305 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example
306 // that can run easily within a unit test, and that needs to receive a reply 306 // that can run easily within a unit test, and that needs to receive a reply
307 // without showing an actual dialog. 307 // without showing an actual dialog.
308 MockRenderProcessHost* ntp_process_host = 308 MockRenderProcessHost* ntp_process_host =
309 static_cast<MockRenderProcessHost*>(ntp_rvh->GetProcess()); 309 static_cast<MockRenderProcessHost*>(ntp_rvh->GetProcess());
310 ntp_process_host->sink().ClearMessages(); 310 ntp_process_host->sink().ClearMessages();
311 const base::string16 msg = ASCIIToUTF16("Message"); 311 const base::string16 msg = base::ASCIIToUTF16("Message");
312 bool result = false; 312 bool result = false;
313 base::string16 unused; 313 base::string16 unused;
314 ViewHostMsg_RunBeforeUnloadConfirm before_unload_msg( 314 ViewHostMsg_RunBeforeUnloadConfirm before_unload_msg(
315 rvh()->GetRoutingID(), kChromeURL, msg, false, &result, &unused); 315 rvh()->GetRoutingID(), kChromeURL, msg, false, &result, &unused);
316 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. 316 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI.
317 before_unload_msg.EnableMessagePumping(); 317 before_unload_msg.EnableMessagePumping();
318 EXPECT_TRUE(ntp_rvh->OnMessageReceived(before_unload_msg)); 318 EXPECT_TRUE(ntp_rvh->OnMessageReceived(before_unload_msg));
319 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); 319 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID));
320 320
321 // Also test RunJavaScriptMessage. 321 // Also test RunJavaScriptMessage.
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 Source<RenderWidgetHost>(host2)); 1336 Source<RenderWidgetHost>(host2));
1337 manager->ShouldClosePage(false, true, base::TimeTicks()); 1337 manager->ShouldClosePage(false, true, base::TimeTicks());
1338 1338
1339 EXPECT_TRUE( 1339 EXPECT_TRUE(
1340 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); 1340 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED));
1341 EXPECT_FALSE(manager->pending_render_view_host()); 1341 EXPECT_FALSE(manager->pending_render_view_host());
1342 EXPECT_EQ(host, manager->current_host()); 1342 EXPECT_EQ(host, manager->current_host());
1343 } 1343 }
1344 1344
1345 } // namespace content 1345 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698