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

Side by Side Diff: chrome/browser/sessions/session_restore_browsertest.cc

Issue 10917231: Revamp TabNavigation class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac Created 8 years, 3 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/defaults.h" 9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/first_run/first_run.h" 10 #include "chrome/browser/first_run/first_run.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/sessions/session_restore.h" 13 #include "chrome/browser/sessions/session_restore.h"
14 #include "chrome/browser/sessions/session_service.h" 14 #include "chrome/browser/sessions/session_service.h"
15 #include "chrome/browser/sessions/session_service_factory.h" 15 #include "chrome/browser/sessions/session_service_factory.h"
16 #include "chrome/browser/sessions/session_service_test_helper.h" 16 #include "chrome/browser/sessions/session_service_test_helper.h"
17 #include "chrome/browser/sessions/session_types.h"
18 #include "chrome/browser/sessions/session_types_test_helper.h"
17 #include "chrome/browser/sessions/tab_restore_service.h" 19 #include "chrome/browser/sessions/tab_restore_service.h"
18 #include "chrome/browser/sessions/tab_restore_service_factory.h" 20 #include "chrome/browser/sessions/tab_restore_service_factory.h"
19 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
22 #include "chrome/browser/ui/browser_tabstrip.h" 24 #include "chrome/browser/ui/browser_tabstrip.h"
23 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 382
381 // The first tab should have 'url' as its url. 383 // The first tab should have 'url' as its url.
382 ASSERT_TRUE(new_browser); 384 ASSERT_TRUE(new_browser);
383 EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL()); 385 EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL());
384 } 386 }
385 #endif // !OS_CHROMEOS 387 #endif // !OS_CHROMEOS
386 388
387 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { 389 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) {
388 GURL url1("http://google.com"); 390 GURL url1("http://google.com");
389 GURL url2("http://google2.com"); 391 GURL url2("http://google2.com");
390 TabNavigation nav1(0, url1, content::Referrer(), ASCIIToUTF16("one"), 392 TabNavigation nav1 =
391 std::string(), content::PAGE_TRANSITION_TYPED); 393 SessionTypesTestHelper::CreateNavigation(url1.spec(), "one");
392 TabNavigation nav2(0, url2, content::Referrer(), ASCIIToUTF16("two"), 394 TabNavigation nav2 =
393 std::string(), content::PAGE_TRANSITION_TYPED); 395 SessionTypesTestHelper::CreateNavigation(url2.spec(), "two");
396 SessionTypesTestHelper::SetIsOverridingUserAgent(&nav2, true);
394 397
395 // Set up the restore data. 398 // Set up the restore data.
396 SessionTab tab; 399 SessionTab tab;
397 tab.tab_visual_index = 0; 400 tab.tab_visual_index = 0;
398 tab.current_navigation_index = 1; 401 tab.current_navigation_index = 1;
399 tab.pinned = false; 402 tab.pinned = false;
400 tab.navigations.push_back(nav1); 403 tab.navigations.push_back(nav1);
401 tab.navigations.push_back(nav2); 404 tab.navigations.push_back(nav2);
402 tab.user_agent_override = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19" 405 tab.user_agent_override = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19"
403 " (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19"; 406 " (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 web_contents = chrome::GetWebContentsAt(new_browser, 0); 446 web_contents = chrome::GetWebContentsAt(new_browser, 0);
444 VerifyNavigationEntries(web_contents->GetController(), url1, url2); 447 VerifyNavigationEntries(web_contents->GetController(), url1, url2);
445 ASSERT_EQ(tab.user_agent_override, web_contents->GetUserAgentOverride()); 448 ASSERT_EQ(tab.user_agent_override, web_contents->GetUserAgentOverride());
446 } 449 }
447 450
448 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignSession) { 451 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignSession) {
449 Profile* profile = browser()->profile(); 452 Profile* profile = browser()->profile();
450 453
451 GURL url1("http://google.com"); 454 GURL url1("http://google.com");
452 GURL url2("http://google2.com"); 455 GURL url2("http://google2.com");
453 TabNavigation nav1(0, url1, content::Referrer(), ASCIIToUTF16("one"), 456 TabNavigation nav1 =
454 std::string(), content::PAGE_TRANSITION_TYPED); 457 SessionTypesTestHelper::CreateNavigation(url1.spec(), "one");
455 TabNavigation nav2(0, url2, content::Referrer(), ASCIIToUTF16("two"), 458 TabNavigation nav2 =
456 std::string(), content::PAGE_TRANSITION_TYPED); 459 SessionTypesTestHelper::CreateNavigation(url2.spec(), "two");
457 nav1.set_is_overriding_user_agent(false);
458 nav2.set_is_overriding_user_agent(true);
459 460
460 // Set up the restore data -- one window with two tabs. 461 // Set up the restore data -- one window with two tabs.
461 std::vector<const SessionWindow*> session; 462 std::vector<const SessionWindow*> session;
462 SessionWindow window; 463 SessionWindow window;
463 SessionTab tab1; 464 SessionTab tab1;
464 tab1.tab_visual_index = 0; 465 tab1.tab_visual_index = 0;
465 tab1.current_navigation_index = 0; 466 tab1.current_navigation_index = 0;
466 tab1.pinned = true; 467 tab1.pinned = true;
467 tab1.navigations.push_back(nav1); 468 tab1.navigations.push_back(nav1);
468 tab1.user_agent_override = "user_agent_override"; 469 tab1.user_agent_override = "user_agent_override";
(...skipping 23 matching lines...) Expand all
492 ASSERT_EQ(url1, web_contents_1->GetURL()); 493 ASSERT_EQ(url1, web_contents_1->GetURL());
493 ASSERT_EQ(url2, web_contents_2->GetURL()); 494 ASSERT_EQ(url2, web_contents_2->GetURL());
494 495
495 // Check user agent override state. 496 // Check user agent override state.
496 ASSERT_EQ(tab1.user_agent_override, web_contents_1->GetUserAgentOverride()); 497 ASSERT_EQ(tab1.user_agent_override, web_contents_1->GetUserAgentOverride());
497 ASSERT_EQ(tab2.user_agent_override, web_contents_2->GetUserAgentOverride()); 498 ASSERT_EQ(tab2.user_agent_override, web_contents_2->GetUserAgentOverride());
498 499
499 content::NavigationEntry* entry = 500 content::NavigationEntry* entry =
500 web_contents_1->GetController().GetActiveEntry(); 501 web_contents_1->GetController().GetActiveEntry();
501 ASSERT_TRUE(entry); 502 ASSERT_TRUE(entry);
502 ASSERT_EQ(nav1.is_overriding_user_agent(), entry->GetIsOverridingUserAgent()); 503 ASSERT_EQ(SessionTypesTestHelper::GetIsOverridingUserAgent(nav1),
504 entry->GetIsOverridingUserAgent());
503 505
504 entry = web_contents_2->GetController().GetActiveEntry(); 506 entry = web_contents_2->GetController().GetActiveEntry();
505 ASSERT_TRUE(entry); 507 ASSERT_TRUE(entry);
506 ASSERT_EQ(nav2.is_overriding_user_agent(), entry->GetIsOverridingUserAgent()); 508 ASSERT_EQ(SessionTypesTestHelper::GetIsOverridingUserAgent(nav2),
509 entry->GetIsOverridingUserAgent());
507 510
508 // The SessionWindow destructor deletes the tabs, so we have to clear them 511 // The SessionWindow destructor deletes the tabs, so we have to clear them
509 // here to avoid a crash. 512 // here to avoid a crash.
510 window.tabs.clear(); 513 window.tabs.clear();
511 } 514 }
512 515
513 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, Basic) { 516 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, Basic) {
514 ui_test_utils::NavigateToURL(browser(), url1_); 517 ui_test_utils::NavigateToURL(browser(), url1_);
515 ui_test_utils::NavigateToURL(browser(), url2_); 518 ui_test_utils::NavigateToURL(browser(), url2_);
516 519
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 ASSERT_EQ(1u, BrowserList::size()); 845 ASSERT_EQ(1u, BrowserList::size());
843 ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL()); 846 ASSERT_EQ(url1_, chrome::GetActiveWebContents(new_browser)->GetURL());
844 content::NavigationController* new_controller = 847 content::NavigationController* new_controller =
845 &chrome::GetActiveWebContents(new_browser)->GetController(); 848 &chrome::GetActiveWebContents(new_browser)->GetController();
846 ASSERT_TRUE(new_controller->GetDefaultSessionStorageNamespace()); 849 ASSERT_TRUE(new_controller->GetDefaultSessionStorageNamespace());
847 std::string restored_session_storage_persistent_id = 850 std::string restored_session_storage_persistent_id =
848 new_controller->GetDefaultSessionStorageNamespace()->persistent_id(); 851 new_controller->GetDefaultSessionStorageNamespace()->persistent_id();
849 EXPECT_EQ(session_storage_persistent_id, 852 EXPECT_EQ(session_storage_persistent_id,
850 restored_session_storage_persistent_id); 853 restored_session_storage_persistent_id);
851 } 854 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_android.cc ('k') | chrome/browser/sessions/session_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698