| 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 "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 6 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 7 #include "ash/test/test_session_state_delegate.h" | 11 #include "ash/test/test_session_state_delegate.h" |
| 8 #include "ash/test/test_shell_delegate.h" | 12 #include "ash/test/test_shell_delegate.h" |
| 9 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 10 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 11 #include "base/macros.h" | 15 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" | |
| 14 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 17 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 19 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 20 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 19 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
| 20 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
| 21 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 23 | 25 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync(); | 70 return WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync(); |
| 69 } | 71 } |
| 70 protected: | 72 protected: |
| 71 ~TestRestoreFunction() override {} | 73 ~TestRestoreFunction() override {} |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 } // namespace | 76 } // namespace |
| 75 | 77 |
| 76 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { | 78 TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { |
| 77 fake_user_manager()->AddUser(test_account_id1_); | 79 fake_user_manager()->AddUser(test_account_id1_); |
| 78 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); | 80 std::unique_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
| 79 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 81 std::unique_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| 80 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 82 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 81 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 83 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 82 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 84 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 83 | 85 |
| 84 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 86 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
| 85 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 87 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
| 86 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 88 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
| 87 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 89 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| 88 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); | 90 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); |
| 89 | 91 |
| 90 window3_state->Minimize(); | 92 window3_state->Minimize(); |
| 91 window1_state->Maximize(); | 93 window1_state->Maximize(); |
| 92 | 94 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 EXPECT_TRUE(window4_state->IsMinimized()); | 133 EXPECT_TRUE(window4_state->IsMinimized()); |
| 132 } | 134 } |
| 133 | 135 |
| 134 // Test for multiple calls to |MinimizeInactiveWindows| before call | 136 // Test for multiple calls to |MinimizeInactiveWindows| before call |
| 135 // |RestoreWindows|: | 137 // |RestoreWindows|: |
| 136 // 1. If all window hasn't change their states, the following calls are noops. | 138 // 1. If all window hasn't change their states, the following calls are noops. |
| 137 // 2. If some windows are manually unminimized, the following call will minimize | 139 // 2. If some windows are manually unminimized, the following call will minimize |
| 138 // all the unminimized windows. | 140 // all the unminimized windows. |
| 139 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { | 141 TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { |
| 140 fake_user_manager()->AddUser(test_account_id1_); | 142 fake_user_manager()->AddUser(test_account_id1_); |
| 141 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 143 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 142 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 144 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 143 | 145 |
| 144 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 146 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
| 145 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 147 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
| 146 | 148 |
| 147 // We then activate window 0 (i.e. wallpaper picker) and call the minimize | 149 // We then activate window 0 (i.e. wallpaper picker) and call the minimize |
| 148 // function. | 150 // function. |
| 149 window0_state->Activate(); | 151 window0_state->Activate(); |
| 150 EXPECT_TRUE(window0_state->IsActive()); | 152 EXPECT_TRUE(window0_state->IsActive()); |
| 151 scoped_refptr<TestMinimizeFunction> minimize_function_0( | 153 scoped_refptr<TestMinimizeFunction> minimize_function_0( |
| 152 new TestMinimizeFunction()); | 154 new TestMinimizeFunction()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 256 } |
| 255 | 257 |
| 256 // In multi profile mode, user may open wallpaper picker in one profile and | 258 // 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 | 259 // then switch to a different profile and open another wallpaper picker |
| 258 // without closing the first one. | 260 // without closing the first one. |
| 259 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { | 261 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| 260 SetUpMultiUserWindowManager( | 262 SetUpMultiUserWindowManager( |
| 261 test_account_id1_, | 263 test_account_id1_, |
| 262 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); | 264 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); |
| 263 | 265 |
| 264 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); | 266 std::unique_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
| 265 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 267 std::unique_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| 266 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 268 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 267 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 269 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 268 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 270 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 269 | 271 |
| 270 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 272 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
| 271 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 273 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
| 272 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 274 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
| 273 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 275 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| 274 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); | 276 ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); |
| 275 | 277 |
| 276 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); | 278 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); |
| 277 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); | 279 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); |
| 278 | 280 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 EXPECT_FALSE(window3_state->IsMinimized()); | 357 EXPECT_FALSE(window3_state->IsMinimized()); |
| 356 } | 358 } |
| 357 | 359 |
| 358 // In multi profile mode, user may teleport windows. Teleported window should | 360 // In multi profile mode, user may teleport windows. Teleported window should |
| 359 // also be minimized when open wallpaper picker. | 361 // also be minimized when open wallpaper picker. |
| 360 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { | 362 TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { |
| 361 SetUpMultiUserWindowManager( | 363 SetUpMultiUserWindowManager( |
| 362 AccountId::FromUserEmail(kTestAccount1), | 364 AccountId::FromUserEmail(kTestAccount1), |
| 363 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED); | 365 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED); |
| 364 | 366 |
| 365 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); | 367 std::unique_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| 366 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 368 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| 367 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 369 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 368 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 370 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 369 | 371 |
| 370 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); | 372 ash::wm::WindowState* window0_state = ash::wm::GetWindowState(window0.get()); |
| 371 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); | 373 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1.get()); |
| 372 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); | 374 ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
| 373 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); | 375 ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| 374 | 376 |
| 375 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); | 377 multi_user_window_manager()->SetWindowOwner(window0.get(), test_account_id1_); |
| 376 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); | 378 multi_user_window_manager()->SetWindowOwner(window1.get(), test_account_id1_); |
| 377 | 379 |
| 378 // Set some windows to an inactive owner. | 380 // Set some windows to an inactive owner. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 scoped_refptr<TestRestoreFunction> restore_function_1( | 413 scoped_refptr<TestRestoreFunction> restore_function_1( |
| 412 new TestRestoreFunction()); | 414 new TestRestoreFunction()); |
| 413 EXPECT_TRUE(restore_function_1->RunAsync()); | 415 EXPECT_TRUE(restore_function_1->RunAsync()); |
| 414 | 416 |
| 415 EXPECT_FALSE(window1_state->IsMinimized()); | 417 EXPECT_FALSE(window1_state->IsMinimized()); |
| 416 EXPECT_FALSE(window2_state->IsMinimized()); | 418 EXPECT_FALSE(window2_state->IsMinimized()); |
| 417 EXPECT_FALSE(window3_state->IsMinimized()); | 419 EXPECT_FALSE(window3_state->IsMinimized()); |
| 418 } | 420 } |
| 419 | 421 |
| 420 } // namespace chromeos | 422 } // namespace chromeos |
| OLD | NEW |