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

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

Issue 2714483003: cros: Fix restoring session windows after crash inconsistent minimized window counts (Closed)
Patch Set: RestoreSessionAfterCrash on nullptr Created 3 years, 9 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/session_restore_browsertest_chromeos.cc
diff --git a/chrome/browser/sessions/session_restore_browsertest_chromeos.cc b/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
index de48f66ddc7d65b5485acada0fb9b328f5a30cc7..f769318899ab69010d49e059a46e800c0e872df6 100644
--- a/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
+++ b/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/sessions/session_restore.h"
+
#include <stddef.h>
#include <list>
@@ -78,9 +80,16 @@ class SessionRestoreTestChromeOS : public InProcessBrowserTest {
browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
}
- Profile* profile() { return browser()->profile(); }
+ Profile* profile() {
+ if (!profile_)
+ profile_ = browser()->profile();
+
+ return profile_;
+ }
+ private:
std::list<Browser*> browser_list_;
+ Profile* profile_ = nullptr;
};
// Thse tests are in pairs. The PRE_ test creates some browser windows and
@@ -203,3 +212,50 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMinimized) {
// they have a browser running instead of just showing them an empty desktop.
EXPECT_EQ(1u, minimized_count);
}
+
+// Tests that restoring session windows after crash should keep consistent
+// minimized window counts (crbug.com/694854).
+IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS,
+ PRE_RestoreSessionWindowsAfterCrash) {
+ // One browser window is always created by default.
+ ASSERT_TRUE(browser());
+ browser()->window()->Minimize();
+
+ Browser* browser2 =
+ CreateBrowserWithParams(Browser::CreateParams(profile(), true));
+ browser2->window()->Minimize();
+
+ Browser* browser3 =
+ CreateBrowserWithParams(Browser::CreateParams(profile(), true));
+ browser3->window()->Minimize();
+
+ EXPECT_TRUE(browser()->window()->IsMinimized());
+ EXPECT_TRUE(browser2->window()->IsMinimized());
+ EXPECT_TRUE(browser3->window()->IsMinimized());
+
+ // Do not turn on startup session restore.
+}
+
+IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS,
+ RestoreSessionWindowsAfterCrash) {
+ // By default, there will be one browser window opened.
+ ASSERT_EQ(1u, BrowserList::GetInstance()->size());
+ Browser* default_browser = BrowserList::GetInstance()->GetLastActive();
+
+ content::WindowedNotificationObserver close_observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::Source<Browser>(default_browser));
+ // |default_browser| will be closed before session restore of last session.
+ SessionRestore::RestoreSessionAfterCrash(default_browser);
+ close_observer.Wait();
+
+ size_t total_count = 0;
+ size_t minimized_count = 0;
+ for (auto* browser : *BrowserList::GetInstance()) {
+ ++total_count;
+ if (browser->window()->IsMinimized())
+ ++minimized_count;
+ }
+ EXPECT_EQ(3u, total_count);
+ EXPECT_EQ(2u, minimized_count);
+}
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/ui/views/session_crashed_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698