| 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 "ash/common/test/test_session_state_delegate.h" | 7 #include "ash/common/test/test_session_state_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_helper.h" | 9 #include "ash/test/ash_test_helper.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { | 111 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { |
| 112 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). | 112 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). |
| 113 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); | 113 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); |
| 114 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 114 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
| 115 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); | 115 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); |
| 116 set_browser(nullptr); | 116 set_browser(nullptr); |
| 117 | 117 |
| 118 // Create an incognito browser. | 118 // Create an incognito browser. |
| 119 Browser::CreateParams params(profile()->GetOffTheRecordProfile()); | 119 Browser::CreateParams params(profile()->GetOffTheRecordProfile(), true); |
| 120 std::unique_ptr<Browser> incognito_browser( | 120 std::unique_ptr<Browser> incognito_browser( |
| 121 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 121 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 122 // Incognito windows are excluded in GetBrowserCount() because kMatchAll | 122 // Incognito windows are excluded in GetBrowserCount() because kMatchAll |
| 123 // doesn't match original profile of the browser with the given profile. | 123 // doesn't match original profile of the browser with the given profile. |
| 124 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); | 124 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); |
| 125 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 125 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
| 126 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); | 126 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { | 129 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { |
| 130 set_browser(nullptr); | 130 set_browser(nullptr); |
| 131 | 131 |
| 132 Browser::CreateParams params(profile()->GetOriginalProfile()); | 132 Browser::CreateParams params(profile()->GetOriginalProfile(), true); |
| 133 std::unique_ptr<Browser> browser( | 133 std::unique_ptr<Browser> browser( |
| 134 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 134 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 135 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), | 135 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), |
| 136 test_account_id1_); | 136 test_account_id1_); |
| 137 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); | 137 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); |
| 138 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 138 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
| 139 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); | 139 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); |
| 140 | 140 |
| 141 // Move the browser window to another user's desktop. Then no window should | 141 // Move the browser window to another user's desktop. Then no window should |
| 142 // be available for the current profile. | 142 // be available for the current profile. |
| 143 GetUserWindowManager()->ShowWindowForUser( | 143 GetUserWindowManager()->ShowWindowForUser( |
| 144 browser->window()->GetNativeWindow(), test_account_id2_); | 144 browser->window()->GetNativeWindow(), test_account_id2_); |
| 145 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); | 145 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); |
| 146 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true)); | 146 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true)); |
| 147 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); | 147 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace test | 150 } // namespace test |
| OLD | NEW |