| 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_chooser_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/avatar_menu.h" | 15 #include "chrome/browser/profiles/avatar_menu.h" |
| 15 #include "chrome/browser/profiles/profile_attributes_entry.h" | 16 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 16 #include "chrome/browser/profiles/profile_attributes_storage.h" | 17 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 17 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" | 18 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
| 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 19 #include "chrome/browser/signin/account_fetcher_service_factory.h" | 20 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
| 20 #include "chrome/browser/signin/account_tracker_service_factory.h" | 21 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 21 #include "chrome/browser/signin/chrome_signin_helper.h" | 22 #include "chrome/browser/signin/chrome_signin_helper.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 57 |
| 57 void SetUp() override { | 58 void SetUp() override { |
| 58 CocoaProfileTest::SetUp(); | 59 CocoaProfileTest::SetUp(); |
| 59 | 60 |
| 60 ASSERT_TRUE(browser()->profile()); | 61 ASSERT_TRUE(browser()->profile()); |
| 61 | 62 |
| 62 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( | 63 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( |
| 63 browser()->profile(), gcm::FakeGCMProfileService::Build); | 64 browser()->profile(), gcm::FakeGCMProfileService::Build); |
| 64 | 65 |
| 65 testing_profile_manager()->CreateTestingProfile( | 66 testing_profile_manager()->CreateTestingProfile( |
| 66 "test1", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), | 67 "test1", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), |
| 67 base::ASCIIToUTF16("Test 1"), 0, std::string(), testing_factories()); | 68 base::ASCIIToUTF16("Test 1"), 0, std::string(), testing_factories()); |
| 68 testing_profile_manager()->CreateTestingProfile( | 69 testing_profile_manager()->CreateTestingProfile( |
| 69 "test2", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), | 70 "test2", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), |
| 70 base::ASCIIToUTF16("Test 2"), 1, std::string(), | 71 base::ASCIIToUTF16("Test 2"), 1, std::string(), |
| 71 TestingProfile::TestingFactories()); | 72 TestingProfile::TestingFactories()); |
| 72 | 73 |
| 73 menu_ = new AvatarMenu( | 74 menu_ = new AvatarMenu( |
| 74 testing_profile_manager()->profile_attributes_storage(), NULL, NULL); | 75 testing_profile_manager()->profile_attributes_storage(), NULL, NULL); |
| 75 menu_->RebuildMenu(); | 76 menu_->RebuildMenu(); |
| 76 | 77 |
| 77 // There should be the default profile + two profiles we created. | 78 // There should be the default profile + two profiles we created. |
| 78 EXPECT_EQ(3U, menu_->GetNumberOfItems()); | 79 EXPECT_EQ(3U, menu_->GetNumberOfItems()); |
| 79 } | 80 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 subviews = [[subviews objectAtIndex:0] subviews]; | 284 subviews = [[subviews objectAtIndex:0] subviews]; |
| 284 | 285 |
| 285 // There should be 3 views since there's no tutorial | 286 // There should be 3 views since there's no tutorial |
| 286 ASSERT_EQ(3U, [subviews count]); | 287 ASSERT_EQ(3U, [subviews count]); |
| 287 } | 288 } |
| 288 | 289 |
| 289 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { | 290 TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { |
| 290 // Add two extra profiles, to make sure sorting is alphabetical and not | 291 // Add two extra profiles, to make sure sorting is alphabetical and not |
| 291 // by order of creation. | 292 // by order of creation. |
| 292 testing_profile_manager()->CreateTestingProfile( | 293 testing_profile_manager()->CreateTestingProfile( |
| 293 "test3", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), | 294 "test3", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), |
| 294 base::ASCIIToUTF16("New Profile"), 1, std::string(), | 295 base::ASCIIToUTF16("New Profile"), 1, std::string(), |
| 295 TestingProfile::TestingFactories()); | 296 TestingProfile::TestingFactories()); |
| 296 testing_profile_manager()->CreateTestingProfile( | 297 testing_profile_manager()->CreateTestingProfile( |
| 297 "test4", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), | 298 "test4", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), |
| 298 base::ASCIIToUTF16("Another Test"), 1, std::string(), | 299 base::ASCIIToUTF16("Another Test"), 1, std::string(), |
| 299 TestingProfile::TestingFactories()); | 300 TestingProfile::TestingFactories()); |
| 300 StartFastUserSwitcher(); | 301 StartFastUserSwitcher(); |
| 301 | 302 |
| 302 NSArray* subviews = [[[controller() window] contentView] subviews]; | 303 NSArray* subviews = [[[controller() window] contentView] subviews]; |
| 303 ASSERT_EQ(2U, [subviews count]); | 304 ASSERT_EQ(2U, [subviews count]); |
| 304 subviews = [[subviews objectAtIndex:0] subviews]; | 305 subviews = [[subviews objectAtIndex:0] subviews]; |
| 305 NSString* sortedNames[] = { @"Another Test", | 306 NSString* sortedNames[] = { @"Another Test", |
| 306 @"New Profile", | 307 @"New Profile", |
| 307 @"Test 1", | 308 @"Test 1", |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 ASSERT_EQ(5U, [buttonSubviews count]); | 562 ASSERT_EQ(5U, [buttonSubviews count]); |
| 562 | 563 |
| 563 // There should be a lock button. | 564 // There should be a lock button. |
| 564 NSButton* lockButton = | 565 NSButton* lockButton = |
| 565 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); | 566 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); |
| 566 ASSERT_TRUE(lockButton); | 567 ASSERT_TRUE(lockButton); |
| 567 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); | 568 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); |
| 568 EXPECT_EQ(controller(), [lockButton target]); | 569 EXPECT_EQ(controller(), [lockButton target]); |
| 569 EXPECT_TRUE([lockButton isEnabled]); | 570 EXPECT_TRUE([lockButton isEnabled]); |
| 570 } | 571 } |
| OLD | NEW |