| 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/avatar_icon_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_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 "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 // Do not animate out because that is hard to test around. | 86 // Do not animate out because that is hard to test around. |
| 87 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations = | 87 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations = |
| 88 info_bubble::kAnimateNone; | 88 info_bubble::kAnimateNone; |
| 89 [menu close]; | 89 [menu close]; |
| 90 EXPECT_FALSE([controller() menuController]); | 90 EXPECT_FALSE([controller() menuController]); |
| 91 | 91 |
| 92 testing_profile_manager()->DeleteTestingProfile("p2"); | 92 testing_profile_manager()->DeleteTestingProfile("p2"); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(AvatarIconControllerTest, ManagedUserLabel) { | 95 TEST_F(AvatarIconControllerTest, SupervisedUserLabel) { |
| 96 DCHECK(!profile()->IsManaged()); | 96 DCHECK(!profile()->IsSupervised()); |
| 97 EXPECT_FALSE([controller() labelButtonView]); | 97 EXPECT_FALSE([controller() labelButtonView]); |
| 98 | 98 |
| 99 // Create a second, managed profile to enable the avatar menu. | 99 // Create a second, supervised profile to enable the avatar menu. |
| 100 std::string name = "p2"; | 100 std::string name = "p2"; |
| 101 TestingProfile* profile = testing_profile_manager()->CreateTestingProfile( | 101 TestingProfile* profile = testing_profile_manager()->CreateTestingProfile( |
| 102 name, scoped_ptr<PrefServiceSyncable>(), base::ASCIIToUTF16(name), 0, | 102 name, scoped_ptr<PrefServiceSyncable>(), base::ASCIIToUTF16(name), 0, |
| 103 "asdf", TestingProfile::TestingFactories()); | 103 "asdf", TestingProfile::TestingFactories()); |
| 104 EXPECT_TRUE(profile->IsManaged()); | 104 EXPECT_TRUE(profile->IsSupervised()); |
| 105 | 105 |
| 106 // http://crbug.com/39725 | 106 // http://crbug.com/39725 |
| 107 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 107 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 108 profile, &TemplateURLServiceFactory::BuildInstanceFor); | 108 profile, &TemplateURLServiceFactory::BuildInstanceFor); |
| 109 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( | 109 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( |
| 110 profile, &AutocompleteClassifierFactory::BuildInstanceFor); | 110 profile, &AutocompleteClassifierFactory::BuildInstanceFor); |
| 111 profile->CreateBookmarkModel(true); | 111 profile->CreateBookmarkModel(true); |
| 112 test::WaitForBookmarkModelToLoad( | 112 test::WaitForBookmarkModelToLoad( |
| 113 BookmarkModelFactory::GetForProfile(profile)); | 113 BookmarkModelFactory::GetForProfile(profile)); |
| 114 | 114 |
| 115 Browser* browser = | 115 Browser* browser = |
| 116 new Browser(Browser::CreateParams(profile, chrome::GetActiveDesktop())); | 116 new Browser(Browser::CreateParams(profile, chrome::GetActiveDesktop())); |
| 117 // Build a new controller to check if it is initialized correctly for a | 117 // Build a new controller to check if it is initialized correctly for a |
| 118 // managed user profile. | 118 // supervised user profile. |
| 119 base::scoped_nsobject<AvatarIconController> controller( | 119 base::scoped_nsobject<AvatarIconController> controller( |
| 120 [[AvatarIconController alloc] initWithBrowser:browser]); | 120 [[AvatarIconController alloc] initWithBrowser:browser]); |
| 121 | 121 |
| 122 EXPECT_TRUE([controller labelButtonView]); | 122 EXPECT_TRUE([controller labelButtonView]); |
| 123 | 123 |
| 124 browser->window()->Close(); | 124 browser->window()->Close(); |
| 125 } | 125 } |
| OLD | NEW |