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" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 void WallpaperPrivateApiMultiUserUnittest::TearDown() { | 229 void WallpaperPrivateApiMultiUserUnittest::TearDown() { |
230 chrome::MultiUserWindowManager::DeleteInstance(); | 230 chrome::MultiUserWindowManager::DeleteInstance(); |
231 AshTestBase::TearDown(); | 231 AshTestBase::TearDown(); |
232 WallpaperManager::Shutdown(); | 232 WallpaperManager::Shutdown(); |
233 } | 233 } |
234 | 234 |
235 void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( | 235 void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( |
236 const AccountId& active_account_id, | 236 const AccountId& active_account_id, |
237 chrome::MultiUserWindowManager::MultiProfileMode mode) { | 237 chrome::MultiUserWindowManager::MultiProfileMode mode) { |
238 multi_user_window_manager_ = new chrome::MultiUserWindowManagerChromeOS( | 238 multi_user_window_manager_ = |
239 active_account_id.GetUserEmail()); | 239 new chrome::MultiUserWindowManagerChromeOS(active_account_id); |
240 multi_user_window_manager_->Init(); | 240 multi_user_window_manager_->Init(); |
241 chrome::MultiUserWindowManager::SetInstanceForTest( | 241 chrome::MultiUserWindowManager::SetInstanceForTest( |
242 multi_user_window_manager_, mode); | 242 multi_user_window_manager_, mode); |
243 // We do not want animations while the test is going on. | 243 // We do not want animations while the test is going on. |
244 multi_user_window_manager_->SetAnimationSpeedForTest( | 244 multi_user_window_manager_->SetAnimationSpeedForTest( |
245 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 245 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
246 EXPECT_TRUE(multi_user_window_manager_); | 246 EXPECT_TRUE(multi_user_window_manager_); |
247 } | 247 } |
248 | 248 |
249 void WallpaperPrivateApiMultiUserUnittest::SwitchActiveUser( | 249 void WallpaperPrivateApiMultiUserUnittest::SwitchActiveUser( |
250 const AccountId& active_account_id) { | 250 const AccountId& active_account_id) { |
251 fake_user_manager()->SwitchActiveUser(active_account_id); | 251 fake_user_manager()->SwitchActiveUser(active_account_id); |
252 multi_user_window_manager_->ActiveUserChanged( | 252 multi_user_window_manager_->ActiveUserChanged(active_account_id); |
253 active_account_id.GetUserEmail()); | |
254 } | 253 } |
255 | 254 |
256 // In multi profile mode, user may open wallpaper picker in one profile and | 255 // 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 | 256 // then switch to a different profile and open another wallpaper picker |
258 // without closing the first one. | 257 // without closing the first one. |
259 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { | 258 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
260 SetUpMultiUserWindowManager( | 259 SetUpMultiUserWindowManager( |
261 test_account_id1_, | 260 test_account_id1_, |
262 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); | 261 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); |
263 | 262 |
264 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); | 263 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
265 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 264 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
266 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 265 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
267 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 266 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
268 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 267 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
269 | 268 |
270 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 269 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
271 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 270 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
272 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 271 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
273 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 272 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
274 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); | 273 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); |
275 | 274 |
276 multi_user_window_manager()->SetWindowOwner(window0.get(), | 275 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); |
277 test_account_id1_.GetUserEmail()); | 276 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); |
278 multi_user_window_manager()->SetWindowOwner(window1.get(), | |
279 test_account_id1_.GetUserEmail()); | |
280 | 277 |
281 // Set some windows to an inactive owner. | 278 // Set some windows to an inactive owner. |
282 multi_user_window_manager()->SetWindowOwner(window2.get(), | 279 multi_user_window_manager()->SetWindowOwner(window2.get(), test_account_id2_); |
283 test_account_id2_.GetUserEmail()); | 280 multi_user_window_manager()->SetWindowOwner(window3.get(), test_account_id2_); |
284 multi_user_window_manager()->SetWindowOwner(window3.get(), | 281 multi_user_window_manager()->SetWindowOwner(window4.get(), test_account_id2_); |
285 test_account_id2_.GetUserEmail()); | |
286 multi_user_window_manager()->SetWindowOwner(window4.get(), | |
287 test_account_id2_.GetUserEmail()); | |
288 | 282 |
289 EXPECT_FALSE(window0_state->IsMinimized()); | 283 EXPECT_FALSE(window0_state->IsMinimized()); |
290 EXPECT_FALSE(window1_state->IsMinimized()); | 284 EXPECT_FALSE(window1_state->IsMinimized()); |
291 EXPECT_FALSE(window2_state->IsMinimized()); | 285 EXPECT_FALSE(window2_state->IsMinimized()); |
292 EXPECT_FALSE(window3_state->IsMinimized()); | 286 EXPECT_FALSE(window3_state->IsMinimized()); |
293 EXPECT_FALSE(window4_state->IsMinimized()); | 287 EXPECT_FALSE(window4_state->IsMinimized()); |
294 | 288 |
295 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 289 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
296 // function. | 290 // function. |
297 window0_state->Activate(); | 291 window0_state->Activate(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 364 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
371 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 365 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
372 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 366 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
373 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 367 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
374 | 368 |
375 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 369 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
376 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 370 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
377 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 371 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
378 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 372 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
379 | 373 |
380 multi_user_window_manager()->SetWindowOwner(window0.get(), | 374 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); |
381 test_account_id1_.GetUserEmail()); | 375 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); |
382 multi_user_window_manager()->SetWindowOwner(window1.get(), | |
383 test_account_id1_.GetUserEmail()); | |
384 | 376 |
385 // Set some windows to an inactive owner. | 377 // Set some windows to an inactive owner. |
386 multi_user_window_manager()->SetWindowOwner(window2.get(), | 378 multi_user_window_manager()->SetWindowOwner(window2.get(), test_account_id2_); |
387 test_account_id2_.GetUserEmail()); | 379 multi_user_window_manager()->SetWindowOwner(window3.get(), test_account_id2_); |
388 multi_user_window_manager()->SetWindowOwner(window3.get(), | |
389 test_account_id2_.GetUserEmail()); | |
390 | 380 |
391 // Teleport window2 to kTestAccount1. | 381 // Teleport window2 to kTestAccount1. |
392 multi_user_window_manager()->ShowWindowForUser( | 382 multi_user_window_manager()->ShowWindowForUser(window2.get(), |
393 window2.get(), test_account_id1_.GetUserEmail()); | 383 test_account_id1_); |
394 | 384 |
395 // Initial window state. All windows shouldn't be minimized. | 385 // Initial window state. All windows shouldn't be minimized. |
396 EXPECT_FALSE(window0_state->IsMinimized()); | 386 EXPECT_FALSE(window0_state->IsMinimized()); |
397 EXPECT_FALSE(window1_state->IsMinimized()); | 387 EXPECT_FALSE(window1_state->IsMinimized()); |
398 EXPECT_FALSE(window2_state->IsMinimized()); | 388 EXPECT_FALSE(window2_state->IsMinimized()); |
399 EXPECT_FALSE(window3_state->IsMinimized()); | 389 EXPECT_FALSE(window3_state->IsMinimized()); |
400 | 390 |
401 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 391 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
402 // function. | 392 // function. |
403 window0_state->Activate(); | 393 window0_state->Activate(); |
(...skipping 16 matching lines...) Expand all Loading... |
420 scoped_refptr<TestRestoreFunction> restore_function_1( | 410 scoped_refptr<TestRestoreFunction> restore_function_1( |
421 new TestRestoreFunction()); | 411 new TestRestoreFunction()); |
422 EXPECT_TRUE(restore_function_1->RunAsync()); | 412 EXPECT_TRUE(restore_function_1->RunAsync()); |
423 | 413 |
424 EXPECT_FALSE(window1_state->IsMinimized()); | 414 EXPECT_FALSE(window1_state->IsMinimized()); |
425 EXPECT_FALSE(window2_state->IsMinimized()); | 415 EXPECT_FALSE(window2_state->IsMinimized()); |
426 EXPECT_FALSE(window3_state->IsMinimized()); | 416 EXPECT_FALSE(window3_state->IsMinimized()); |
427 } | 417 } |
428 | 418 |
429 } // namespace chromeos | 419 } // namespace chromeos |
OLD | NEW |