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

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

Issue 1258273006: Remove page id from title and state updating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch
Patch Set: comment nit Created 4 years, 2 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
« 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 static_cast<NavigationControllerImpl&>(controller()); 360 static_cast<NavigationControllerImpl&>(controller());
361 cont.LoadURL(GURL(url::kAboutBlankURL), Referrer(), ui::PAGE_TRANSITION_TYPED, 361 cont.LoadURL(GURL(url::kAboutBlankURL), Referrer(), ui::PAGE_TRANSITION_TYPED,
362 std::string()); 362 std::string());
363 363
364 FrameHostMsg_DidCommitProvisionalLoad_Params params; 364 FrameHostMsg_DidCommitProvisionalLoad_Params params;
365 InitNavigateParams(&params, 0, 0, true, GURL(url::kAboutBlankURL), 365 InitNavigateParams(&params, 0, 0, true, GURL(url::kAboutBlankURL),
366 ui::PAGE_TRANSITION_TYPED); 366 ui::PAGE_TRANSITION_TYPED);
367 367
368 main_test_rfh()->SendNavigateWithParams(&params); 368 main_test_rfh()->SendNavigateWithParams(&params);
369 369
370 contents()->UpdateTitle(main_test_rfh(), 0, 370 contents()->UpdateTitle(main_test_rfh(),
371 base::ASCIIToUTF16(" Lots O' Whitespace\n"), 371 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
372 base::i18n::LEFT_TO_RIGHT); 372 base::i18n::LEFT_TO_RIGHT);
373 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 373 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
374 } 374 }
375 375
376 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) { 376 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) {
377 ASSERT_TRUE(controller().IsInitialNavigation()); 377 ASSERT_TRUE(controller().IsInitialNavigation());
378 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); 378 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title");
379 contents()->UpdateTitle(main_test_rfh(), -1, title, 379 contents()->UpdateTitle(main_test_rfh(), title, base::i18n::LEFT_TO_RIGHT);
380 base::i18n::LEFT_TO_RIGHT);
381 EXPECT_EQ(title, contents()->GetTitle()); 380 EXPECT_EQ(title, contents()->GetTitle());
382 } 381 }
383 382
384 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { 383 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) {
385 const GURL kGURL("chrome://blah"); 384 const GURL kGURL("chrome://blah");
386 controller().LoadURL( 385 controller().LoadURL(
387 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 386 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
388 EXPECT_EQ(base::string16(), contents()->GetTitle()); 387 EXPECT_EQ(base::string16(), contents()->GetTitle());
389 388
390 // Also test setting title while the first navigation is still pending. 389 // Also test setting title while the first navigation is still pending.
391 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); 390 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title");
392 contents()->UpdateTitle(main_test_rfh(), -1, title, 391 contents()->UpdateTitle(main_test_rfh(), title, base::i18n::LEFT_TO_RIGHT);
393 base::i18n::LEFT_TO_RIGHT);
394 EXPECT_EQ(title, contents()->GetTitle()); 392 EXPECT_EQ(title, contents()->GetTitle());
395 } 393 }
396 394
397 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) { 395 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) {
398 const GURL kGURL("chrome://blah"); 396 const GURL kGURL("chrome://blah");
399 const base::string16 title = base::ASCIIToUTF16("My Title"); 397 const base::string16 title = base::ASCIIToUTF16("My Title");
400 controller().LoadURL( 398 controller().LoadURL(
401 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 399 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
402 400
403 NavigationEntry* entry = controller().GetVisibleEntry(); 401 NavigationEntry* entry = controller().GetVisibleEntry();
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 // An automatic navigation. 3451 // An automatic navigation.
3454 main_test_rfh()->SendNavigateWithModificationCallback( 3452 main_test_rfh()->SendNavigateWithModificationCallback(
3455 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3453 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3456 3454
3457 EXPECT_EQ(1u, dialog_manager.reset_count()); 3455 EXPECT_EQ(1u, dialog_manager.reset_count());
3458 3456
3459 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3457 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3460 } 3458 }
3461 3459
3462 } // namespace content 3460 } // 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