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" | |
22 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
23 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 22 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
24 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
25 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
26 #include "ui/wm/core/wm_core_switches.h" | |
27 | 25 |
28 namespace { | 26 namespace { |
29 const char* test_app_popup_name1 = "TestApp1"; | 27 const char* test_app_popup_name1 = "TestApp1"; |
30 const char* test_app_popup_name2 = "TestApp2"; | 28 const char* test_app_popup_name2 = "TestApp2"; |
31 } | 29 } |
32 | 30 |
33 class SessionRestoreTestChromeOS : public InProcessBrowserTest { | 31 class SessionRestoreTestChromeOS : public InProcessBrowserTest { |
34 public: | 32 public: |
35 ~SessionRestoreTestChromeOS() override {} | 33 ~SessionRestoreTestChromeOS() override {} |
36 | 34 |
37 protected: | 35 protected: |
38 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { | 36 void SetUpCommandLine(base::CommandLine* command_line) override { |
39 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); | 37 InProcessBrowserTest::SetUpCommandLine(command_line); |
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); | |
48 } | 38 } |
49 | 39 |
50 Browser* CreateBrowserWithParams(Browser::CreateParams params) { | 40 Browser* CreateBrowserWithParams(Browser::CreateParams params) { |
51 Browser* browser = new Browser(params); | 41 Browser* browser = new Browser(params); |
52 AddBlankTabAndShow(browser); | 42 AddBlankTabAndShow(browser); |
53 browser_list_.push_back(browser); | 43 browser_list_.push_back(browser); |
54 return browser; | 44 return browser; |
55 } | 45 } |
56 | 46 |
57 bool CloseBrowser(Browser* browser) { | 47 bool CloseBrowser(Browser* browser) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 size_t total_count = 0; | 154 size_t total_count = 0; |
165 size_t maximized_count = 0; | 155 size_t maximized_count = 0; |
166 for (auto* browser : *BrowserList::GetInstance()) { | 156 for (auto* browser : *BrowserList::GetInstance()) { |
167 ++total_count; | 157 ++total_count; |
168 if (browser->window()->IsMaximized()) | 158 if (browser->window()->IsMaximized()) |
169 ++maximized_count; | 159 ++maximized_count; |
170 } | 160 } |
171 EXPECT_EQ(4u, total_count); | 161 EXPECT_EQ(4u, total_count); |
172 EXPECT_EQ(2u, maximized_count); | 162 EXPECT_EQ(2u, maximized_count); |
173 } | 163 } |
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 |