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

Side by Side Diff: content/browser/web_contents/web_contents_impl_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 (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"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Test to make sure that title updates get stripped of whitespace. 297 // Test to make sure that title updates get stripped of whitespace.
298 TEST_F(WebContentsImplTest, UpdateTitle) { 298 TEST_F(WebContentsImplTest, UpdateTitle) {
299 NavigationControllerImpl& cont = 299 NavigationControllerImpl& cont =
300 static_cast<NavigationControllerImpl&>(controller()); 300 static_cast<NavigationControllerImpl&>(controller());
301 ViewHostMsg_FrameNavigate_Params params; 301 ViewHostMsg_FrameNavigate_Params params;
302 InitNavigateParams(&params, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED); 302 InitNavigateParams(&params, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
303 303
304 LoadCommittedDetails details; 304 LoadCommittedDetails details;
305 cont.RendererDidNavigate(params, &details); 305 cont.RendererDidNavigate(params, &details);
306 306
307 contents()->UpdateTitle(rvh(), 0, ASCIIToUTF16(" Lots O' Whitespace\n"), 307 contents()->UpdateTitle(rvh(), 0,
308 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
308 base::i18n::LEFT_TO_RIGHT); 309 base::i18n::LEFT_TO_RIGHT);
309 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 310 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
310 } 311 }
311 312
312 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { 313 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) {
313 const GURL kGURL("chrome://blah"); 314 const GURL kGURL("chrome://blah");
314 controller().LoadURL( 315 controller().LoadURL(
315 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 316 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
316 EXPECT_EQ(base::string16(), contents()->GetTitle()); 317 EXPECT_EQ(base::string16(), contents()->GetTitle());
317 } 318 }
318 319
319 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) { 320 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) {
320 const GURL kGURL("chrome://blah"); 321 const GURL kGURL("chrome://blah");
321 const base::string16 title = ASCIIToUTF16("My Title"); 322 const base::string16 title = base::ASCIIToUTF16("My Title");
322 controller().LoadURL( 323 controller().LoadURL(
323 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 324 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
324 325
325 NavigationEntry* entry = controller().GetVisibleEntry(); 326 NavigationEntry* entry = controller().GetVisibleEntry();
326 ASSERT_EQ(kGURL, entry->GetURL()); 327 ASSERT_EQ(kGURL, entry->GetURL());
327 entry->SetTitle(title); 328 entry->SetTitle(title);
328 329
329 EXPECT_EQ(title, contents()->GetTitle()); 330 EXPECT_EQ(title, contents()->GetTitle());
330 } 331 }
331 332
(...skipping 11 matching lines...) Expand all
343 rvh()->GetDelegate()->RenderViewCreated(rvh()); 344 rvh()->GetDelegate()->RenderViewCreated(rvh());
344 // Did we get the expected message? 345 // Did we get the expected message?
345 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( 346 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
346 ViewMsg_EnableViewSourceMode::ID)); 347 ViewMsg_EnableViewSourceMode::ID));
347 348
348 ViewHostMsg_FrameNavigate_Params params; 349 ViewHostMsg_FrameNavigate_Params params;
349 InitNavigateParams(&params, 0, kGURL, PAGE_TRANSITION_TYPED); 350 InitNavigateParams(&params, 0, kGURL, PAGE_TRANSITION_TYPED);
350 LoadCommittedDetails details; 351 LoadCommittedDetails details;
351 cont.RendererDidNavigate(params, &details); 352 cont.RendererDidNavigate(params, &details);
352 // Also check title and url. 353 // Also check title and url.
353 EXPECT_EQ(ASCIIToUTF16(kUrl), contents()->GetTitle()); 354 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle());
354 } 355 }
355 356
356 // Test to ensure UpdateMaxPageID is working properly. 357 // Test to ensure UpdateMaxPageID is working properly.
357 TEST_F(WebContentsImplTest, UpdateMaxPageID) { 358 TEST_F(WebContentsImplTest, UpdateMaxPageID) {
358 SiteInstance* instance1 = contents()->GetSiteInstance(); 359 SiteInstance* instance1 = contents()->GetSiteInstance();
359 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); 360 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL));
360 361
361 // Starts at -1. 362 // Starts at -1.
362 EXPECT_EQ(-1, contents()->GetMaxPageID()); 363 EXPECT_EQ(-1, contents()->GetMaxPageID());
363 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1)); 364 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1));
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); 2031 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted);
2031 TestInterstitialPageStateGuard state_guard(interstitial); 2032 TestInterstitialPageStateGuard state_guard(interstitial);
2032 interstitial->Show(); 2033 interstitial->Show();
2033 interstitial->TestDidNavigate(1, kGURL); 2034 interstitial->TestDidNavigate(1, kGURL);
2034 2035
2035 // While the interstitial is showing, let's simulate the hidden page 2036 // While the interstitial is showing, let's simulate the hidden page
2036 // attempting to show a JS message. 2037 // attempting to show a JS message.
2037 IPC::Message* dummy_message = new IPC::Message; 2038 IPC::Message* dummy_message = new IPC::Message;
2038 bool did_suppress_message = false; 2039 bool did_suppress_message = false;
2039 contents()->RunJavaScriptMessage(contents()->GetRenderViewHost(), 2040 contents()->RunJavaScriptMessage(contents()->GetRenderViewHost(),
2040 ASCIIToUTF16("This is an informative message"), ASCIIToUTF16("OK"), 2041 base::ASCIIToUTF16("This is an informative message"),
2042 base::ASCIIToUTF16("OK"),
2041 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message, 2043 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message,
2042 &did_suppress_message); 2044 &did_suppress_message);
2043 EXPECT_TRUE(did_suppress_message); 2045 EXPECT_TRUE(did_suppress_message);
2044 } 2046 }
2045 2047
2046 // Makes sure that if the source passed to CopyStateFromAndPrune has an 2048 // Makes sure that if the source passed to CopyStateFromAndPrune has an
2047 // interstitial it isn't copied over to the destination. 2049 // interstitial it isn't copied over to the destination.
2048 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { 2050 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) {
2049 // Navigate to a page. 2051 // Navigate to a page.
2050 GURL url1("http://www.google.com"); 2052 GURL url1("http://www.google.com");
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 TEST_F(WebContentsImplTest, PendingContents) { 2164 TEST_F(WebContentsImplTest, PendingContents) {
2163 scoped_ptr<TestWebContents> other_contents( 2165 scoped_ptr<TestWebContents> other_contents(
2164 static_cast<TestWebContents*>(CreateTestWebContents())); 2166 static_cast<TestWebContents*>(CreateTestWebContents()));
2165 contents()->AddPendingContents(other_contents.get()); 2167 contents()->AddPendingContents(other_contents.get());
2166 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2168 int route_id = other_contents->GetRenderViewHost()->GetRoutingID();
2167 other_contents.reset(); 2169 other_contents.reset();
2168 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); 2170 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id));
2169 } 2171 }
2170 2172
2171 } // namespace content 2173 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698