| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "chrome/browser/ui/browser_finder.h" | 5 #include "chrome/browser/ui/browser_finder.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 7 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 8 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 8 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 10 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 TestingProfile* second_profile_; | 76 TestingProfile* second_profile_; |
| 77 scoped_ptr<TestingProfileManager> profile_manager_; | 77 scoped_ptr<TestingProfileManager> profile_manager_; |
| 78 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; | 78 chrome::MultiUserWindowManagerChromeOS* multi_user_window_manager_; |
| 79 | 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(BrowserFinderChromeOSTest); | 80 DISALLOW_COPY_AND_ASSIGN(BrowserFinderChromeOSTest); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { | 83 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { |
| 84 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). | 84 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). |
| 85 EXPECT_EQ(1u, | 85 EXPECT_EQ(1u, chrome::GetBrowserCount(profile(), ui::HOST_DESKTOP_TYPE_ASH)); |
| 86 chrome::GetBrowserCount(profile(), chrome::HOST_DESKTOP_TYPE_ASH)); | |
| 87 EXPECT_TRUE( | 86 EXPECT_TRUE( |
| 88 chrome::FindAnyBrowser(profile(), true, chrome::HOST_DESKTOP_TYPE_ASH)); | 87 chrome::FindAnyBrowser(profile(), true, ui::HOST_DESKTOP_TYPE_ASH)); |
| 89 EXPECT_TRUE( | 88 EXPECT_TRUE( |
| 90 chrome::FindAnyBrowser(profile(), false, chrome::HOST_DESKTOP_TYPE_ASH)); | 89 chrome::FindAnyBrowser(profile(), false, ui::HOST_DESKTOP_TYPE_ASH)); |
| 91 set_browser(nullptr); | 90 set_browser(nullptr); |
| 92 | 91 |
| 93 // Create an incognito browser. | 92 // Create an incognito browser. |
| 94 Browser::CreateParams params(profile()->GetOffTheRecordProfile(), | 93 Browser::CreateParams params(profile()->GetOffTheRecordProfile(), |
| 95 chrome::HOST_DESKTOP_TYPE_ASH); | 94 ui::HOST_DESKTOP_TYPE_ASH); |
| 96 scoped_ptr<Browser> incognito_browser( | 95 scoped_ptr<Browser> incognito_browser( |
| 97 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 96 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 98 // Incognito windows are excluded in GetBrowserCount() because kMatchAll | 97 // Incognito windows are excluded in GetBrowserCount() because kMatchAll |
| 99 // doesn't match original profile of the browser with the given profile. | 98 // doesn't match original profile of the browser with the given profile. |
| 100 EXPECT_EQ(0u, | 99 EXPECT_EQ(0u, chrome::GetBrowserCount(profile(), ui::HOST_DESKTOP_TYPE_ASH)); |
| 101 chrome::GetBrowserCount(profile(), chrome::HOST_DESKTOP_TYPE_ASH)); | |
| 102 EXPECT_TRUE( | 100 EXPECT_TRUE( |
| 103 chrome::FindAnyBrowser(profile(), true, chrome::HOST_DESKTOP_TYPE_ASH)); | 101 chrome::FindAnyBrowser(profile(), true, ui::HOST_DESKTOP_TYPE_ASH)); |
| 104 EXPECT_FALSE( | 102 EXPECT_FALSE( |
| 105 chrome::FindAnyBrowser(profile(), false, chrome::HOST_DESKTOP_TYPE_ASH)); | 103 chrome::FindAnyBrowser(profile(), false, ui::HOST_DESKTOP_TYPE_ASH)); |
| 106 } | 104 } |
| 107 | 105 |
| 108 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { | 106 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { |
| 109 set_browser(nullptr); | 107 set_browser(nullptr); |
| 110 | 108 |
| 111 Browser::CreateParams params(profile()->GetOriginalProfile(), | 109 Browser::CreateParams params(profile()->GetOriginalProfile(), |
| 112 chrome::HOST_DESKTOP_TYPE_ASH); | 110 ui::HOST_DESKTOP_TYPE_ASH); |
| 113 scoped_ptr<Browser> browser( | 111 scoped_ptr<Browser> browser( |
| 114 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 112 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 115 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), | 113 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), |
| 116 kTestAccount1); | 114 kTestAccount1); |
| 117 EXPECT_EQ(1u, | 115 EXPECT_EQ(1u, chrome::GetBrowserCount(profile(), ui::HOST_DESKTOP_TYPE_ASH)); |
| 118 chrome::GetBrowserCount(profile(), chrome::HOST_DESKTOP_TYPE_ASH)); | |
| 119 EXPECT_TRUE( | 116 EXPECT_TRUE( |
| 120 chrome::FindAnyBrowser(profile(), true, chrome::HOST_DESKTOP_TYPE_ASH)); | 117 chrome::FindAnyBrowser(profile(), true, ui::HOST_DESKTOP_TYPE_ASH)); |
| 121 EXPECT_TRUE( | 118 EXPECT_TRUE( |
| 122 chrome::FindAnyBrowser(profile(), false, chrome::HOST_DESKTOP_TYPE_ASH)); | 119 chrome::FindAnyBrowser(profile(), false, ui::HOST_DESKTOP_TYPE_ASH)); |
| 123 | 120 |
| 124 // Move the browser window to another user's desktop. Then no window should | 121 // Move the browser window to another user's desktop. Then no window should |
| 125 // be available for the current profile. | 122 // be available for the current profile. |
| 126 GetUserWindowManager()->ShowWindowForUser( | 123 GetUserWindowManager()->ShowWindowForUser( |
| 127 browser->window()->GetNativeWindow(), kTestAccount2); | 124 browser->window()->GetNativeWindow(), kTestAccount2); |
| 128 EXPECT_EQ(0u, | 125 EXPECT_EQ(0u, chrome::GetBrowserCount(profile(), ui::HOST_DESKTOP_TYPE_ASH)); |
| 129 chrome::GetBrowserCount(profile(), chrome::HOST_DESKTOP_TYPE_ASH)); | |
| 130 EXPECT_FALSE( | 126 EXPECT_FALSE( |
| 131 chrome::FindAnyBrowser(profile(), true, chrome::HOST_DESKTOP_TYPE_ASH)); | 127 chrome::FindAnyBrowser(profile(), true, ui::HOST_DESKTOP_TYPE_ASH)); |
| 132 EXPECT_FALSE( | 128 EXPECT_FALSE( |
| 133 chrome::FindAnyBrowser(profile(), false, chrome::HOST_DESKTOP_TYPE_ASH)); | 129 chrome::FindAnyBrowser(profile(), false, ui::HOST_DESKTOP_TYPE_ASH)); |
| 134 } | 130 } |
| 135 | 131 |
| 136 } // namespace test | 132 } // namespace test |
| OLD | NEW |