OLD | NEW |
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 <list> | 7 #include <list> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/defaults.h" | 13 #include "chrome/browser/defaults.h" |
14 #include "chrome/browser/prefs/session_startup_pref.h" | 14 #include "chrome/browser/prefs/session_startup_pref.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/test_launcher_utils.h" |
21 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
22 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 23 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 26 #include "ui/wm/core/wm_core_switches.h" |
25 | 27 |
26 namespace { | 28 namespace { |
27 const char* test_app_popup_name1 = "TestApp1"; | 29 const char* test_app_popup_name1 = "TestApp1"; |
28 const char* test_app_popup_name2 = "TestApp2"; | 30 const char* test_app_popup_name2 = "TestApp2"; |
29 } | 31 } |
30 | 32 |
31 class SessionRestoreTestChromeOS : public InProcessBrowserTest { | 33 class SessionRestoreTestChromeOS : public InProcessBrowserTest { |
32 public: | 34 public: |
33 ~SessionRestoreTestChromeOS() override {} | 35 ~SessionRestoreTestChromeOS() override {} |
34 | 36 |
35 protected: | 37 protected: |
36 void SetUpCommandLine(base::CommandLine* command_line) override { | 38 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { |
37 InProcessBrowserTest::SetUpCommandLine(command_line); | 39 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); |
| 40 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); |
| 41 |
| 42 // Animations have caused crashes in session restore in the past but are |
| 43 // usually disabled in tests. Remove --wm-window-animations-disabled to |
| 44 // re-enable animations. |
| 45 test_launcher_utils::RemoveCommandLineSwitch( |
| 46 default_command_line, wm::switches::kWindowAnimationsDisabled, |
| 47 command_line); |
38 } | 48 } |
39 | 49 |
40 Browser* CreateBrowserWithParams(Browser::CreateParams params) { | 50 Browser* CreateBrowserWithParams(Browser::CreateParams params) { |
41 Browser* browser = new Browser(params); | 51 Browser* browser = new Browser(params); |
42 AddBlankTabAndShow(browser); | 52 AddBlankTabAndShow(browser); |
43 browser_list_.push_back(browser); | 53 browser_list_.push_back(browser); |
44 return browser; | 54 return browser; |
45 } | 55 } |
46 | 56 |
47 bool CloseBrowser(Browser* browser) { | 57 bool CloseBrowser(Browser* browser) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 size_t total_count = 0; | 164 size_t total_count = 0; |
155 size_t maximized_count = 0; | 165 size_t maximized_count = 0; |
156 for (auto* browser : *BrowserList::GetInstance()) { | 166 for (auto* browser : *BrowserList::GetInstance()) { |
157 ++total_count; | 167 ++total_count; |
158 if (browser->window()->IsMaximized()) | 168 if (browser->window()->IsMaximized()) |
159 ++maximized_count; | 169 ++maximized_count; |
160 } | 170 } |
161 EXPECT_EQ(4u, total_count); | 171 EXPECT_EQ(4u, total_count); |
162 EXPECT_EQ(2u, maximized_count); | 172 EXPECT_EQ(2u, maximized_count); |
163 } | 173 } |
| 174 |
| 175 // Test for crash when restoring minimized windows. http://crbug.com/679513. |
| 176 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMinimized) { |
| 177 // One browser window is always created by default. |
| 178 ASSERT_TRUE(browser()); |
| 179 browser()->window()->Minimize(); |
| 180 |
| 181 Browser* browser2 = CreateBrowserWithParams(Browser::CreateParams(profile())); |
| 182 browser2->window()->Minimize(); |
| 183 |
| 184 EXPECT_TRUE(browser()->window()->IsMinimized()); |
| 185 EXPECT_TRUE(browser2->window()->IsMinimized()); |
| 186 |
| 187 TurnOnSessionRestore(); |
| 188 } |
| 189 |
| 190 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMinimized) { |
| 191 size_t total_count = 0; |
| 192 size_t minimized_count = 0; |
| 193 for (auto* browser : *BrowserList::GetInstance()) { |
| 194 ++total_count; |
| 195 if (browser->window()->IsMinimized()) |
| 196 ++minimized_count; |
| 197 } |
| 198 EXPECT_EQ(2u, total_count); |
| 199 // Chrome OS always activates the last browser window on login, which results |
| 200 // in one window being restored. This seems reasonable as it reminds users |
| 201 // they have a browser running instead of just showing them an empty desktop. |
| 202 EXPECT_EQ(1u, minimized_count); |
| 203 } |
OLD | NEW |