| Index: chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
|
| diff --git a/chrome/browser/ui/views/profiles/new_avatar_menu_button_browsertest.cc b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
|
| similarity index 60%
|
| copy from chrome/browser/ui/views/profiles/new_avatar_menu_button_browsertest.cc
|
| copy to chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
|
| index 137a80b605ee63cb14d0a3abbd925174c3164946..712592a70439281a9adb86ce881fb9f2dddefb26 100644
|
| --- a/chrome/browser/ui/views/profiles/new_avatar_menu_button_browsertest.cc
|
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
|
| @@ -1,61 +1,67 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2013 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.
|
|
|
| #include "base/command_line.h"
|
| #include "base/path_service.h"
|
| +#include "base/prefs/pref_service.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/profiles/profile_metrics.h"
|
| #include "chrome/browser/profiles/profiles_state.h"
|
| #include "chrome/browser/ui/browser_dialogs.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/views/avatar_menu_button.h"
|
| #include "chrome/browser/ui/views/frame/browser_view.h"
|
| -#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
|
| -#include "chrome/browser/ui/views/profiles/new_avatar_button.h"
|
| -#include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
|
| -#include "chrome/browser/ui/views/profiles/user_manager_view.h"
|
| +#include "chrome/browser/ui/views/new_avatar_button.h"
|
| +#include "chrome/browser/ui/views/profile_chooser_view.h"
|
| +#include "chrome/browser/ui/views/user_manager_view.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "chrome/common/profile_management_switches.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/test_switches.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| +#include "chrome/test/base/uma_histogram_helper.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/views/controls/button/label_button.h"
|
|
|
| -class NewAvatarMenuButtonTest : public InProcessBrowserTest {
|
| +class ProfileChooserViewBrowserTest : public InProcessBrowserTest {
|
| public:
|
| - NewAvatarMenuButtonTest();
|
| - virtual ~NewAvatarMenuButtonTest();
|
| + ProfileChooserViewBrowserTest();
|
| + virtual ~ProfileChooserViewBrowserTest();
|
|
|
| protected:
|
| virtual void SetUp() OVERRIDE;
|
| virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
|
| void CreateTestingProfile();
|
| - void StartAvatarMenu();
|
| + void OpenProfileChooserView();
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(NewAvatarMenuButtonTest);
|
| + DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewBrowserTest);
|
| };
|
|
|
| -NewAvatarMenuButtonTest::NewAvatarMenuButtonTest() {
|
| +ProfileChooserViewBrowserTest::ProfileChooserViewBrowserTest() {
|
| }
|
|
|
| -NewAvatarMenuButtonTest::~NewAvatarMenuButtonTest() {
|
| +ProfileChooserViewBrowserTest::~ProfileChooserViewBrowserTest() {
|
| }
|
|
|
| -void NewAvatarMenuButtonTest::SetUp() {
|
| +void ProfileChooserViewBrowserTest::SetUp() {
|
| InProcessBrowserTest::SetUp();
|
| DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kNewProfileManagement));
|
| }
|
|
|
| -void NewAvatarMenuButtonTest::SetUpCommandLine(CommandLine* command_line) {
|
| +void ProfileChooserViewBrowserTest::SetUpCommandLine(
|
| + CommandLine* command_line) {
|
| command_line->AppendSwitch(switches::kNewProfileManagement);
|
| }
|
|
|
| -void NewAvatarMenuButtonTest::CreateTestingProfile() {
|
| +void ProfileChooserViewBrowserTest::CreateTestingProfile() {
|
| ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles());
|
|
|
| @@ -70,13 +76,15 @@ void NewAvatarMenuButtonTest::CreateTestingProfile() {
|
| ASSERT_TRUE(base::CreateDirectory(path));
|
| Profile* profile =
|
| Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
|
| + profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0);
|
| profile_manager->RegisterTestingProfile(profile, true, false);
|
| EXPECT_EQ(2u, profile_manager->GetNumberOfProfiles());
|
| }
|
|
|
| -void NewAvatarMenuButtonTest::StartAvatarMenu() {
|
| +void ProfileChooserViewBrowserTest::OpenProfileChooserView() {
|
| BrowserView* browser_view = reinterpret_cast<BrowserView*>(
|
| browser()->window());
|
| + UMAHistogramHelper histograms;
|
|
|
| // Ensure that the avatar icon button is not also showing.
|
| NewAvatarButton* button = browser_view->frame()->GetNewAvatarMenuButton();
|
| @@ -88,49 +96,34 @@ void NewAvatarMenuButtonTest::StartAvatarMenu() {
|
| 0);
|
| button->NotifyClick(mouse_ev);
|
| base::MessageLoop::current()->RunUntilIdle();
|
| +
|
| EXPECT_TRUE(ProfileChooserView::IsShowing());
|
| }
|
|
|
| -#if defined(OS_CHROMEOS) || defined (OS_LINUX) || defined (OS_WIN)
|
| +#if defined(OS_CHROMEOS) || defined (OS_LINUX)
|
| // This test doesn't make sense for ChromeOS since it has a different
|
| // multi-profiles menu in the system tray instead.
|
| //
|
| -// Test fails flakily on Linux and Windows http://crbug.com/352710
|
| -#define MAYBE_SignOut DISABLED_SignOut
|
| +// Expect tests to be flaky on Linux, since this test was copied from
|
| +// new_avatar_menu_button_browsertest.cc, which quotes http://crbug.com/352710.
|
| +// Windows test verified as working even despite original having flaky behavior.
|
| +#define MAYBE_ViewProfileUMA DISABLED_ViewProfileUMA
|
| #else
|
| -#define MAYBE_SignOut SignOut
|
| +#define MAYBE_ViewProfileUMA ViewProfileUMA
|
| #endif
|
|
|
| -IN_PROC_BROWSER_TEST_F(NewAvatarMenuButtonTest, MAYBE_SignOut) {
|
| +IN_PROC_BROWSER_TEST_F(ProfileChooserViewBrowserTest, MAYBE_ViewProfileUMA) {
|
| + UMAHistogramHelper histograms;
|
| // If multiprofile mode is not enabled, you can't switch between profiles.
|
| if (!profiles::IsMultipleProfilesEnabled())
|
| return;
|
|
|
| CreateTestingProfile();
|
| - ASSERT_NO_FATAL_FAILURE(StartAvatarMenu());
|
| -
|
| - BrowserList* browser_list =
|
| - BrowserList::GetInstance(chrome::GetActiveDesktop());
|
| - EXPECT_EQ(1U, browser_list->size());
|
| - content::WindowedNotificationObserver window_close_observer(
|
| - chrome::NOTIFICATION_BROWSER_CLOSED,
|
| - content::Source<Browser>(browser()));
|
| -
|
| - AvatarMenu* menu =
|
| - ProfileChooserView::profile_bubble_->avatar_menu_.get();
|
| - const AvatarMenu::Item& menu_item_before =
|
| - menu->GetItemAt(menu->GetActiveProfileIndex());
|
| - EXPECT_FALSE(menu_item_before.signin_required);
|
| -
|
| - ui::MouseEvent mouse_ev(
|
| - ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, 0);
|
| - ProfileChooserView::profile_bubble_->ButtonPressed(
|
| - ProfileChooserView::profile_bubble_->lock_button_, mouse_ev);
|
| -
|
| - EXPECT_TRUE(menu->GetItemAt(menu->GetActiveProfileIndex()).signin_required);
|
| -
|
| - window_close_observer.Wait(); // Rely on test timeout for failure indication.
|
| - EXPECT_TRUE(browser_list->empty());
|
| + ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView());
|
| +
|
| + histograms.Fetch();
|
| + histograms.ExpectUniqueSample("Profile.Enrollment",
|
| + ProfileMetrics::ENROLL_DISPLAY, 1);
|
|
|
| // If the User Manager hasn't shown yet, wait for it to show up.
|
| if (!UserManagerView::IsShowing())
|
|
|