| 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 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
| 30 #include "ui/views/controls/button/label_button.h" | 30 #include "ui/views/controls/button/label_button.h" |
| 31 | 31 |
| 32 class ProfileChooserViewBrowserTest : public InProcessBrowserTest { | 32 class ProfileChooserViewBrowserTest : public InProcessBrowserTest { |
| 33 public: | 33 public: |
| 34 ProfileChooserViewBrowserTest(); | 34 ProfileChooserViewBrowserTest(); |
| 35 ~ProfileChooserViewBrowserTest() override; | 35 ~ProfileChooserViewBrowserTest() override; |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 void SetUp() override; | 38 void SetUp() override; |
| 39 void SetUpCommandLine(CommandLine* command_line) override; | 39 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 40 void OpenProfileChooserView(); | 40 void OpenProfileChooserView(); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewBrowserTest); | 43 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewBrowserTest); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 ProfileChooserViewBrowserTest::ProfileChooserViewBrowserTest() { | 46 ProfileChooserViewBrowserTest::ProfileChooserViewBrowserTest() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 ProfileChooserViewBrowserTest::~ProfileChooserViewBrowserTest() { | 49 ProfileChooserViewBrowserTest::~ProfileChooserViewBrowserTest() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void ProfileChooserViewBrowserTest::SetUp() { | 52 void ProfileChooserViewBrowserTest::SetUp() { |
| 53 InProcessBrowserTest::SetUp(); | 53 InProcessBrowserTest::SetUp(); |
| 54 DCHECK(switches::IsNewAvatarMenu()); | 54 DCHECK(switches::IsNewAvatarMenu()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ProfileChooserViewBrowserTest::SetUpCommandLine( | 57 void ProfileChooserViewBrowserTest::SetUpCommandLine( |
| 58 CommandLine* command_line) { | 58 base::CommandLine* command_line) { |
| 59 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 59 switches::EnableNewAvatarMenuForTesting( |
| 60 base::CommandLine::ForCurrentProcess()); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ProfileChooserViewBrowserTest::OpenProfileChooserView() { | 63 void ProfileChooserViewBrowserTest::OpenProfileChooserView() { |
| 63 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); | 64 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); |
| 64 NewAvatarButton* button = browser_view->frame()->GetNewAvatarMenuButton(); | 65 NewAvatarButton* button = browser_view->frame()->GetNewAvatarMenuButton(); |
| 65 ASSERT_TRUE(button); | 66 ASSERT_TRUE(button); |
| 66 | 67 |
| 67 ProfileChooserView::clear_close_on_deactivate_for_testing(); | 68 ProfileChooserView::clear_close_on_deactivate_for_testing(); |
| 68 ui::MouseEvent mouse_ev(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, | 69 ui::MouseEvent mouse_ev(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, |
| 69 0); | 70 0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 return; | 90 return; |
| 90 | 91 |
| 91 Profile* profile = browser()->profile(); | 92 Profile* profile = browser()->profile(); |
| 92 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); | 93 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); |
| 93 | 94 |
| 94 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView()); | 95 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView()); |
| 95 | 96 |
| 96 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", | 97 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", |
| 97 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW, 1); | 98 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW, 1); |
| 98 } | 99 } |
| OLD | NEW |