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 "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/defaults.h" | 14 #include "chrome/browser/defaults.h" |
15 #include "chrome/browser/prefs/session_startup_pref.h" | 15 #include "chrome/browser/prefs/session_startup_pref.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_iterator.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/host_desktop.h" | 19 #include "chrome/browser/ui/host_desktop.h" |
20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 23 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
26 | 26 |
27 namespace { | 27 namespace { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Browser::CreateParams(profile(), chrome::GetActiveDesktop())); | 86 Browser::CreateParams(profile(), chrome::GetActiveDesktop())); |
87 // Create a third incognito browser window which should not get restored. | 87 // Create a third incognito browser window which should not get restored. |
88 CreateBrowserWithParams(Browser::CreateParams( | 88 CreateBrowserWithParams(Browser::CreateParams( |
89 profile()->GetOffTheRecordProfile(), chrome::GetActiveDesktop())); | 89 profile()->GetOffTheRecordProfile(), chrome::GetActiveDesktop())); |
90 TurnOnSessionRestore(); | 90 TurnOnSessionRestore(); |
91 } | 91 } |
92 | 92 |
93 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreBrowserWindows) { | 93 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreBrowserWindows) { |
94 size_t total_count = 0; | 94 size_t total_count = 0; |
95 size_t incognito_count = 0; | 95 size_t incognito_count = 0; |
96 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 96 for (auto* browser : *BrowserList::GetInstance()) { |
97 ++total_count; | 97 ++total_count; |
98 if (it->profile()->IsOffTheRecord()) | 98 if (browser->profile()->IsOffTheRecord()) |
99 ++incognito_count; | 99 ++incognito_count; |
100 } | 100 } |
101 EXPECT_EQ(2u, total_count); | 101 EXPECT_EQ(2u, total_count); |
102 EXPECT_EQ(0u, incognito_count); | 102 EXPECT_EQ(0u, incognito_count); |
103 } | 103 } |
104 | 104 |
105 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreAppsV1) { | 105 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreAppsV1) { |
106 // Create a trusted app popup. | 106 // Create a trusted app popup. |
107 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true)); | 107 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true)); |
108 // Create a second trusted app with two popup windows. | 108 // Create a second trusted app with two popup windows. |
109 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, true)); | 109 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, true)); |
110 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, true)); | 110 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, true)); |
111 // Create a third untrusted (child) app3 popup. This should not get restored. | 111 // Create a third untrusted (child) app3 popup. This should not get restored. |
112 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, false)); | 112 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name2, false)); |
113 | 113 |
114 TurnOnSessionRestore(); | 114 TurnOnSessionRestore(); |
115 } | 115 } |
116 | 116 |
117 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreAppsV1) { | 117 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreAppsV1) { |
118 size_t total_count = 0; | 118 size_t total_count = 0; |
119 size_t app1_count = 0; | 119 size_t app1_count = 0; |
120 size_t app2_count = 0; | 120 size_t app2_count = 0; |
121 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 121 for (auto* browser : *BrowserList::GetInstance()) { |
122 ++total_count; | 122 ++total_count; |
123 if (it->app_name() == test_app_popup_name1) | 123 if (browser->app_name() == test_app_popup_name1) |
124 ++app1_count; | 124 ++app1_count; |
125 if (it->app_name() == test_app_popup_name2) | 125 if (browser->app_name() == test_app_popup_name2) |
126 ++app2_count; | 126 ++app2_count; |
127 } | 127 } |
128 EXPECT_EQ(1u, app1_count); | 128 EXPECT_EQ(1u, app1_count); |
129 EXPECT_EQ(2u, app2_count); // Only the trusted app windows are restored. | 129 EXPECT_EQ(2u, app2_count); // Only the trusted app windows are restored. |
130 EXPECT_EQ(4u, total_count); // Default browser() + 3 app windows | 130 EXPECT_EQ(4u, total_count); // Default browser() + 3 app windows |
131 } | 131 } |
132 | 132 |
133 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMaximized) { | 133 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMaximized) { |
134 // One browser window is always created by default. | 134 // One browser window is always created by default. |
135 ASSERT_TRUE(browser()); | 135 ASSERT_TRUE(browser()); |
(...skipping 13 matching lines...) Expand all Loading... |
149 EXPECT_TRUE(browser2->window()->IsMaximized()); | 149 EXPECT_TRUE(browser2->window()->IsMaximized()); |
150 EXPECT_FALSE(app_browser1->window()->IsMaximized()); | 150 EXPECT_FALSE(app_browser1->window()->IsMaximized()); |
151 EXPECT_TRUE(app_browser2->window()->IsMaximized()); | 151 EXPECT_TRUE(app_browser2->window()->IsMaximized()); |
152 | 152 |
153 TurnOnSessionRestore(); | 153 TurnOnSessionRestore(); |
154 } | 154 } |
155 | 155 |
156 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMaximized) { | 156 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMaximized) { |
157 size_t total_count = 0; | 157 size_t total_count = 0; |
158 size_t maximized_count = 0; | 158 size_t maximized_count = 0; |
159 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 159 for (auto* browser : *BrowserList::GetInstance()) { |
160 ++total_count; | 160 ++total_count; |
161 if (it->window()->IsMaximized()) | 161 if (browser->window()->IsMaximized()) |
162 ++maximized_count; | 162 ++maximized_count; |
163 } | 163 } |
164 EXPECT_EQ(4u, total_count); | 164 EXPECT_EQ(4u, total_count); |
165 EXPECT_EQ(2u, maximized_count); | 165 EXPECT_EQ(2u, maximized_count); |
166 } | 166 } |
OLD | NEW |