Chromium Code Reviews| Index: chrome/browser/ui/cocoa/browser/avatar_button_controller_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/avatar_button_controller_unittest.mm |
| index 99a3b5705c05ecb1ea5598da9ac3cf7184489316..24e32b00d75c8617f6db19c863a3aa7fb38f523d 100644 |
| --- a/chrome/browser/ui/cocoa/browser/avatar_button_controller_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller_unittest.mm |
| @@ -1,36 +1,38 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| +#include "base/command_line.h" |
| #include "base/mac/scoped_nsobject.h" |
| -#include "base/strings/utf_string_conversions.h" |
| -#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| -#include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| -#include "chrome/browser/managed_mode/managed_user_service.h" |
| -#include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| -#include "chrome/browser/prefs/pref_service_syncable.h" |
| -#include "chrome/browser/search_engines/template_url_service_factory.h" |
| +#include "base/strings/sys_string_conversions.h" |
| +#include "chrome/browser/profiles/profiles_state.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/browser.h" |
| -#include "chrome/browser/ui/browser_commands.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| +#import "chrome/browser/ui/cocoa/browser/profile_chooser_controller.h" |
| #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| #include "chrome/browser/ui/cocoa/info_bubble_window.h" |
| -#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| -#include "chrome/common/pref_names.h" |
| -#include "chrome/test/base/testing_profile.h" |
| +#include "chrome/common/chrome_switches.h" |
| + |
| +static const char kDefaultProfileName[] = "default"; |
|
Nico
2014/01/14 03:56:02
nit: const has implicit internal linkage, no need
noms (inactive)
2014/01/15 22:07:47
Done.
|
| class AvatarButtonControllerTest : public CocoaProfileTest { |
| public: |
| virtual void SetUp() OVERRIDE { |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kNewProfileManagement); |
| + DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kNewProfileManagement)); |
| + DCHECK(profiles::IsMultipleProfilesEnabled()); |
| + |
| CocoaProfileTest::SetUp(); |
| ASSERT_TRUE(browser()); |
| controller_.reset( |
| [[AvatarButtonController alloc] initWithBrowser:browser()]); |
| - [[controller_ view] setHidden:YES]; |
| } |
| virtual void TearDown() OVERRIDE { |
| @@ -48,33 +50,19 @@ class AvatarButtonControllerTest : public CocoaProfileTest { |
| base::scoped_nsobject<AvatarButtonController> controller_; |
| }; |
| -TEST_F(AvatarButtonControllerTest, AddRemoveProfiles) { |
| - EXPECT_TRUE([view() isHidden]); |
| - |
| - testing_profile_manager()->CreateTestingProfile("one"); |
| - |
| +TEST_F(AvatarButtonControllerTest, ButtonShown) { |
| EXPECT_FALSE([view() isHidden]); |
| - |
| - testing_profile_manager()->CreateTestingProfile("two"); |
| - EXPECT_FALSE([view() isHidden]); |
| - |
| - testing_profile_manager()->DeleteTestingProfile("one"); |
| - EXPECT_FALSE([view() isHidden]); |
| - |
| - testing_profile_manager()->DeleteTestingProfile("two"); |
| - EXPECT_TRUE([view() isHidden]); |
| + EXPECT_EQ(kDefaultProfileName, base::SysNSStringToUTF8([button() title])); |
| } |
| TEST_F(AvatarButtonControllerTest, DoubleOpen) { |
| - // Create a second profile to enable the avatar menu. |
| - testing_profile_manager()->CreateTestingProfile("p2"); |
| - |
| EXPECT_FALSE([controller() menuController]); |
| [button() performClick:button()]; |
| BaseBubbleController* menu = [controller() menuController]; |
| EXPECT_TRUE(menu); |
| + EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]); |
| [button() performClick:button()]; |
| EXPECT_EQ(menu, [controller() menuController]); |
| @@ -84,37 +72,4 @@ TEST_F(AvatarButtonControllerTest, DoubleOpen) { |
| info_bubble::kAnimateNone; |
| [menu close]; |
| EXPECT_FALSE([controller() menuController]); |
| - |
| - testing_profile_manager()->DeleteTestingProfile("p2"); |
| -} |
| - |
| -TEST_F(AvatarButtonControllerTest, ManagedUserLabel) { |
| - DCHECK(!profile()->IsManaged()); |
| - EXPECT_FALSE([controller() labelButtonView]); |
| - |
| - // Create a second, managed profile to enable the avatar menu. |
| - std::string name = "p2"; |
| - TestingProfile* profile = testing_profile_manager()->CreateTestingProfile( |
| - name, scoped_ptr<PrefServiceSyncable>(), base::ASCIIToUTF16(name), 0, |
| - "asdf", TestingProfile::TestingFactories()); |
| - EXPECT_TRUE(profile->IsManaged()); |
| - |
| - // http://crbug.com/39725 |
| - TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| - profile, &TemplateURLServiceFactory::BuildInstanceFor); |
| - AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( |
| - profile, &AutocompleteClassifierFactory::BuildInstanceFor); |
| - profile->CreateBookmarkModel(true); |
| - test::WaitForBookmarkModelToLoad(profile); |
| - |
| - Browser* browser = |
| - new Browser(Browser::CreateParams(profile, chrome::GetActiveDesktop())); |
| - // Build a new controller to check if it is initialized correctly for a |
| - // managed user profile. |
| - base::scoped_nsobject<AvatarButtonController> controller( |
| - [[AvatarButtonController alloc] initWithBrowser:browser]); |
| - |
| - EXPECT_TRUE([controller labelButtonView]); |
| - |
| - browser->window()->Close(); |
| } |