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

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

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/renderer_host/test_render_view_host.h" 10 #include "content/browser/renderer_host/test_render_view_host.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 virtual void DidFinishLoad(int64 frame_id, 277 virtual void DidFinishLoad(int64 frame_id,
278 const GURL& validated_url, 278 const GURL& validated_url,
279 bool is_main_frame, 279 bool is_main_frame,
280 RenderViewHost* render_view_host) OVERRIDE { 280 RenderViewHost* render_view_host) OVERRIDE {
281 last_url_ = validated_url; 281 last_url_ = validated_url;
282 } 282 }
283 virtual void DidFailLoad(int64 frame_id, 283 virtual void DidFailLoad(int64 frame_id,
284 const GURL& validated_url, 284 const GURL& validated_url,
285 bool is_main_frame, 285 bool is_main_frame,
286 int error_code, 286 int error_code,
287 const string16& error_description, 287 const base::string16& error_description,
288 RenderViewHost* render_view_host) OVERRIDE { 288 RenderViewHost* render_view_host) OVERRIDE {
289 last_url_ = validated_url; 289 last_url_ = validated_url;
290 } 290 }
291 291
292 const GURL& last_url() const { return last_url_; } 292 const GURL& last_url() const { return last_url_; }
293 293
294 private: 294 private:
295 GURL last_url_; 295 GURL last_url_;
296 296
297 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); 297 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
(...skipping 13 matching lines...) Expand all
311 311
312 contents()->UpdateTitle(rvh(), 0, ASCIIToUTF16(" Lots O' Whitespace\n"), 312 contents()->UpdateTitle(rvh(), 0, ASCIIToUTF16(" Lots O' Whitespace\n"),
313 base::i18n::LEFT_TO_RIGHT); 313 base::i18n::LEFT_TO_RIGHT);
314 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 314 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
315 } 315 }
316 316
317 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { 317 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) {
318 const GURL kGURL("chrome://blah"); 318 const GURL kGURL("chrome://blah");
319 controller().LoadURL( 319 controller().LoadURL(
320 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 320 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
321 EXPECT_EQ(string16(), contents()->GetTitle()); 321 EXPECT_EQ(base::string16(), contents()->GetTitle());
322 } 322 }
323 323
324 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) { 324 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) {
325 const GURL kGURL("chrome://blah"); 325 const GURL kGURL("chrome://blah");
326 const string16 title = ASCIIToUTF16("My Title"); 326 const base::string16 title = ASCIIToUTF16("My Title");
327 controller().LoadURL( 327 controller().LoadURL(
328 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 328 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
329 329
330 NavigationEntry* entry = controller().GetVisibleEntry(); 330 NavigationEntry* entry = controller().GetVisibleEntry();
331 ASSERT_EQ(kGURL, entry->GetURL()); 331 ASSERT_EQ(kGURL, entry->GetURL());
332 entry->SetTitle(title); 332 entry->SetTitle(title);
333 333
334 EXPECT_EQ(title, contents()->GetTitle()); 334 EXPECT_EQ(title, contents()->GetTitle());
335 } 335 }
336 336
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 EXPECT_EQ(url_normalized, observer.last_url()); 2145 EXPECT_EQ(url_normalized, observer.last_url());
2146 2146
2147 // Create and navigate another WebContents. 2147 // Create and navigate another WebContents.
2148 scoped_ptr<TestWebContents> other_contents( 2148 scoped_ptr<TestWebContents> other_contents(
2149 static_cast<TestWebContents*>(CreateTestWebContents())); 2149 static_cast<TestWebContents*>(CreateTestWebContents()));
2150 TestWebContentsObserver other_observer(other_contents.get()); 2150 TestWebContentsObserver other_observer(other_contents.get());
2151 other_contents->NavigateAndCommit(url_normalized); 2151 other_contents->NavigateAndCommit(url_normalized);
2152 2152
2153 // Check that an IPC with about:whatever is correctly normalized. 2153 // Check that an IPC with about:whatever is correctly normalized.
2154 other_contents->TestDidFailLoadWithError( 2154 other_contents->TestDidFailLoadWithError(
2155 1, url_from_ipc, true, 1, string16()); 2155 1, url_from_ipc, true, 1, base::string16());
2156 EXPECT_EQ(url_normalized, other_observer.last_url()); 2156 EXPECT_EQ(url_normalized, other_observer.last_url());
2157 } 2157 }
2158 2158
2159 // Test that if a pending contents is deleted before it is shown, we don't 2159 // Test that if a pending contents is deleted before it is shown, we don't
2160 // crash. 2160 // crash.
2161 TEST_F(WebContentsImplTest, PendingContents) { 2161 TEST_F(WebContentsImplTest, PendingContents) {
2162 scoped_ptr<TestWebContents> other_contents( 2162 scoped_ptr<TestWebContents> other_contents(
2163 static_cast<TestWebContents*>(CreateTestWebContents())); 2163 static_cast<TestWebContents*>(CreateTestWebContents()));
2164 contents()->AddPendingContents(other_contents.get()); 2164 contents()->AddPendingContents(other_contents.get());
2165 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2165 int route_id = other_contents->GetRenderViewHost()->GetRoutingID();
2166 other_contents.reset(); 2166 other_contents.reset();
2167 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); 2167 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id));
2168 } 2168 }
2169 2169
2170 } // namespace content 2170 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/web_contents/web_contents_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698