This source file includes following definitions.
- session_state_delegate_
- SwitchUserAndWaitForAnimation
- window
- delete_window_at
- multi_user_window_manager
- session_state_delegate
- MakeWindowSystemModal
- ShowWindowForUserNoUserTransition
- GetAndValidateCurrentUserFromSessionStateObserver
- SetUp
- SetUpForThisManyWindows
- TearDown
- GetStatus
- GetOwnersOfVisibleWindowsAsString
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/wm/window_state.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/time/time.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 "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/ui_base_types.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
namespace ash {
namespace test {
class MultiUserWindowManagerChromeOSTest : public AshTestBase {
public:
MultiUserWindowManagerChromeOSTest()
: multi_user_window_manager_(NULL),
session_state_delegate_(NULL) {}
virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
protected:
void SetUpForThisManyWindows(int windows);
void SwitchUserAndWaitForAnimation(const std::string& user_id) {
multi_user_window_manager_->ActiveUserChanged(user_id);
base::TimeTicks now = base::TimeTicks::Now();
while (multi_user_window_manager_->IsAnimationRunningForTest()) {
ASSERT_GE(1000, (base::TimeTicks::Now() - now).InMilliseconds());
base::MessageLoop::current()->RunUntilIdle();
}
}
aura::Window* window(size_t index) {
DCHECK(index < window_.size());
return window_[index];
}
void delete_window_at(size_t index) {
delete window_[index];
window_[index] = NULL;
}
chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager() {
return multi_user_window_manager_;
}
std::string GetStatus();
std::string GetOwnersOfVisibleWindowsAsString();
TestSessionStateDelegate* session_state_delegate() {
return session_state_delegate_;
}
void MakeWindowSystemModal(aura::Window* window) {
aura::Window* system_modal_container =
window->GetRootWindow()->GetChildById(
ash::kShellWindowId_SystemModalContainer);
system_modal_container->AddChild(window);
}
void ShowWindowForUserNoUserTransition(aura::Window* window,
const std::string& user_id) {
multi_user_window_manager_->ShowWindowForUserIntern(window, user_id);
}
std::string GetAndValidateCurrentUserFromSessionStateObserver() {
const std::string& user = session_state_delegate()->get_activated_user();
if (user != multi_user_window_manager_->GetCurrentUserForTest())
multi_user_window_manager()->ActiveUserChanged(user);
return user;
}
private:
std::vector<aura::Window*> window_;
chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_;
ash::test::TestSessionStateDelegate* session_state_delegate_;
DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerChromeOSTest);
};
void MultiUserWindowManagerChromeOSTest::SetUp() {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
AshTestBase::SetUp();
session_state_delegate_ =
static_cast<TestSessionStateDelegate*> (
ash::Shell::GetInstance()->session_state_delegate());
}
void MultiUserWindowManagerChromeOSTest::SetUpForThisManyWindows(int windows) {
DCHECK(!window_.size());
for (int i = 0; i < windows; i++) {
window_.push_back(CreateTestWindowInShellWithId(i));
window_[i]->Show();
}
multi_user_window_manager_ = new chrome::MultiUserWindowManagerChromeOS("A");
multi_user_window_manager_->SetAnimationsForTest(true);
chrome::MultiUserWindowManager::SetInstanceForTest(multi_user_window_manager_,
chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED);
EXPECT_TRUE(multi_user_window_manager_);
}
void MultiUserWindowManagerChromeOSTest::TearDown() {
while (!window_.empty()) {
delete *(window_.begin());
window_.erase(window_.begin());
}
chrome::MultiUserWindowManager::DeleteInstance();
AshTestBase::TearDown();
}
std::string MultiUserWindowManagerChromeOSTest::GetStatus() {
std::string s;
for (size_t i = 0; i < window_.size(); i++) {
if (i)
s += ", ";
if (!window(i)) {
s += "D";
continue;
}
s += window(i)->IsVisible() ? "S[" : "H[";
const std::string& owner =
multi_user_window_manager_->GetWindowOwner(window(i));
s += owner;
const std::string& presenter =
multi_user_window_manager_->GetUserPresentingWindow(window(i));
if (!owner.empty() && owner != presenter) {
s += ",";
s += presenter;
}
s += "]";
}
return s;
}
std::string
MultiUserWindowManagerChromeOSTest::GetOwnersOfVisibleWindowsAsString() {
std::set<std::string> owners;
multi_user_window_manager_->GetOwnersOfVisibleWindows(&owners);
std::vector<std::string> owner_list;
owner_list.insert(owner_list.begin(), owners.begin(), owners.end());
return JoinString(owner_list, ' ');
}
TEST_F(MultiUserWindowManagerChromeOSTest, BasicTests) {
SetUpForThisManyWindows(3);
EXPECT_EQ("S[], S[], S[]", GetStatus());
EXPECT_TRUE(multi_user_window_manager());
EXPECT_EQ(multi_user_window_manager(),
chrome::MultiUserWindowManager::GetInstance());
EXPECT_FALSE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("", multi_user_window_manager()->GetWindowOwner(window(0)));
EXPECT_EQ("",
multi_user_window_manager()->GetUserPresentingWindow(window(0)));
EXPECT_TRUE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "A"));
EXPECT_TRUE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "B"));
multi_user_window_manager()->SetWindowOwner(window(0), "A");
EXPECT_EQ("A", multi_user_window_manager()->GetWindowOwner(window(0)));
EXPECT_EQ("A",
multi_user_window_manager()->GetUserPresentingWindow(window(0)));
EXPECT_TRUE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "A"));
EXPECT_FALSE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "B"));
ShowWindowForUserNoUserTransition(window(0), "B");
EXPECT_EQ("A", multi_user_window_manager()->GetWindowOwner(window(0)));
EXPECT_EQ("B",
multi_user_window_manager()->GetUserPresentingWindow(window(0)));
EXPECT_FALSE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "A"));
EXPECT_TRUE(
multi_user_window_manager()->IsWindowOnDesktopOfUser(window(0), "B"));
}
TEST_F(MultiUserWindowManagerChromeOSTest, OwnerTests) {
SetUpForThisManyWindows(5);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
EXPECT_EQ("S[A], S[], S[], S[], S[]", GetStatus());
multi_user_window_manager()->SetWindowOwner(window(2), "A");
EXPECT_EQ("S[A], S[], S[A], S[], S[]", GetStatus());
multi_user_window_manager()->SetWindowOwner(window(1), "B");
EXPECT_EQ("S[A], H[B], S[A], S[], S[]", GetStatus());
multi_user_window_manager()->SetWindowOwner(window(3), "B");
EXPECT_EQ("S[A], H[B], S[A], H[B], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("C");
EXPECT_EQ("H[A], H[B], H[A], H[B], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("S[A], H[B], S[A], H[B], S[]", GetStatus());
window(3)->Show();
EXPECT_EQ("S[A], H[B], S[A], H[B], S[]", GetStatus());
window(2)->Hide();
EXPECT_EQ("S[A], H[B], H[A], H[B], S[]", GetStatus());
window(2)->Show();
EXPECT_EQ("S[A], H[B], S[A], H[B], S[]", GetStatus());
}
TEST_F(MultiUserWindowManagerChromeOSTest, CloseWindowTests) {
SetUpForThisManyWindows(1);
multi_user_window_manager()->SetWindowOwner(window(0), "B");
EXPECT_EQ("H[B]", GetStatus());
ShowWindowForUserNoUserTransition(window(0), "A");
EXPECT_EQ("S[B,A]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("B", GetOwnersOfVisibleWindowsAsString());
aura::Window* to_be_deleted = window(0);
EXPECT_EQ(std::string("A"),
multi_user_window_manager()->GetUserPresentingWindow(
to_be_deleted));
EXPECT_EQ(std::string("B"),
multi_user_window_manager()->GetWindowOwner(
to_be_deleted));
delete_window_at(0);
EXPECT_EQ("D", GetStatus());
EXPECT_EQ("", GetOwnersOfVisibleWindowsAsString());
EXPECT_EQ(std::string(),
multi_user_window_manager()->GetUserPresentingWindow(
to_be_deleted));
EXPECT_EQ(std::string(),
multi_user_window_manager()->GetWindowOwner(
to_be_deleted));
}
TEST_F(MultiUserWindowManagerChromeOSTest, SharedWindowTests) {
SetUpForThisManyWindows(5);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "A");
multi_user_window_manager()->SetWindowOwner(window(2), "B");
multi_user_window_manager()->SetWindowOwner(window(3), "B");
multi_user_window_manager()->SetWindowOwner(window(4), "C");
EXPECT_EQ("S[A], S[A], H[B], H[B], H[C]", GetStatus());
EXPECT_FALSE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("A", GetOwnersOfVisibleWindowsAsString());
ShowWindowForUserNoUserTransition(window(1), "B");
ShowWindowForUserNoUserTransition(window(2), "A");
EXPECT_EQ("S[A], H[A,B], S[B,A], H[B], H[C]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("A B", GetOwnersOfVisibleWindowsAsString());
ShowWindowForUserNoUserTransition(window(2), "C");
EXPECT_EQ("S[A], H[A,B], H[B,C], H[B], H[C]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("A", GetOwnersOfVisibleWindowsAsString());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], S[A,B], H[B,C], S[B], H[C]", GetStatus());
EXPECT_EQ("A B", GetOwnersOfVisibleWindowsAsString());
multi_user_window_manager()->ActiveUserChanged("C");
EXPECT_EQ("H[A], H[A,B], S[B,C], H[B], S[C]", GetStatus());
EXPECT_EQ("B C", GetOwnersOfVisibleWindowsAsString());
ShowWindowForUserNoUserTransition(window(4), "C");
EXPECT_EQ("H[A], H[A,B], S[B,C], H[B], S[C]", GetStatus());
EXPECT_EQ("B C", GetOwnersOfVisibleWindowsAsString());
ShowWindowForUserNoUserTransition(window(2), "B");
EXPECT_EQ("H[A], H[A,B], H[B], H[B], S[C]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
EXPECT_EQ("C", GetOwnersOfVisibleWindowsAsString());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], S[A,B], S[B], S[B], H[C]", GetStatus());
EXPECT_EQ("A B", GetOwnersOfVisibleWindowsAsString());
multi_user_window_manager()->ActiveUserChanged("C");
EXPECT_EQ("H[A], H[A,B], H[B], H[B], S[C]", GetStatus());
EXPECT_EQ("C", GetOwnersOfVisibleWindowsAsString());
ShowWindowForUserNoUserTransition(window(1), "A");
EXPECT_FALSE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
}
TEST_F(MultiUserWindowManagerChromeOSTest, DoubleSharedWindowTests) {
SetUpForThisManyWindows(1);
multi_user_window_manager()->SetWindowOwner(window(0), "B");
ShowWindowForUserNoUserTransition(window(0), "A");
ShowWindowForUserNoUserTransition(window(0), "A");
EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
delete_window_at(0);
EXPECT_EQ("D", GetStatus());
EXPECT_FALSE(multi_user_window_manager()->AreWindowsSharedAmongUsers());
}
TEST_F(MultiUserWindowManagerChromeOSTest, PreserveWindowVisibilityTests) {
SetUpForThisManyWindows(5);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "A");
multi_user_window_manager()->SetWindowOwner(window(2), "B");
multi_user_window_manager()->SetWindowOwner(window(3), "B");
ShowWindowForUserNoUserTransition(window(2), "A");
ShowWindowForUserNoUserTransition(window(3), "A");
EXPECT_EQ("S[A], S[A], S[B,A], S[B,A], S[]", GetStatus());
window(0)->Hide();
window(2)->Hide();
window(4)->Hide();
EXPECT_EQ("H[A], S[A], H[B,A], S[B,A], H[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[A], H[B,A], H[B,A], H[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("H[A], S[A], H[B,A], S[B,A], H[]", GetStatus());
window(0)->Show();
window(2)->Show();
window(4)->Show();
EXPECT_EQ("S[A], S[A], S[B,A], S[B,A], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[A], H[B,A], H[B,A], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("S[A], S[A], S[B,A], S[B,A], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[A], H[B,A], H[B,A], S[]", GetStatus());
window(0)->Show();
window(2)->Show();
window(4)->Show();
EXPECT_EQ("H[A], H[A], H[B,A], H[B,A], S[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("S[A], S[A], S[B,A], S[B,A], S[]", GetStatus());
}
TEST_F(MultiUserWindowManagerChromeOSTest, MinimizeChangesOwnershipBack) {
SetUpForThisManyWindows(4);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
multi_user_window_manager()->SetWindowOwner(window(2), "B");
ShowWindowForUserNoUserTransition(window(1), "A");
EXPECT_EQ("S[A], S[B,A], H[B], S[]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->IsWindowOnDesktopOfUser(window(1),
"A"));
wm::GetWindowState(window(1))->Minimize();
EXPECT_EQ("S[A], H[B,A], H[B], S[]", GetStatus());
EXPECT_TRUE(multi_user_window_manager()->IsWindowOnDesktopOfUser(window(1),
"A"));
EXPECT_TRUE(wm::GetWindowState(window(1))->IsMinimized());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], S[B], S[B], S[]", GetStatus());
EXPECT_FALSE(wm::GetWindowState(window(1))->IsMinimized());
}
TEST_F(MultiUserWindowManagerChromeOSTest, MinimizeSuppressesViewTransfer) {
SetUpForThisManyWindows(1);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
wm::GetWindowState(window(0))->Minimize();
EXPECT_EQ("H[A]", GetStatus());
ShowWindowForUserNoUserTransition(window(0), "B");
EXPECT_EQ("H[A]", GetStatus());
}
TEST_F(MultiUserWindowManagerChromeOSTest, ActiveWindowTests) {
SetUpForThisManyWindows(4);
aura::client::ActivationClient* activation_client =
aura::client::GetActivationClient(window(0)->GetRootWindow());
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "A");
multi_user_window_manager()->SetWindowOwner(window(2), "B");
multi_user_window_manager()->SetWindowOwner(window(3), "B");
EXPECT_EQ("S[A], S[A], H[B], H[B]", GetStatus());
activation_client->ActivateWindow(window(1));
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[A], S[B], S[B]", GetStatus());
EXPECT_TRUE(window(3) == activation_client->GetActiveWindow() ||
window(2) == activation_client->GetActiveWindow());
activation_client->ActivateWindow(window(2));
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ(window(1), activation_client->GetActiveWindow());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ(window(2), activation_client->GetActiveWindow());
multi_user_window_manager()->ActiveUserChanged("C");
EXPECT_EQ(NULL, activation_client->GetActiveWindow());
multi_user_window_manager()->ActiveUserChanged("A");
wm::GetWindowState(window(0))->Minimize();
multi_user_window_manager()->ActiveUserChanged("B");
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_TRUE(wm::GetWindowState(window(0))->IsMinimized());
EXPECT_EQ(window(1), activation_client->GetActiveWindow());
}
TEST_F(MultiUserWindowManagerChromeOSTest, TransientWindows) {
SetUpForThisManyWindows(10);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(4), "B");
::wm::AddTransientChild(window(0), window(1));
::wm::AddTransientChild(window(2), window(3));
::wm::AddTransientChild(window(1), window(2));
::wm::AddTransientChild(window(4), window(5));
::wm::AddTransientChild(window(4), window(6));
::wm::AddTransientChild(window(7), window(8));
::wm::AddTransientChild(window(7), window(9));
EXPECT_EQ("S[A], S[], S[], S[], H[B], H[], H[], S[], S[], S[]", GetStatus());
window(5)->Show();
window(6)->Show();
EXPECT_EQ("S[A], S[], S[], S[], H[B], H[], H[], S[], S[], S[]", GetStatus());
window(2)->Hide();
window(9)->Hide();
EXPECT_EQ("S[A], S[], H[], H[], H[B], H[], H[], S[], S[], H[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[], H[], H[], S[B], S[], S[], S[], S[], H[]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("S[A], S[], H[], H[], H[B], H[], H[], S[], S[], H[]", GetStatus());
::wm::RemoveTransientChild(window(2), window(3));
::wm::RemoveTransientChild(window(4), window(6));
EXPECT_EQ("S[A], S[], H[], H[], H[B], H[], S[], S[], S[], H[]", GetStatus());
::wm::RemoveTransientChild(window(0), window(1));
::wm::RemoveTransientChild(window(1), window(2));
::wm::RemoveTransientChild(window(4), window(5));
::wm::RemoveTransientChild(window(7), window(8));
::wm::RemoveTransientChild(window(7), window(9));
}
TEST_F(MultiUserWindowManagerChromeOSTest, PreserveInitialVisibility) {
SetUpForThisManyWindows(4);
window(0)->Show();
window(1)->Hide();
window(2)->Show();
window(3)->Hide();
EXPECT_EQ("S[], H[], S[], H[]", GetStatus());
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "A");
multi_user_window_manager()->SetWindowOwner(window(2), "B");
multi_user_window_manager()->SetWindowOwner(window(3), "B");
EXPECT_EQ("S[A], H[A], H[B], H[B]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[A], S[B], H[B]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("S[A], H[A], H[B], H[B]", GetStatus());
ShowWindowForUserNoUserTransition(window(0), "B");
ShowWindowForUserNoUserTransition(window(1), "B");
ShowWindowForUserNoUserTransition(window(2), "A");
ShowWindowForUserNoUserTransition(window(3), "A");
EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("S[A,B], H[A,B], H[B,A], H[B,A]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("A");
EXPECT_EQ("H[A,B], H[A,B], S[B,A], H[B,A]", GetStatus());
}
TEST_F(MultiUserWindowManagerChromeOSTest, SwitchUsersUponModalityChange) {
SetUpForThisManyWindows(1);
session_state_delegate()->SwitchActiveUser("a");
MakeWindowSystemModal(window(0));
EXPECT_EQ("a", session_state_delegate()->get_activated_user());
multi_user_window_manager()->SetWindowOwner(window(0), "b");
EXPECT_EQ("b", session_state_delegate()->get_activated_user());
}
TEST_F(MultiUserWindowManagerChromeOSTest, DontSwitchUsersUponModalityChange) {
SetUpForThisManyWindows(1);
session_state_delegate()->SwitchActiveUser("a");
MakeWindowSystemModal(window(0));
EXPECT_EQ("a", session_state_delegate()->get_activated_user());
multi_user_window_manager()->SetWindowOwner(window(0), "a");
EXPECT_EQ("a", session_state_delegate()->get_activated_user());
}
TEST_F(MultiUserWindowManagerChromeOSTest,
DontSwitchUsersUponModalityChangeWhenShownButNotOwned) {
SetUpForThisManyWindows(1);
session_state_delegate()->SwitchActiveUser("a");
window(0)->Hide();
multi_user_window_manager()->SetWindowOwner(window(0), "b");
ShowWindowForUserNoUserTransition(window(0), "a");
MakeWindowSystemModal(window(0));
window(0)->Show();
EXPECT_EQ("a", session_state_delegate()->get_activated_user());
}
TEST_F(MultiUserWindowManagerChromeOSTest,
SwitchUsersUponModalityChangeWhenShownButNotOwned) {
SetUpForThisManyWindows(1);
session_state_delegate()->SwitchActiveUser("a");
window(0)->Hide();
multi_user_window_manager()->SetWindowOwner(window(0), "a");
ShowWindowForUserNoUserTransition(window(0), "b");
MakeWindowSystemModal(window(0));
window(0)->Show();
EXPECT_EQ("b", session_state_delegate()->get_activated_user());
}
TEST_F(MultiUserWindowManagerChromeOSTest, FullUserSwitchAnimationTests) {
SetUpForThisManyWindows(3);
multi_user_window_manager()->SetAnimationsForTest(false);
multi_user_window_manager()->SetWindowOwner(window(0), "A");
multi_user_window_manager()->SetWindowOwner(window(1), "B");
multi_user_window_manager()->SetWindowOwner(window(2), "C");
EXPECT_EQ("S[A], H[B], H[C]", GetStatus());
EXPECT_EQ("A", GetOwnersOfVisibleWindowsAsString());
SwitchUserAndWaitForAnimation("B");
EXPECT_EQ("H[A], S[B], H[C]", GetStatus());
EXPECT_EQ("B", GetOwnersOfVisibleWindowsAsString());
SwitchUserAndWaitForAnimation("A");
EXPECT_EQ("S[A], H[B], H[C]", GetStatus());
multi_user_window_manager()->ActiveUserChanged("B");
EXPECT_EQ("H[A], H[B], H[C]", GetStatus());
SwitchUserAndWaitForAnimation("C");
EXPECT_EQ("H[A], H[B], S[C]", GetStatus());
}
TEST_F(MultiUserWindowManagerChromeOSTest, ShowForUserSwitchesDesktop) {
SetUpForThisManyWindows(3);
multi_user_window_manager()->ActiveUserChanged("a");
session_state_delegate()->SwitchActiveUser("a");
multi_user_window_manager()->SetWindowOwner(window(0), "a");
multi_user_window_manager()->SetWindowOwner(window(1), "b");
multi_user_window_manager()->SetWindowOwner(window(2), "c");
EXPECT_EQ("S[a], H[b], H[c]", GetStatus());
EXPECT_EQ("a", GetAndValidateCurrentUserFromSessionStateObserver());
multi_user_window_manager()->ShowWindowForUser(window(0), "b");
EXPECT_EQ("b", GetAndValidateCurrentUserFromSessionStateObserver());
EXPECT_EQ("S[a,b], S[b], H[c]", GetStatus());
multi_user_window_manager()->ShowWindowForUser(window(2), "a");
EXPECT_EQ("b", GetAndValidateCurrentUserFromSessionStateObserver());
EXPECT_EQ("S[a,b], S[b], H[c,a]", GetStatus());
multi_user_window_manager()->ShowWindowForUser(window(2), "b");
EXPECT_EQ("b", GetAndValidateCurrentUserFromSessionStateObserver());
EXPECT_EQ("S[a,b], S[b], S[c,b]", GetStatus());
multi_user_window_manager()->ShowWindowForUser(window(2), "c");
EXPECT_EQ("c", GetAndValidateCurrentUserFromSessionStateObserver());
EXPECT_EQ("H[a,b], H[b], S[c]", GetStatus());
}
}
}