| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "ash/content/shell_content_state.h" | 7 #include "ash/content/shell_content_state.h" |
| 8 #include "ash/public/cpp/shell_window_ids.h" | 8 #include "ash/public/cpp/shell_window_ids.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/ash_test_environment_content.h" | 13 #include "ash/test/ash_test_environment_content.h" |
| 14 #include "ash/test/ash_test_helper.h" | 14 #include "ash/test/ash_test_helper.h" |
| 15 #include "ash/test/test_shell_delegate.h" | 15 #include "ash/test/test_shell_delegate.h" |
| 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | |
| 17 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | |
| 18 #include "ash/wm/mru_window_tracker.h" | 16 #include "ash/wm/mru_window_tracker.h" |
| 17 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 18 #include "ash/wm/tablet_mode/tablet_mode_window_manager.h" |
| 19 #include "ash/wm/window_state.h" | 19 #include "ash/wm/window_state.h" |
| 20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 21 #include "ash/wm/wm_event.h" | 21 #include "ash/wm/wm_event.h" |
| 22 #include "ash/wm_window.h" | 22 #include "ash/wm_window.h" |
| 23 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
| 24 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "base/macros.h" | 25 #include "base/macros.h" |
| 26 #include "base/run_loop.h" | 26 #include "base/run_loop.h" |
| 27 #include "base/strings/string_piece.h" | 27 #include "base/strings/string_piece.h" |
| 28 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // Return the user id of the wallpaper which is currently set. | 263 // Return the user id of the wallpaper which is currently set. |
| 264 const std::string& GetWallpaperUserIdForTest() { | 264 const std::string& GetWallpaperUserIdForTest() { |
| 265 return multi_user_window_manager_->animation_->wallpaper_user_id_for_test(); | 265 return multi_user_window_manager_->animation_->wallpaper_user_id_for_test(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 // Returns true if the given window covers the screen. | 268 // Returns true if the given window covers the screen. |
| 269 bool CoversScreen(aura::Window* window) { | 269 bool CoversScreen(aura::Window* window) { |
| 270 return chrome::UserSwitchAnimatorChromeOS::CoversScreen(window); | 270 return chrome::UserSwitchAnimatorChromeOS::CoversScreen(window); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Create a maximize mode window manager. | 273 // Create a tablet mode window manager. |
| 274 MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { | 274 TabletModeWindowManager* CreateTabletModeWindowManager() { |
| 275 EXPECT_FALSE(maximize_mode_window_manager()); | 275 EXPECT_FALSE(tablet_mode_window_manager()); |
| 276 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 276 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); |
| 277 true); | 277 return tablet_mode_window_manager(); |
| 278 return maximize_mode_window_manager(); | |
| 279 } | 278 } |
| 280 | 279 |
| 281 MaximizeModeWindowManager* maximize_mode_window_manager() { | 280 TabletModeWindowManager* tablet_mode_window_manager() { |
| 282 return Shell::Get() | 281 return Shell::Get() |
| 283 ->maximize_mode_controller() | 282 ->tablet_mode_controller() |
| 284 ->maximize_mode_window_manager_.get(); | 283 ->tablet_mode_window_manager_.get(); |
| 285 } | 284 } |
| 286 | 285 |
| 287 private: | 286 private: |
| 288 // These get created for each session. | 287 // These get created for each session. |
| 289 aura::Window::Windows windows_; | 288 aura::Window::Windows windows_; |
| 290 | 289 |
| 291 // The instance of the MultiUserWindowManager. | 290 // The instance of the MultiUserWindowManager. |
| 292 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; | 291 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; |
| 293 | 292 |
| 294 // Owned by |user_manager_enabler_|. | 293 // Owned by |user_manager_enabler_|. |
| 295 chromeos::FakeChromeUserManager* fake_user_manager_ = nullptr; | 294 chromeos::FakeChromeUserManager* fake_user_manager_ = nullptr; |
| 296 | 295 |
| 297 std::unique_ptr<TestingProfileManager> profile_manager_; | 296 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 298 | 297 |
| 299 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 298 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 300 | 299 |
| 301 // The maximized window manager (if enabled). | 300 // The maximized window manager (if enabled). |
| 302 std::unique_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; | 301 std::unique_ptr<TabletModeWindowManager> tablet_mode_window_manager_; |
| 303 | 302 |
| 304 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest); | 303 DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest); |
| 305 }; | 304 }; |
| 306 | 305 |
| 307 void MultiUserWindowManagerChromeOSTest::SetUp() { | 306 void MultiUserWindowManagerChromeOSTest::SetUp() { |
| 308 ash_test_helper()->set_test_shell_delegate(new TestShellDelegateChromeOS); | 307 ash_test_helper()->set_test_shell_delegate(new TestShellDelegateChromeOS); |
| 309 ash::test::AshTestEnvironmentContent* test_environment = | 308 ash::test::AshTestEnvironmentContent* test_environment = |
| 310 static_cast<ash::test::AshTestEnvironmentContent*>( | 309 static_cast<ash::test::AshTestEnvironmentContent*>( |
| 311 ash_test_helper()->ash_test_environment()); | 310 ash_test_helper()->ash_test_environment()); |
| 312 test_environment->set_content_state(new ::TestShellContentState); | 311 test_environment->set_content_state(new ::TestShellContentState); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 ShowWindowForUserNoUserTransition(window(1), account_id_B); | 847 ShowWindowForUserNoUserTransition(window(1), account_id_B); |
| 849 ShowWindowForUserNoUserTransition(window(2), account_id_A); | 848 ShowWindowForUserNoUserTransition(window(2), account_id_A); |
| 850 ShowWindowForUserNoUserTransition(window(3), account_id_A); | 849 ShowWindowForUserNoUserTransition(window(3), account_id_A); |
| 851 EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus()); | 850 EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus()); |
| 852 StartUserTransitionAnimation(account_id_B); | 851 StartUserTransitionAnimation(account_id_B); |
| 853 EXPECT_EQ("S[A,B], H[A,B], H[B,A], H[B,A]", GetStatus()); | 852 EXPECT_EQ("S[A,B], H[A,B], H[B,A], H[B,A]", GetStatus()); |
| 854 StartUserTransitionAnimation(account_id_A); | 853 StartUserTransitionAnimation(account_id_A); |
| 855 EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus()); | 854 EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus()); |
| 856 } | 855 } |
| 857 | 856 |
| 858 // Test that in case of an activated maximize mode, windows from other users get | 857 // Test that in case of an activated tablet mode, windows from other users get |
| 859 // maximized after a user switch. | 858 // maximized after a user switch. |
| 860 TEST_F(MultiUserWindowManagerChromeOSTest, MaximizeModeInteraction) { | 859 TEST_F(MultiUserWindowManagerChromeOSTest, TabletModeInteraction) { |
| 861 SetUpForThisManyWindows(2); | 860 SetUpForThisManyWindows(2); |
| 862 | 861 |
| 863 const AccountId account_id_A(AccountId::FromUserEmail("A")); | 862 const AccountId account_id_A(AccountId::FromUserEmail("A")); |
| 864 const AccountId account_id_B(AccountId::FromUserEmail("B")); | 863 const AccountId account_id_B(AccountId::FromUserEmail("B")); |
| 865 | 864 |
| 866 multi_user_window_manager()->SetWindowOwner(window(0), account_id_A); | 865 multi_user_window_manager()->SetWindowOwner(window(0), account_id_A); |
| 867 multi_user_window_manager()->SetWindowOwner(window(1), account_id_B); | 866 multi_user_window_manager()->SetWindowOwner(window(1), account_id_B); |
| 868 | 867 |
| 869 EXPECT_FALSE(wm::GetWindowState(window(0))->IsMaximized()); | 868 EXPECT_FALSE(wm::GetWindowState(window(0))->IsMaximized()); |
| 870 EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized()); | 869 EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized()); |
| 871 | 870 |
| 872 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); | 871 TabletModeWindowManager* manager = CreateTabletModeWindowManager(); |
| 873 ASSERT_TRUE(manager); | 872 ASSERT_TRUE(manager); |
| 874 | 873 |
| 875 EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized()); | 874 EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized()); |
| 876 EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized()); | 875 EXPECT_FALSE(wm::GetWindowState(window(1))->IsMaximized()); |
| 877 | 876 |
| 878 // After we start switching to B, the windows of user B should maximize. | 877 // After we start switching to B, the windows of user B should maximize. |
| 879 StartUserTransitionAnimation(account_id_B); | 878 StartUserTransitionAnimation(account_id_B); |
| 880 | 879 |
| 881 EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized()); | 880 EXPECT_TRUE(wm::GetWindowState(window(0))->IsMaximized()); |
| 882 EXPECT_TRUE(wm::GetWindowState(window(1))->IsMaximized()); | 881 EXPECT_TRUE(wm::GetWindowState(window(1))->IsMaximized()); |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 user_manager()->SwitchActiveUser(account_id_B); | 1577 user_manager()->SwitchActiveUser(account_id_B); |
| 1579 multi_user_window_manager()->ActiveUserChanged( | 1578 multi_user_window_manager()->ActiveUserChanged( |
| 1580 user_manager()->FindUser(account_id_B)); | 1579 user_manager()->FindUser(account_id_B)); |
| 1581 EXPECT_EQ(browser.get(), BrowserList::GetInstance()->GetLastActive()); | 1580 EXPECT_EQ(browser.get(), BrowserList::GetInstance()->GetLastActive()); |
| 1582 EXPECT_EQ(nullptr, wm::GetActiveWindow()); | 1581 EXPECT_EQ(nullptr, wm::GetActiveWindow()); |
| 1583 EXPECT_EQ(nullptr, ChromeNewWindowClient::GetActiveBrowser()); | 1582 EXPECT_EQ(nullptr, ChromeNewWindowClient::GetActiveBrowser()); |
| 1584 } | 1583 } |
| 1585 | 1584 |
| 1586 } // namespace test | 1585 } // namespace test |
| 1587 } // namespace ash | 1586 } // namespace ash |
| OLD | NEW |