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

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

Issue 2345763002: Fix tabs duplication when restoring last closed window. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/ui/browser.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 <stddef.h> 5 #include <stddef.h>
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/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/lifetime/keep_alive_types.h"
17 #include "chrome/browser/lifetime/scoped_keep_alive.h"
18 #include "chrome/browser/prefs/session_startup_pref.h"
19 #include "chrome/browser/sessions/session_restore_test_helper.h"
16 #include "chrome/browser/sessions/tab_restore_service_factory.h" 20 #include "chrome/browser/sessions/tab_restore_service_factory.h"
17 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
19 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/browser_live_tab_context.h" 24 #include "chrome/browser/ui/browser_live_tab_context.h"
21 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
22 #include "chrome/browser/ui/find_bar/find_notification_details.h" 26 #include "chrome/browser/ui/find_bar/find_notification_details.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 while (browser()->tab_strip_model()->count()) 713 while (browser()->tab_strip_model()->count())
710 CloseTab(0); 714 CloseTab(0);
711 } 715 }
712 716
713 // Verifies restoring a tab works on startup. 717 // Verifies restoring a tab works on startup.
714 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) { 718 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) {
715 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); 719 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1));
716 EXPECT_EQ(url1_, 720 EXPECT_EQ(url1_,
717 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); 721 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL());
718 } 722 }
723
724 // Check that TabRestoreService and SessionService do not conflict with each
725 // other when the first window for a profile has been launched.
726 IN_PROC_BROWSER_TEST_F(TabRestoreTest,
727 RestoreFirstBrowserWhenSessionServiceEnabled) {
728 // Do not exit from test when last browser is closed.
729 ScopedKeepAlive keep_alive(KeepAliveOrigin::SESSION_RESTORE,
730 KeepAliveRestartOption::DISABLED);
731
732 // Enable session service.
733 SessionStartupPref pref(SessionStartupPref::LAST);
734 Profile* profile = browser()->profile();
735 SessionStartupPref::SetStartupPref(profile, pref);
736
737 // Add tabs and close browser.
738 AddSomeTabs(browser(), 3);
739 // 1st tab is about:blank added by InProcessBrowserTest.
740 EXPECT_EQ(4, browser()->tab_strip_model()->count());
741 content::WindowedNotificationObserver observer(
742 chrome::NOTIFICATION_BROWSER_CLOSED,
743 content::NotificationService::AllSources());
744 chrome::CloseWindow(browser());
745 observer.Wait();
746
747 SessionRestoreTestHelper helper;
748 // Restore browser (that what Cmd-Shift-T does on Mac).
749 chrome::OpenWindowWithRestoredTabs(profile);
750 if (SessionRestore::IsRestoring(profile))
751 helper.Wait();
752 Browser* browser = GetBrowser(0);
753 EXPECT_EQ(4, browser->tab_strip_model()->count());
Michael K. (Yandex Team) 2016/09/20 14:53:58 Without that fix there will be 8 tabs.
754 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698