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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/test/ash_test_base.h" | 6 #include "ash/test/ash_test_base.h" |
7 #include "ash/test/test_session_state_delegate.h" | 7 #include "ash/test/test_session_state_delegate.h" |
8 #include "ash/test/test_shell_delegate.h" | 8 #include "ash/test/test_shell_delegate.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" | 12 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
15 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 15 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
17 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 17 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
18 #include "components/signin/core/account_id/account_id.h" | |
19 #include "ui/aura/test/test_windows.h" | 18 #include "ui/aura/test/test_windows.h" |
20 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
21 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
22 | 21 |
23 namespace chromeos { | 22 namespace chromeos { |
24 namespace { | 23 namespace { |
25 | 24 |
26 const char kTestAccount1[] = "user1@test.com"; | 25 const char kTestAccount1[] = "user1@test.com"; |
27 const char kTestAccount2[] = "user2@test.com"; | 26 const char kTestAccount2[] = "user2@test.com"; |
28 | 27 |
29 class WallpaperPrivateApiUnittest : public ash::test::AshTestBase { | 28 class WallpaperPrivateApiUnittest : public ash::test::AshTestBase { |
30 public: | 29 public: |
31 WallpaperPrivateApiUnittest() | 30 WallpaperPrivateApiUnittest() |
32 : fake_user_manager_(new FakeChromeUserManager()), | 31 : fake_user_manager_(new FakeChromeUserManager()), |
33 scoped_user_manager_(fake_user_manager_) {} | 32 scoped_user_manager_(fake_user_manager_) {} |
34 | 33 |
35 protected: | 34 protected: |
36 FakeChromeUserManager* fake_user_manager() { return fake_user_manager_; } | 35 FakeChromeUserManager* fake_user_manager() { return fake_user_manager_; } |
37 | 36 |
38 const AccountId test_account_id1_ = AccountId::FromUserEmail(kTestAccount1); | |
39 const AccountId test_account_id2_ = AccountId::FromUserEmail(kTestAccount2); | |
40 | |
41 private: | 37 private: |
42 FakeChromeUserManager* fake_user_manager_; | 38 FakeChromeUserManager* fake_user_manager_; |
43 ScopedUserManagerEnabler scoped_user_manager_; | 39 ScopedUserManagerEnabler scoped_user_manager_; |
44 | 40 |
45 DISALLOW_COPY_AND_ASSIGN(WallpaperPrivateApiUnittest); | 41 DISALLOW_COPY_AND_ASSIGN(WallpaperPrivateApiUnittest); |
46 }; | 42 }; |
47 | 43 |
48 class TestMinimizeFunction | 44 class TestMinimizeFunction |
49 : public WallpaperPrivateMinimizeInactiveWindowsFunction { | 45 : public WallpaperPrivateMinimizeInactiveWindowsFunction { |
50 public: | 46 public: |
(...skipping 15 matching lines...) Expand all Loading... |
66 bool RunAsync() override { | 62 bool RunAsync() override { |
67 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync(); | 63 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync(); |
68 } | 64 } |
69 protected: | 65 protected: |
70 ~TestRestoreFunction() override {} | 66 ~TestRestoreFunction() override {} |
71 }; | 67 }; |
72 | 68 |
73 } // namespace | 69 } // namespace |
74 | 70 |
75 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { | 71 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { |
76 fake_user_manager()->AddUser(test_account_id1_); | 72 fake_user_manager()->AddUser(kTestAccount1); |
77 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); | 73 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
78 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 74 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
79 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 75 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
80 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 76 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
81 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 77 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
82 | 78 |
83 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 79 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
84 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 80 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
85 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 81 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
86 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 82 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_TRUE(window3_state->IsMinimized()); | 125 EXPECT_TRUE(window3_state->IsMinimized()); |
130 EXPECT_TRUE(window4_state->IsMinimized()); | 126 EXPECT_TRUE(window4_state->IsMinimized()); |
131 } | 127 } |
132 | 128 |
133 // Test for multiple calls to |MinimizeInactiveWindows| before call | 129 // Test for multiple calls to |MinimizeInactiveWindows| before call |
134 // |RestoreWindows|: | 130 // |RestoreWindows|: |
135 // 1. If all window hasn't change their states, the following calls are noops. | 131 // 1. If all window hasn't change their states, the following calls are noops. |
136 // 2. If some windows are manually unminimized, the following call will minimize | 132 // 2. If some windows are manually unminimized, the following call will minimize |
137 // all the unminimized windows. | 133 // all the unminimized windows. |
138 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { | 134 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { |
139 fake_user_manager()->AddUser(test_account_id1_); | 135 fake_user_manager()->AddUser(kTestAccount1); |
140 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 136 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
141 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 137 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
142 | 138 |
143 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 139 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
144 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 140 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
145 | 141 |
146 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 142 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
147 // function. | 143 // function. |
148 window0_state->Activate(); | 144 window0_state->Activate(); |
149 EXPECT_TRUE(window0_state->IsActive()); | 145 EXPECT_TRUE(window0_state->IsActive()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 public: | 189 public: |
194 WallpaperPrivateApiMultiUserUnittest() | 190 WallpaperPrivateApiMultiUserUnittest() |
195 : multi_user_window_manager_(NULL), | 191 : multi_user_window_manager_(NULL), |
196 session_state_delegate_(NULL) {} | 192 session_state_delegate_(NULL) {} |
197 | 193 |
198 void SetUp() override; | 194 void SetUp() override; |
199 void TearDown() override; | 195 void TearDown() override; |
200 | 196 |
201 protected: | 197 protected: |
202 void SetUpMultiUserWindowManager( | 198 void SetUpMultiUserWindowManager( |
203 const AccountId& active_account_id, | 199 const std::string& active_user_id, |
204 chrome::MultiUserWindowManager::MultiProfileMode mode); | 200 chrome::MultiUserWindowManager::MultiProfileMode mode); |
205 | 201 |
206 void SwitchActiveUser(const AccountId& active_account_id); | 202 void SwitchActiveUser(const std::string& active_user_id); |
207 | 203 |
208 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager() { | 204 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager() { |
209 return multi_user_window_manager_; | 205 return multi_user_window_manager_; |
210 } | 206 } |
211 | 207 |
212 private: | 208 private: |
213 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; | 209 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; |
214 ash::test::TestSessionStateDelegate* session_state_delegate_; | 210 ash::test::TestSessionStateDelegate* session_state_delegate_; |
215 | 211 |
216 DISALLOW_COPY_AND_ASSIGN(WallpaperPrivateApiMultiUserUnittest); | 212 DISALLOW_COPY_AND_ASSIGN(WallpaperPrivateApiMultiUserUnittest); |
217 }; | 213 }; |
218 | 214 |
219 void WallpaperPrivateApiMultiUserUnittest::SetUp() { | 215 void WallpaperPrivateApiMultiUserUnittest::SetUp() { |
220 AshTestBase::SetUp(); | 216 AshTestBase::SetUp(); |
221 WallpaperManager::Initialize(); | 217 WallpaperManager::Initialize(); |
222 session_state_delegate_ = | 218 session_state_delegate_ = |
223 static_cast<ash::test::TestSessionStateDelegate*> ( | 219 static_cast<ash::test::TestSessionStateDelegate*> ( |
224 ash::Shell::GetInstance()->session_state_delegate()); | 220 ash::Shell::GetInstance()->session_state_delegate()); |
225 fake_user_manager()->AddUser(test_account_id1_); | 221 fake_user_manager()->AddUser(kTestAccount1); |
226 fake_user_manager()->AddUser(test_account_id2_); | 222 fake_user_manager()->AddUser(kTestAccount2); |
227 } | 223 } |
228 | 224 |
229 void WallpaperPrivateApiMultiUserUnittest::TearDown() { | 225 void WallpaperPrivateApiMultiUserUnittest::TearDown() { |
230 chrome::MultiUserWindowManager::DeleteInstance(); | 226 chrome::MultiUserWindowManager::DeleteInstance(); |
231 AshTestBase::TearDown(); | 227 AshTestBase::TearDown(); |
232 WallpaperManager::Shutdown(); | 228 WallpaperManager::Shutdown(); |
233 } | 229 } |
234 | 230 |
235 void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( | 231 void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( |
236 const AccountId& active_account_id, | 232 const std::string& active_user_id, |
237 chrome::MultiUserWindowManager::MultiProfileMode mode) { | 233 chrome::MultiUserWindowManager::MultiProfileMode mode) { |
238 multi_user_window_manager_ = new chrome::MultiUserWindowManagerChromeOS( | 234 multi_user_window_manager_ = |
239 active_account_id.GetUserEmail()); | 235 new chrome::MultiUserWindowManagerChromeOS(active_user_id); |
240 multi_user_window_manager_->Init(); | 236 multi_user_window_manager_->Init(); |
241 chrome::MultiUserWindowManager::SetInstanceForTest( | 237 chrome::MultiUserWindowManager::SetInstanceForTest( |
242 multi_user_window_manager_, mode); | 238 multi_user_window_manager_, mode); |
243 // We do not want animations while the test is going on. | 239 // We do not want animations while the test is going on. |
244 multi_user_window_manager_->SetAnimationSpeedForTest( | 240 multi_user_window_manager_->SetAnimationSpeedForTest( |
245 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 241 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
246 EXPECT_TRUE(multi_user_window_manager_); | 242 EXPECT_TRUE(multi_user_window_manager_); |
247 } | 243 } |
248 | 244 |
249 void WallpaperPrivateApiMultiUserUnittest::SwitchActiveUser( | 245 void WallpaperPrivateApiMultiUserUnittest::SwitchActiveUser( |
250 const AccountId& active_account_id) { | 246 const std::string& active_user_id) { |
251 fake_user_manager()->SwitchActiveUser(active_account_id); | 247 fake_user_manager()->SwitchActiveUser(active_user_id); |
252 multi_user_window_manager_->ActiveUserChanged( | 248 multi_user_window_manager_->ActiveUserChanged(active_user_id); |
253 active_account_id.GetUserEmail()); | |
254 } | 249 } |
255 | 250 |
256 // In multi profile mode, user may open wallpaper picker in one profile and | 251 // In multi profile mode, user may open wallpaper picker in one profile and |
257 // then switch to a different profile and open another wallpaper picker | 252 // then switch to a different profile and open another wallpaper picker |
258 // without closing the first one. | 253 // without closing the first one. |
259 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { | 254 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
260 SetUpMultiUserWindowManager( | 255 SetUpMultiUserWindowManager(kTestAccount1, |
261 test_account_id1_, | |
262 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); | 256 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); |
263 | 257 |
264 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); | 258 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
265 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 259 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
266 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 260 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
267 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 261 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
268 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 262 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
269 | 263 |
270 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 264 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
271 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 265 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
272 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 266 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
273 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 267 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
274 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); | 268 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); |
275 | 269 |
276 multi_user_window_manager()->SetWindowOwner(window0.get(), | 270 multi_user_window_manager()->SetWindowOwner(window0.get(), kTestAccount1); |
277 test_account_id1_.GetUserEmail()); | 271 multi_user_window_manager()->SetWindowOwner(window1.get(), kTestAccount1); |
278 multi_user_window_manager()->SetWindowOwner(window1.get(), | |
279 test_account_id1_.GetUserEmail()); | |
280 | 272 |
281 // Set some windows to an inactive owner. | 273 // Set some windows to an inactive owner. |
282 multi_user_window_manager()->SetWindowOwner(window2.get(), | 274 multi_user_window_manager()->SetWindowOwner(window2.get(), kTestAccount2); |
283 test_account_id2_.GetUserEmail()); | 275 multi_user_window_manager()->SetWindowOwner(window3.get(), kTestAccount2); |
284 multi_user_window_manager()->SetWindowOwner(window3.get(), | 276 multi_user_window_manager()->SetWindowOwner(window4.get(), kTestAccount2); |
285 test_account_id2_.GetUserEmail()); | |
286 multi_user_window_manager()->SetWindowOwner(window4.get(), | |
287 test_account_id2_.GetUserEmail()); | |
288 | 277 |
289 EXPECT_FALSE(window0_state->IsMinimized()); | 278 EXPECT_FALSE(window0_state->IsMinimized()); |
290 EXPECT_FALSE(window1_state->IsMinimized()); | 279 EXPECT_FALSE(window1_state->IsMinimized()); |
291 EXPECT_FALSE(window2_state->IsMinimized()); | 280 EXPECT_FALSE(window2_state->IsMinimized()); |
292 EXPECT_FALSE(window3_state->IsMinimized()); | 281 EXPECT_FALSE(window3_state->IsMinimized()); |
293 EXPECT_FALSE(window4_state->IsMinimized()); | 282 EXPECT_FALSE(window4_state->IsMinimized()); |
294 | 283 |
295 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 284 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
296 // function. | 285 // function. |
297 window0_state->Activate(); | 286 window0_state->Activate(); |
298 EXPECT_TRUE(window0_state->IsActive()); | 287 EXPECT_TRUE(window0_state->IsActive()); |
299 scoped_refptr<TestMinimizeFunction> minimize_function_0( | 288 scoped_refptr<TestMinimizeFunction> minimize_function_0( |
300 new TestMinimizeFunction()); | 289 new TestMinimizeFunction()); |
301 EXPECT_TRUE(minimize_function_0->RunAsync()); | 290 EXPECT_TRUE(minimize_function_0->RunAsync()); |
302 | 291 |
303 // All windows except window 0 should be minimized. | 292 // All windows except window 0 should be minimized. |
304 EXPECT_FALSE(window0_state->IsMinimized()); | 293 EXPECT_FALSE(window0_state->IsMinimized()); |
305 EXPECT_TRUE(window1_state->IsMinimized()); | 294 EXPECT_TRUE(window1_state->IsMinimized()); |
306 | 295 |
307 // All windows that belong to inactive user should not be affected. | 296 // All windows that belong to inactive user should not be affected. |
308 EXPECT_FALSE(window2_state->IsMinimized()); | 297 EXPECT_FALSE(window2_state->IsMinimized()); |
309 EXPECT_FALSE(window3_state->IsMinimized()); | 298 EXPECT_FALSE(window3_state->IsMinimized()); |
310 EXPECT_FALSE(window4_state->IsMinimized()); | 299 EXPECT_FALSE(window4_state->IsMinimized()); |
311 | 300 |
312 // Activate kTestAccount2. kTestAccount1 becomes inactive user. | 301 // Activate kTestAccount2. kTestAccount1 becomes inactive user. |
313 SwitchActiveUser(test_account_id2_); | 302 SwitchActiveUser(kTestAccount2); |
314 | 303 |
315 window2_state->Activate(); | 304 window2_state->Activate(); |
316 EXPECT_TRUE(window2_state->IsActive()); | 305 EXPECT_TRUE(window2_state->IsActive()); |
317 scoped_refptr<TestMinimizeFunction> minimize_function_1( | 306 scoped_refptr<TestMinimizeFunction> minimize_function_1( |
318 new TestMinimizeFunction()); | 307 new TestMinimizeFunction()); |
319 EXPECT_TRUE(minimize_function_1->RunAsync()); | 308 EXPECT_TRUE(minimize_function_1->RunAsync()); |
320 | 309 |
321 // All windows except window 2 should be minimized. | 310 // All windows except window 2 should be minimized. |
322 EXPECT_FALSE(window2_state->IsMinimized()); | 311 EXPECT_FALSE(window2_state->IsMinimized()); |
323 EXPECT_TRUE(window3_state->IsMinimized()); | 312 EXPECT_TRUE(window3_state->IsMinimized()); |
(...skipping 17 matching lines...) Expand all Loading... |
341 scoped_refptr<TestRestoreFunction> restore_function_0( | 330 scoped_refptr<TestRestoreFunction> restore_function_0( |
342 new TestRestoreFunction()); | 331 new TestRestoreFunction()); |
343 EXPECT_TRUE(restore_function_0->RunAsync()); | 332 EXPECT_TRUE(restore_function_0->RunAsync()); |
344 | 333 |
345 EXPECT_FALSE(window3_state->IsMinimized()); | 334 EXPECT_FALSE(window3_state->IsMinimized()); |
346 | 335 |
347 // All windows that belong to inactive user should not be affected. | 336 // All windows that belong to inactive user should not be affected. |
348 EXPECT_FALSE(window0_state->IsMinimized()); | 337 EXPECT_FALSE(window0_state->IsMinimized()); |
349 EXPECT_TRUE(window1_state->IsMinimized()); | 338 EXPECT_TRUE(window1_state->IsMinimized()); |
350 | 339 |
351 SwitchActiveUser(test_account_id1_); | 340 SwitchActiveUser(kTestAccount1); |
352 | 341 |
353 // Then we destroy window 0 and call the restore function. | 342 // Then we destroy window 0 and call the restore function. |
354 window0.reset(); | 343 window0.reset(); |
355 scoped_refptr<TestRestoreFunction> restore_function_1( | 344 scoped_refptr<TestRestoreFunction> restore_function_1( |
356 new TestRestoreFunction()); | 345 new TestRestoreFunction()); |
357 EXPECT_TRUE(restore_function_1->RunAsync()); | 346 EXPECT_TRUE(restore_function_1->RunAsync()); |
358 | 347 |
359 EXPECT_FALSE(window1_state->IsMinimized()); | 348 EXPECT_FALSE(window1_state->IsMinimized()); |
360 EXPECT_FALSE(window3_state->IsMinimized()); | 349 EXPECT_FALSE(window3_state->IsMinimized()); |
361 } | 350 } |
362 | 351 |
363 // In multi profile mode, user may teleport windows. Teleported window should | 352 // In multi profile mode, user may teleport windows. Teleported window should |
364 // also be minimized when open wallpaper picker. | 353 // also be minimized when open wallpaper picker. |
365 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { | 354 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { |
366 SetUpMultiUserWindowManager( | 355 SetUpMultiUserWindowManager(kTestAccount1, |
367 AccountId::FromUserEmail(kTestAccount1), | |
368 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED); | 356 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED); |
369 | 357 |
370 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 358 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
371 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 359 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
372 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 360 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
373 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 361 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
374 | 362 |
375 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 363 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
376 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 364 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
377 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 365 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
378 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 366 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
379 | 367 |
380 multi_user_window_manager()->SetWindowOwner(window0.get(), | 368 multi_user_window_manager()->SetWindowOwner(window0.get(), kTestAccount1); |
381 test_account_id1_.GetUserEmail()); | 369 multi_user_window_manager()->SetWindowOwner(window1.get(), kTestAccount1); |
382 multi_user_window_manager()->SetWindowOwner(window1.get(), | |
383 test_account_id1_.GetUserEmail()); | |
384 | 370 |
385 // Set some windows to an inactive owner. | 371 // Set some windows to an inactive owner. |
386 multi_user_window_manager()->SetWindowOwner(window2.get(), | 372 multi_user_window_manager()->SetWindowOwner(window2.get(), kTestAccount2); |
387 test_account_id2_.GetUserEmail()); | 373 multi_user_window_manager()->SetWindowOwner(window3.get(), kTestAccount2); |
388 multi_user_window_manager()->SetWindowOwner(window3.get(), | |
389 test_account_id2_.GetUserEmail()); | |
390 | 374 |
391 // Teleport window2 to kTestAccount1. | 375 // Teleport window2 to kTestAccount1. |
392 multi_user_window_manager()->ShowWindowForUser( | 376 multi_user_window_manager()->ShowWindowForUser(window2.get(), kTestAccount1); |
393 window2.get(), test_account_id1_.GetUserEmail()); | |
394 | 377 |
395 // Initial window state. All windows shouldn't be minimized. | 378 // Initial window state. All windows shouldn't be minimized. |
396 EXPECT_FALSE(window0_state->IsMinimized()); | 379 EXPECT_FALSE(window0_state->IsMinimized()); |
397 EXPECT_FALSE(window1_state->IsMinimized()); | 380 EXPECT_FALSE(window1_state->IsMinimized()); |
398 EXPECT_FALSE(window2_state->IsMinimized()); | 381 EXPECT_FALSE(window2_state->IsMinimized()); |
399 EXPECT_FALSE(window3_state->IsMinimized()); | 382 EXPECT_FALSE(window3_state->IsMinimized()); |
400 | 383 |
401 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 384 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
402 // function. | 385 // function. |
403 window0_state->Activate(); | 386 window0_state->Activate(); |
(...skipping 16 matching lines...) Expand all Loading... |
420 scoped_refptr<TestRestoreFunction> restore_function_1( | 403 scoped_refptr<TestRestoreFunction> restore_function_1( |
421 new TestRestoreFunction()); | 404 new TestRestoreFunction()); |
422 EXPECT_TRUE(restore_function_1->RunAsync()); | 405 EXPECT_TRUE(restore_function_1->RunAsync()); |
423 | 406 |
424 EXPECT_FALSE(window1_state->IsMinimized()); | 407 EXPECT_FALSE(window1_state->IsMinimized()); |
425 EXPECT_FALSE(window2_state->IsMinimized()); | 408 EXPECT_FALSE(window2_state->IsMinimized()); |
426 EXPECT_FALSE(window3_state->IsMinimized()); | 409 EXPECT_FALSE(window3_state->IsMinimized()); |
427 } | 410 } |
428 | 411 |
429 } // namespace chromeos | 412 } // namespace chromeos |
OLD | NEW |