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