Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc |
| diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc |
| index 16843b7cf6e5528b8d84ef9efb9c21077b1d59bc..8ec3bade05e04daafc0c0098866897e23856ad05 100644 |
| --- a/chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc |
| +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api_unittest.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| +#include "components/signin/core/account_id/account_id.h" |
| #include "ui/aura/test/test_windows.h" |
| #include "ui/aura/window.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| @@ -28,12 +29,17 @@ const char kTestAccount2[] = "user2@test.com"; |
| class WallpaperPrivateApiUnittest : public ash::test::AshTestBase { |
| public: |
| WallpaperPrivateApiUnittest() |
| - : fake_user_manager_(new FakeChromeUserManager()), |
| + : test_account1_(AccountId::FromUserEmail(kTestAccount1)), |
| + test_account2_(AccountId::FromUserEmail(kTestAccount2)), |
| + fake_user_manager_(new FakeChromeUserManager()), |
| scoped_user_manager_(fake_user_manager_) {} |
| protected: |
| FakeChromeUserManager* fake_user_manager() { return fake_user_manager_; } |
| + 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.
|
| + const AccountId test_account2_; |
| + |
| private: |
| FakeChromeUserManager* fake_user_manager_; |
| ScopedUserManagerEnabler scoped_user_manager_; |
| @@ -69,7 +75,7 @@ class TestRestoreFunction |
| } // namespace |
| TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { |
| - fake_user_manager()->AddUser(kTestAccount1); |
| + fake_user_manager()->AddUser(test_account1_); |
| scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
| scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
| @@ -132,7 +138,7 @@ TEST_F(WallpaperPrivateApiUnittest, HideAndRestoreWindows) { |
| // 2. If some windows are manually unminimized, the following call will minimize |
| // all the unminimized windows. |
| TEST_F(WallpaperPrivateApiUnittest, HideAndManualUnminimizeWindows) { |
| - fake_user_manager()->AddUser(kTestAccount1); |
| + fake_user_manager()->AddUser(test_account1_); |
| scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| @@ -196,10 +202,10 @@ class WallpaperPrivateApiMultiUserUnittest |
| protected: |
| void SetUpMultiUserWindowManager( |
| - const std::string& active_user_id, |
| + const AccountId& active_user_id, |
| chrome::MultiUserWindowManager::MultiProfileMode mode); |
| - void SwitchActiveUser(const std::string& active_user_id); |
| + 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.
|
| chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager() { |
| return multi_user_window_manager_; |
| @@ -218,8 +224,8 @@ void WallpaperPrivateApiMultiUserUnittest::SetUp() { |
| session_state_delegate_ = |
| static_cast<ash::test::TestSessionStateDelegate*> ( |
| ash::Shell::GetInstance()->session_state_delegate()); |
| - fake_user_manager()->AddUser(kTestAccount1); |
| - fake_user_manager()->AddUser(kTestAccount2); |
| + fake_user_manager()->AddUser(test_account1_); |
| + fake_user_manager()->AddUser(test_account2_); |
| } |
| void WallpaperPrivateApiMultiUserUnittest::TearDown() { |
| @@ -229,10 +235,10 @@ void WallpaperPrivateApiMultiUserUnittest::TearDown() { |
| } |
| void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( |
| - const std::string& active_user_id, |
| + const AccountId& active_user_id, |
|
achuithb
2015/10/23 00:08:49
active_account_id
Alexander Alekseev
2015/10/23 09:11:21
Done.
|
| chrome::MultiUserWindowManager::MultiProfileMode mode) { |
| multi_user_window_manager_ = |
| - new chrome::MultiUserWindowManagerChromeOS(active_user_id); |
| + new chrome::MultiUserWindowManagerChromeOS(active_user_id.GetUserEmail()); |
| multi_user_window_manager_->Init(); |
| chrome::MultiUserWindowManager::SetInstanceForTest( |
| multi_user_window_manager_, mode); |
| @@ -243,16 +249,17 @@ void WallpaperPrivateApiMultiUserUnittest::SetUpMultiUserWindowManager( |
| } |
| void WallpaperPrivateApiMultiUserUnittest::SwitchActiveUser( |
| - const std::string& active_user_id) { |
| + const AccountId& active_user_id) { |
|
achuithb
2015/10/23 00:08:49
active_account_id
Alexander Alekseev
2015/10/23 09:11:21
Done.
|
| fake_user_manager()->SwitchActiveUser(active_user_id); |
| - multi_user_window_manager_->ActiveUserChanged(active_user_id); |
| + multi_user_window_manager_->ActiveUserChanged(active_user_id.GetUserEmail()); |
| } |
| // In multi profile mode, user may open wallpaper picker in one profile and |
| // then switch to a different profile and open another wallpaper picker |
| // without closing the first one. |
| TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| - SetUpMultiUserWindowManager(kTestAccount1, |
| + SetUpMultiUserWindowManager( |
| + test_account1_, |
| chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED); |
| scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(4)); |
| @@ -267,13 +274,18 @@ TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| ash::wm::WindowState* window4_state = ash::wm::GetWindowState(window4.get()); |
| - multi_user_window_manager()->SetWindowOwner(window0.get(), kTestAccount1); |
| - multi_user_window_manager()->SetWindowOwner(window1.get(), kTestAccount1); |
| + multi_user_window_manager()->SetWindowOwner(window0.get(), |
| + test_account1_.GetUserEmail()); |
| + multi_user_window_manager()->SetWindowOwner(window1.get(), |
| + test_account1_.GetUserEmail()); |
| // Set some windows to an inactive owner. |
| - multi_user_window_manager()->SetWindowOwner(window2.get(), kTestAccount2); |
| - multi_user_window_manager()->SetWindowOwner(window3.get(), kTestAccount2); |
| - multi_user_window_manager()->SetWindowOwner(window4.get(), kTestAccount2); |
| + multi_user_window_manager()->SetWindowOwner(window2.get(), |
| + test_account2_.GetUserEmail()); |
| + multi_user_window_manager()->SetWindowOwner(window3.get(), |
| + test_account2_.GetUserEmail()); |
| + multi_user_window_manager()->SetWindowOwner(window4.get(), |
| + test_account2_.GetUserEmail()); |
| EXPECT_FALSE(window0_state->IsMinimized()); |
| EXPECT_FALSE(window1_state->IsMinimized()); |
| @@ -299,7 +311,7 @@ TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| EXPECT_FALSE(window4_state->IsMinimized()); |
| // Activate kTestAccount2. kTestAccount1 becomes inactive user. |
| - SwitchActiveUser(kTestAccount2); |
| + SwitchActiveUser(test_account2_); |
| window2_state->Activate(); |
| EXPECT_TRUE(window2_state->IsActive()); |
| @@ -337,7 +349,7 @@ TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| EXPECT_FALSE(window0_state->IsMinimized()); |
| EXPECT_TRUE(window1_state->IsMinimized()); |
| - SwitchActiveUser(kTestAccount1); |
| + SwitchActiveUser(test_account1_); |
| // Then we destroy window 0 and call the restore function. |
| window0.reset(); |
| @@ -352,7 +364,8 @@ TEST_F(WallpaperPrivateApiMultiUserUnittest, HideAndRestoreWindowsTwoUsers) { |
| // In multi profile mode, user may teleport windows. Teleported window should |
| // also be minimized when open wallpaper picker. |
| TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { |
| - SetUpMultiUserWindowManager(kTestAccount1, |
| + SetUpMultiUserWindowManager( |
| + AccountId::FromUserEmail(kTestAccount1), |
| chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED); |
| scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(3)); |
| @@ -365,15 +378,20 @@ TEST_F(WallpaperPrivateApiMultiUserUnittest, HideTeleportedWindow) { |
| ash::wm::WindowState* window2_state = ash::wm::GetWindowState(window2.get()); |
| ash::wm::WindowState* window3_state = ash::wm::GetWindowState(window3.get()); |
| - multi_user_window_manager()->SetWindowOwner(window0.get(), kTestAccount1); |
| - multi_user_window_manager()->SetWindowOwner(window1.get(), kTestAccount1); |
| + multi_user_window_manager()->SetWindowOwner(window0.get(), |
| + test_account1_.GetUserEmail()); |
| + multi_user_window_manager()->SetWindowOwner(window1.get(), |
| + test_account1_.GetUserEmail()); |
| // Set some windows to an inactive owner. |
| - multi_user_window_manager()->SetWindowOwner(window2.get(), kTestAccount2); |
| - multi_user_window_manager()->SetWindowOwner(window3.get(), kTestAccount2); |
| + multi_user_window_manager()->SetWindowOwner(window2.get(), |
| + test_account2_.GetUserEmail()); |
| + multi_user_window_manager()->SetWindowOwner(window3.get(), |
| + test_account2_.GetUserEmail()); |
| // Teleport window2 to kTestAccount1. |
| - multi_user_window_manager()->ShowWindowForUser(window2.get(), kTestAccount1); |
| + multi_user_window_manager()->ShowWindowForUser(window2.get(), |
| + test_account1_.GetUserEmail()); |
| // Initial window state. All windows shouldn't be minimized. |
| EXPECT_FALSE(window0_state->IsMinimized()); |