OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full | 195 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full |
196 // BrowserWindow, so it is called manually. | 196 // BrowserWindow, so it is called manually. |
197 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) { | 197 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) { |
198 NSMenu* menu = [controller() menu]; | 198 NSMenu* menu = [controller() menu]; |
199 TestingProfileManager* manager = testing_profile_manager(); | 199 TestingProfileManager* manager = testing_profile_manager(); |
200 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2"); | 200 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2"); |
201 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3"); | 201 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3"); |
202 ASSERT_EQ(7, [menu numberOfItems]); | 202 ASSERT_EQ(7, [menu numberOfItems]); |
203 | 203 |
204 // Create a browser and "show" it. | 204 // Create a browser and "show" it. |
205 Browser::CreateParams profile2_params(profile2, chrome::GetActiveDesktop()); | 205 Browser::CreateParams profile2_params(profile2); |
206 scoped_ptr<Browser> p2_browser( | 206 scoped_ptr<Browser> p2_browser( |
207 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 207 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
208 BrowserList::SetLastActive(p2_browser.get()); | 208 BrowserList::SetLastActive(p2_browser.get()); |
209 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); | 209 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); |
210 | 210 |
211 // Close the browser and make sure it's still active. | 211 // Close the browser and make sure it's still active. |
212 p2_browser.reset(); | 212 p2_browser.reset(); |
213 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); | 213 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); |
214 | 214 |
215 // Open a new browser and make sure it takes effect. | 215 // Open a new browser and make sure it takes effect. |
216 Browser::CreateParams profile3_params(profile3, chrome::GetActiveDesktop()); | 216 Browser::CreateParams profile3_params(profile3); |
217 scoped_ptr<Browser> p3_browser( | 217 scoped_ptr<Browser> p3_browser( |
218 chrome::CreateBrowserWithTestWindowForParams(&profile3_params)); | 218 chrome::CreateBrowserWithTestWindowForParams(&profile3_params)); |
219 BrowserList::SetLastActive(p3_browser.get()); | 219 BrowserList::SetLastActive(p3_browser.get()); |
220 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); | 220 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); |
221 | 221 |
222 p3_browser.reset(); | 222 p3_browser.reset(); |
223 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); | 223 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); |
224 } | 224 } |
225 | 225 |
226 TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) { | 226 TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 item = [menu itemAtIndex:1]; | 273 item = [menu itemAtIndex:1]; |
274 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); | 274 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); |
275 EXPECT_TRUE([controller() validateMenuItem:item]); | 275 EXPECT_TRUE([controller() validateMenuItem:item]); |
276 | 276 |
277 item = [menu itemAtIndex:5]; | 277 item = [menu itemAtIndex:5]; |
278 ASSERT_EQ(@selector(newProfile:), [item action]); | 278 ASSERT_EQ(@selector(newProfile:), [item action]); |
279 EXPECT_TRUE([controller() validateMenuItem:item]); | 279 EXPECT_TRUE([controller() validateMenuItem:item]); |
280 | 280 |
281 // Open a new browser for the supervised user and switch to it. | 281 // Open a new browser for the supervised user and switch to it. |
282 Browser::CreateParams supervised_profile_params( | 282 Browser::CreateParams supervised_profile_params(supervised_profile); |
283 supervised_profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | |
284 scoped_ptr<Browser> supervised_browser( | 283 scoped_ptr<Browser> supervised_browser( |
285 chrome::CreateBrowserWithTestWindowForParams(&supervised_profile_params)); | 284 chrome::CreateBrowserWithTestWindowForParams(&supervised_profile_params)); |
286 BrowserList::SetLastActive(supervised_browser.get()); | 285 BrowserList::SetLastActive(supervised_browser.get()); |
287 | 286 |
288 item = [menu itemAtIndex:0]; | 287 item = [menu itemAtIndex:0]; |
289 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); | 288 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); |
290 EXPECT_FALSE([controller() validateMenuItem:item]); | 289 EXPECT_FALSE([controller() validateMenuItem:item]); |
291 | 290 |
292 item = [menu itemAtIndex:1]; | 291 item = [menu itemAtIndex:1]; |
293 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); | 292 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); |
294 EXPECT_TRUE([controller() validateMenuItem:item]); | 293 EXPECT_TRUE([controller() validateMenuItem:item]); |
295 | 294 |
296 item = [menu itemAtIndex:5]; | 295 item = [menu itemAtIndex:5]; |
297 ASSERT_EQ(@selector(newProfile:), [item action]); | 296 ASSERT_EQ(@selector(newProfile:), [item action]); |
298 EXPECT_FALSE([controller() validateMenuItem:item]); | 297 EXPECT_FALSE([controller() validateMenuItem:item]); |
299 } | 298 } |
OLD | NEW |