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

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

Issue 225303016: Elim kRestorePopups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 DISABLED_RestoreOnNewWindowWithNoTabbedBrowsers 292 DISABLED_RestoreOnNewWindowWithNoTabbedBrowsers
293 #else 293 #else
294 #define MAYBE_RestoreOnNewWindowWithNoTabbedBrowsers \ 294 #define MAYBE_RestoreOnNewWindowWithNoTabbedBrowsers \
295 RestoreOnNewWindowWithNoTabbedBrowsers 295 RestoreOnNewWindowWithNoTabbedBrowsers
296 #endif 296 #endif
297 297
298 // Makes sure when session restore is triggered in the same process we don't end 298 // Makes sure when session restore is triggered in the same process we don't end
299 // up with an extra tab. 299 // up with an extra tab.
300 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, 300 IN_PROC_BROWSER_TEST_F(SessionRestoreTest,
301 MAYBE_RestoreOnNewWindowWithNoTabbedBrowsers) { 301 MAYBE_RestoreOnNewWindowWithNoTabbedBrowsers) {
302 if (browser_defaults::kRestorePopups)
303 return;
304
305 const base::FilePath::CharType* kTitle1File = 302 const base::FilePath::CharType* kTitle1File =
306 FILE_PATH_LITERAL("title1.html"); 303 FILE_PATH_LITERAL("title1.html");
307 GURL url(ui_test_utils::GetTestUrl(base::FilePath( 304 GURL url(ui_test_utils::GetTestUrl(base::FilePath(
308 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); 305 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File)));
309 ui_test_utils::NavigateToURL(browser(), url); 306 ui_test_utils::NavigateToURL(browser(), url);
310 307
311 // Turn on session restore. 308 // Turn on session restore.
312 SessionStartupPref::SetStartupPref( 309 SessionStartupPref::SetStartupPref(
313 browser()->profile(), 310 browser()->profile(),
314 SessionStartupPref(SessionStartupPref::LAST)); 311 SessionStartupPref(SessionStartupPref::LAST));
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 navigate_params.disposition = NEW_BACKGROUND_TAB; 844 navigate_params.disposition = NEW_BACKGROUND_TAB;
848 ui_test_utils::NavigateToURL(&navigate_params); 845 ui_test_utils::NavigateToURL(&navigate_params);
849 846
850 Browser* new_browser = QuitBrowserAndRestore(browser(), 3); 847 Browser* new_browser = QuitBrowserAndRestore(browser(), 3);
851 848
852 ASSERT_EQ(url1_, 849 ASSERT_EQ(url1_,
853 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 850 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
854 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1); 851 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1);
855 } 852 }
856 853
857 // Creates a tabbed browser and popup and makes sure we restore both.
858 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NormalAndPopup) {
859 if (!browser_defaults::kRestorePopups)
860 return; // Test only applicable if restoring popups.
861
862 ui_test_utils::NavigateToURL(browser(), url1_);
863
864 // Make sure we have one window.
865 AssertOneWindowWithOneTab(browser());
866
867 // Open a popup.
868 Browser* popup = new Browser(
869 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(),
870 browser()->host_desktop_type()));
871 popup->window()->Show();
872 ASSERT_EQ(2u, active_browser_list_->size());
873
874 ui_test_utils::NavigateToURL(popup, url1_);
875
876 // Simulate an exit by shuting down the session service. If we don't do this
877 // the first window close is treated as though the user closed the window
878 // and won't be restored.
879 SessionServiceFactory::ShutdownForProfile(browser()->profile());
880
881 // Restart and make sure we have two windows.
882 QuitBrowserAndRestore(browser(), 1);
883
884 ASSERT_EQ(2u, active_browser_list_->size());
885
886 Browser* browser1 = active_browser_list_->get(0);
887 Browser* browser2 = active_browser_list_->get(1);
888
889 Browser::Type type1 = browser1->type();
890 Browser::Type type2 = browser2->type();
891
892 // The order of whether the normal window or popup is first depends upon
893 // activation order, which is not necessarily consistant across runs.
894 if (type1 == Browser::TYPE_TABBED) {
895 EXPECT_EQ(type2, Browser::TYPE_POPUP);
896 } else {
897 EXPECT_EQ(type1, Browser::TYPE_POPUP);
898 EXPECT_EQ(type2, Browser::TYPE_TABBED);
899 }
900 }
901
902 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) 854 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
903 // This test doesn't apply to the Mac version; see GetCommandLineForRelaunch 855 // This test doesn't apply to the Mac version; see GetCommandLineForRelaunch
904 // for details. It was disabled for a long time so might never have worked on 856 // for details. It was disabled for a long time so might never have worked on
905 // ChromeOS. 857 // ChromeOS.
906 858
907 // Launches an app window, closes tabbed browser, launches and makes sure 859 // Launches an app window, closes tabbed browser, launches and makes sure
908 // we restore the tabbed browser url. 860 // we restore the tabbed browser url.
909 // If this test flakes, use http://crbug.com/29110 861 // If this test flakes, use http://crbug.com/29110
910 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, 862 IN_PROC_BROWSER_TEST_F(SessionRestoreTest,
911 RestoreAfterClosingTabbedBrowserWithAppAndLaunching) { 863 RestoreAfterClosingTabbedBrowserWithAppAndLaunching) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 content::NavigationController* controller = 1134 content::NavigationController* controller =
1183 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); 1135 &browser()->tab_strip_model()->GetActiveWebContents()->GetController();
1184 EXPECT_TRUE( 1136 EXPECT_TRUE(
1185 controller->GetDefaultSessionStorageNamespace()->should_persist()); 1137 controller->GetDefaultSessionStorageNamespace()->should_persist());
1186 1138
1187 // Quit and restore. Check that no extra tabs were created. 1139 // Quit and restore. Check that no extra tabs were created.
1188 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 1140 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
1189 ASSERT_EQ(1u, active_browser_list_->size()); 1141 ASSERT_EQ(1u, active_browser_list_->size());
1190 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); 1142 EXPECT_EQ(1, new_browser->tab_strip_model()->count());
1191 } 1143 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/better_session_restore_browsertest.cc ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698