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