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

Unified Diff: chrome/browser/sessions/tab_restore_browsertest.cc

Issue 2345763002: Fix tabs duplication when restoring last closed window. (Closed)
Patch Set: Fix comments. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/tab_restore_browsertest.cc
diff --git a/chrome/browser/sessions/tab_restore_browsertest.cc b/chrome/browser/sessions/tab_restore_browsertest.cc
index 91c8c8ceeee95eb7dc654e7d4012171e861aa886..5c383f9e4226132e2e85b022abb401d102fe669e 100644
--- a/chrome/browser/sessions/tab_restore_browsertest.cc
+++ b/chrome/browser/sessions/tab_restore_browsertest.cc
@@ -13,6 +13,10 @@
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/lifetime/keep_alive_types.h"
+#include "chrome/browser/lifetime/scoped_keep_alive.h"
+#include "chrome/browser/prefs/session_startup_pref.h"
+#include "chrome/browser/sessions/session_restore_test_helper.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -716,3 +720,35 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) {
EXPECT_EQ(url1_,
browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL());
}
+
+// Check that TabRestoreService and SessionService do not try to restore the
+// same thing.
+IN_PROC_BROWSER_TEST_F(TabRestoreTest,
+ RestoreFirstBrowserWhenSessionServiceEnabled) {
+ // Do not exit from test when last browser is closed.
+ ScopedKeepAlive keep_alive(KeepAliveOrigin::SESSION_RESTORE,
+ KeepAliveRestartOption::DISABLED);
+
+ // Enable session service.
+ SessionStartupPref pref(SessionStartupPref::LAST);
+ Profile* profile = browser()->profile();
+ SessionStartupPref::SetStartupPref(profile, pref);
+
+ // Add tabs and close browser.
+ AddSomeTabs(browser(), 3);
+ // 1st tab is about:blank added by InProcessBrowserTest.
+ EXPECT_EQ(4, browser()->tab_strip_model()->count());
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::NotificationService::AllSources());
+ chrome::CloseWindow(browser());
+ observer.Wait();
+
+ SessionRestoreTestHelper helper;
+ // Restore browser (this is what Cmd-Shift-T does on Mac).
+ chrome::OpenWindowWithRestoredTabs(profile);
+ if (SessionRestore::IsRestoring(profile))
+ helper.Wait();
+ Browser* browser = GetBrowser(0);
+ EXPECT_EQ(4, browser->tab_strip_model()->count());
+}
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | components/sessions/core/in_memory_tab_restore_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698