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