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 "base/macros.h" | 7 #include "base/macros.h" |
8 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 8 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
10 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 10 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }; | 88 }; |
89 | 89 |
90 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { | 90 TEST_F(BrowserFinderChromeOSTest, IncognitoBrowserMatchTest) { |
91 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). | 91 // GetBrowserCount() use kMatchAll to find all browser windows for profile(). |
92 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); | 92 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); |
93 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 93 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
94 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); | 94 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); |
95 set_browser(nullptr); | 95 set_browser(nullptr); |
96 | 96 |
97 // Create an incognito browser. | 97 // Create an incognito browser. |
98 Browser::CreateParams params(profile()->GetOffTheRecordProfile(), | 98 Browser::CreateParams params(profile()->GetOffTheRecordProfile()); |
99 chrome::HOST_DESKTOP_TYPE_ASH); | |
100 scoped_ptr<Browser> incognito_browser( | 99 scoped_ptr<Browser> incognito_browser( |
101 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 100 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
102 // Incognito windows are excluded in GetBrowserCount() because kMatchAll | 101 // Incognito windows are excluded in GetBrowserCount() because kMatchAll |
103 // doesn't match original profile of the browser with the given profile. | 102 // doesn't match original profile of the browser with the given profile. |
104 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); | 103 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); |
105 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 104 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
106 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); | 105 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); |
107 } | 106 } |
108 | 107 |
109 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { | 108 TEST_F(BrowserFinderChromeOSTest, FindBrowserOwnedByAnotherProfile) { |
110 set_browser(nullptr); | 109 set_browser(nullptr); |
111 | 110 |
112 Browser::CreateParams params(profile()->GetOriginalProfile(), | 111 Browser::CreateParams params(profile()->GetOriginalProfile()); |
113 chrome::HOST_DESKTOP_TYPE_ASH); | |
114 scoped_ptr<Browser> browser( | 112 scoped_ptr<Browser> browser( |
115 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 113 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
116 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), | 114 GetUserWindowManager()->SetWindowOwner(browser->window()->GetNativeWindow(), |
117 test_account_id1_); | 115 test_account_id1_); |
118 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); | 116 EXPECT_EQ(1u, chrome::GetBrowserCount(profile())); |
119 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); | 117 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), true)); |
120 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); | 118 EXPECT_TRUE(chrome::FindAnyBrowser(profile(), false)); |
121 | 119 |
122 // Move the browser window to another user's desktop. Then no window should | 120 // Move the browser window to another user's desktop. Then no window should |
123 // be available for the current profile. | 121 // be available for the current profile. |
124 GetUserWindowManager()->ShowWindowForUser( | 122 GetUserWindowManager()->ShowWindowForUser( |
125 browser->window()->GetNativeWindow(), test_account_id2_); | 123 browser->window()->GetNativeWindow(), test_account_id2_); |
126 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); | 124 EXPECT_EQ(0u, chrome::GetBrowserCount(profile())); |
127 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true)); | 125 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), true)); |
128 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); | 126 EXPECT_FALSE(chrome::FindAnyBrowser(profile(), false)); |
129 } | 127 } |
130 | 128 |
131 } // namespace test | 129 } // namespace test |
OLD | NEW |