Chromium Code Reviews| Index: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc |
| diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc |
| index 6d0e8e45c4bf9a60c3c1e97be08da56ea8d678e8..f72cd225f86dc6b8f929c952420c7b5d578ffb5f 100644 |
| --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc |
| +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos_unittest.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/command_line.h" |
| #include "base/compiler_specific.h" |
| #include "base/logging.h" |
| +#include "base/strings/string_util.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" |
| @@ -63,6 +64,9 @@ class MultiUserWindowManagerChromeOSTest : public AshTestBase { |
| // shown by A, and "D,..." would mean that window#0 is deleted. |
| std::string GetStatus(); |
| + // Returns a test-friendly string format of GetWindowOwners(). |
|
Mr4D (OOO till 08-26)
2014/01/08 20:53:53
GetOwnersOfVisibleWindows?
Jun Mukai
2014/01/08 21:20:17
Done.
|
| + std::string GetWindowOwners(); |
| + |
| TestSessionStateDelegate* session_state_delegate() { |
| return session_state_delegate_; |
| } |
| @@ -116,8 +120,8 @@ void MultiUserWindowManagerChromeOSTest::TearDown() { |
| window_.erase(window_.begin()); |
| } |
| - AshTestBase::TearDown(); |
| chrome::MultiUserWindowManager::DeleteInstance(); |
| + AshTestBase::TearDown(); |
| } |
| std::string MultiUserWindowManagerChromeOSTest::GetStatus() { |
| @@ -144,6 +148,15 @@ std::string MultiUserWindowManagerChromeOSTest::GetStatus() { |
| return s; |
| } |
| +std::string MultiUserWindowManagerChromeOSTest::GetWindowOwners() { |
| + std::set<std::string> owners; |
| + multi_user_window_manager_->GetWindowOwners(&owners); |
| + |
| + std::vector<std::string> owner_list; |
| + owner_list.insert(owner_list.begin(), owners.begin(), owners.end()); |
| + return JoinString(owner_list, ' '); |
| +} |
| + |
| // Testing basic assumptions like default state and existence of manager. |
| TEST_F(MultiUserWindowManagerChromeOSTest, BasicTests) { |
| SetUpForThisManyWindows(3); |
| @@ -226,6 +239,7 @@ TEST_F(MultiUserWindowManagerChromeOSTest, CloseWindowTests) { |
| multi_user_window_manager()->ShowWindowForUser(window(0), "A"); |
| EXPECT_EQ("S[B,A]", GetStatus()); |
| EXPECT_TRUE(multi_user_window_manager()->AreWindowsSharedAmongUsers()); |
| + EXPECT_EQ("B", GetWindowOwners()); |
| aura::Window* to_be_deleted = window(0); |
| @@ -240,6 +254,7 @@ TEST_F(MultiUserWindowManagerChromeOSTest, CloseWindowTests) { |
| delete_window_at(0); |
| EXPECT_EQ("D", GetStatus()); |
| + EXPECT_EQ("", GetWindowOwners()); |
| // There should be no owner anymore for that window and the shared windows |
| // should be gone as well. |
| EXPECT_EQ(std::string(), |
| @@ -260,6 +275,7 @@ TEST_F(MultiUserWindowManagerChromeOSTest, SharedWindowTests) { |
| 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", GetWindowOwners()); |
| // For all following tests we override window 2 to be shown by user B. |
| multi_user_window_manager()->ShowWindowForUser(window(1), "B"); |
| @@ -269,31 +285,39 @@ TEST_F(MultiUserWindowManagerChromeOSTest, SharedWindowTests) { |
| multi_user_window_manager()->ShowWindowForUser(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", GetWindowOwners()); |
| multi_user_window_manager()->ShowWindowForUser(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", GetWindowOwners()); |
| // Switch the users and see that the results are correct. |
| 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", GetWindowOwners()); |
| 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", GetWindowOwners()); |
| // Showing on the desktop of the already owning user should have no impact. |
| multi_user_window_manager()->ShowWindowForUser(window(4), "C"); |
| EXPECT_EQ("H[A], H[A,B], S[B,C], H[B], S[C]", GetStatus()); |
| + EXPECT_EQ("B C", GetWindowOwners()); |
| // Changing however a shown window back to the original owner should hide it. |
| multi_user_window_manager()->ShowWindowForUser(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", GetWindowOwners()); |
| // And the change should be "permanent" - switching somewhere else and coming |
| // back. |
| multi_user_window_manager()->ActiveUserChanged("B"); |
| EXPECT_EQ("H[A], S[A,B], S[B], S[B], H[C]", GetStatus()); |
|
Mr4D (OOO till 08-26)
2014/01/08 20:53:53
Thanks for adding these tests!
|
| + EXPECT_EQ("A B", GetWindowOwners()); |
| multi_user_window_manager()->ActiveUserChanged("C"); |
| EXPECT_EQ("H[A], H[A,B], H[B], H[B], S[C]", GetStatus()); |
| + EXPECT_EQ("C", GetWindowOwners()); |
| // After switching window 2 back to its original desktop, all desktops should |
| // be "clean" again. |