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

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

Issue 1662783002: Remove HostDesktopType from Browser::CreateParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-12
Patch Set: remove desktop_type_ in bookmark_bubble_sign_in_delegate Created 4 years, 10 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
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 <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 CloseBrowserSynchronously(*iter); 52 CloseBrowserSynchronously(*iter);
53 browser_list_.erase(iter); 53 browser_list_.erase(iter);
54 return true; 54 return true;
55 } 55 }
56 } 56 }
57 return false; 57 return false;
58 } 58 }
59 59
60 Browser::CreateParams CreateParamsForApp(const std::string name, 60 Browser::CreateParams CreateParamsForApp(const std::string name,
61 bool trusted) { 61 bool trusted) {
62 return Browser::CreateParams::CreateForApp( 62 return Browser::CreateParams::CreateForApp(name, trusted, gfx::Rect(),
63 name, trusted, gfx::Rect(), profile(), chrome::GetActiveDesktop()); 63 profile());
64 } 64 }
65 65
66 // Turn on session restore before we restart. 66 // Turn on session restore before we restart.
67 void TurnOnSessionRestore() { 67 void TurnOnSessionRestore() {
68 SessionStartupPref::SetStartupPref( 68 SessionStartupPref::SetStartupPref(
69 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); 69 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
70 } 70 }
71 71
72 Profile* profile() { return browser()->profile(); } 72 Profile* profile() { return browser()->profile(); }
73 73
74 std::list<Browser*> browser_list_; 74 std::list<Browser*> browser_list_;
75 }; 75 };
76 76
77 // Thse tests are in pairs. The PRE_ test creates some browser windows and 77 // Thse tests are in pairs. The PRE_ test creates some browser windows and
78 // the following test confirms that the correct windows are restored after a 78 // the following test confirms that the correct windows are restored after a
79 // restart. 79 // restart.
80 80
81 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreBrowserWindows) { 81 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreBrowserWindows) {
82 // One browser window is always created by default. 82 // One browser window is always created by default.
83 EXPECT_TRUE(browser()); 83 EXPECT_TRUE(browser());
84 // Create a second normal browser window. 84 // Create a second normal browser window.
85 CreateBrowserWithParams(Browser::CreateParams(profile()));
86 // Create a third incognito browser window which should not get restored.
85 CreateBrowserWithParams( 87 CreateBrowserWithParams(
86 Browser::CreateParams(profile(), chrome::GetActiveDesktop())); 88 Browser::CreateParams(profile()->GetOffTheRecordProfile()));
87 // Create a third incognito browser window which should not get restored.
88 CreateBrowserWithParams(Browser::CreateParams(
89 profile()->GetOffTheRecordProfile(), chrome::GetActiveDesktop()));
90 TurnOnSessionRestore(); 89 TurnOnSessionRestore();
91 } 90 }
92 91
93 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreBrowserWindows) { 92 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreBrowserWindows) {
94 size_t total_count = 0; 93 size_t total_count = 0;
95 size_t incognito_count = 0; 94 size_t incognito_count = 0;
96 for (auto* browser : *BrowserList::GetInstance()) { 95 for (auto* browser : *BrowserList::GetInstance()) {
97 ++total_count; 96 ++total_count;
98 if (browser->profile()->IsOffTheRecord()) 97 if (browser->profile()->IsOffTheRecord())
99 ++incognito_count; 98 ++incognito_count;
(...skipping 27 matching lines...) Expand all
127 } 126 }
128 EXPECT_EQ(1u, app1_count); 127 EXPECT_EQ(1u, app1_count);
129 EXPECT_EQ(2u, app2_count); // Only the trusted app windows are restored. 128 EXPECT_EQ(2u, app2_count); // Only the trusted app windows are restored.
130 EXPECT_EQ(4u, total_count); // Default browser() + 3 app windows 129 EXPECT_EQ(4u, total_count); // Default browser() + 3 app windows
131 } 130 }
132 131
133 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMaximized) { 132 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMaximized) {
134 // One browser window is always created by default. 133 // One browser window is always created by default.
135 ASSERT_TRUE(browser()); 134 ASSERT_TRUE(browser());
136 // Create a second browser window and maximize it. 135 // Create a second browser window and maximize it.
137 Browser* browser2 = CreateBrowserWithParams( 136 Browser* browser2 = CreateBrowserWithParams(Browser::CreateParams(profile()));
138 Browser::CreateParams(profile(), chrome::GetActiveDesktop()));
139 browser2->window()->Maximize(); 137 browser2->window()->Maximize();
140 138
141 // Create two app popup windows and maximize the second one. 139 // Create two app popup windows and maximize the second one.
142 Browser* app_browser1 = 140 Browser* app_browser1 =
143 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true)); 141 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true));
144 Browser* app_browser2 = 142 Browser* app_browser2 =
145 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true)); 143 CreateBrowserWithParams(CreateParamsForApp(test_app_popup_name1, true));
146 app_browser2->window()->Maximize(); 144 app_browser2->window()->Maximize();
147 145
148 EXPECT_FALSE(browser()->window()->IsMaximized()); 146 EXPECT_FALSE(browser()->window()->IsMaximized());
149 EXPECT_TRUE(browser2->window()->IsMaximized()); 147 EXPECT_TRUE(browser2->window()->IsMaximized());
150 EXPECT_FALSE(app_browser1->window()->IsMaximized()); 148 EXPECT_FALSE(app_browser1->window()->IsMaximized());
151 EXPECT_TRUE(app_browser2->window()->IsMaximized()); 149 EXPECT_TRUE(app_browser2->window()->IsMaximized());
152 150
153 TurnOnSessionRestore(); 151 TurnOnSessionRestore();
154 } 152 }
155 153
156 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMaximized) { 154 IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMaximized) {
157 size_t total_count = 0; 155 size_t total_count = 0;
158 size_t maximized_count = 0; 156 size_t maximized_count = 0;
159 for (auto* browser : *BrowserList::GetInstance()) { 157 for (auto* browser : *BrowserList::GetInstance()) {
160 ++total_count; 158 ++total_count;
161 if (browser->window()->IsMaximized()) 159 if (browser->window()->IsMaximized())
162 ++maximized_count; 160 ++maximized_count;
163 } 161 }
164 EXPECT_EQ(4u, total_count); 162 EXPECT_EQ(4u, total_count);
165 EXPECT_EQ(2u, maximized_count); 163 EXPECT_EQ(2u, maximized_count);
166 } 164 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698