| 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/avatar_menu_button.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/profiles/profiles_state.h" | 11 #include "chrome/browser/profiles/profiles_state.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 14 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" | 14 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/test_switches.h" | 18 #include "chrome/test/base/test_switches.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "components/signin/core/common/profile_management_switches.h" | |
| 21 | 20 |
| 22 class AvatarMenuButtonTest : public InProcessBrowserTest { | 21 class AvatarMenuButtonTest : public InProcessBrowserTest { |
| 23 public: | 22 public: |
| 24 AvatarMenuButtonTest(); | 23 AvatarMenuButtonTest(); |
| 25 ~AvatarMenuButtonTest() override; | 24 ~AvatarMenuButtonTest() override; |
| 26 | 25 |
| 27 protected: | 26 protected: |
| 28 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 29 void CreateTestingProfile(); | 27 void CreateTestingProfile(); |
| 30 AvatarMenuButton* GetAvatarMenuButton(); | 28 AvatarMenuButton* GetAvatarMenuButton(); |
| 31 void StartAvatarMenu(); | 29 void StartAvatarMenu(); |
| 32 | 30 |
| 33 private: | 31 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonTest); | 32 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonTest); |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 AvatarMenuButtonTest::AvatarMenuButtonTest() { | 35 AvatarMenuButtonTest::AvatarMenuButtonTest() { |
| 38 } | 36 } |
| 39 | 37 |
| 40 AvatarMenuButtonTest::~AvatarMenuButtonTest() { | 38 AvatarMenuButtonTest::~AvatarMenuButtonTest() { |
| 41 } | 39 } |
| 42 | 40 |
| 43 void AvatarMenuButtonTest::SetUpCommandLine(base::CommandLine* command_line) { | |
| 44 switches::DisableNewAvatarMenuForTesting(command_line); | |
| 45 } | |
| 46 | |
| 47 void AvatarMenuButtonTest::CreateTestingProfile() { | 41 void AvatarMenuButtonTest::CreateTestingProfile() { |
| 48 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 42 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 49 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); | 43 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); |
| 50 | 44 |
| 51 base::FilePath path; | 45 base::FilePath path; |
| 52 PathService::Get(chrome::DIR_USER_DATA, &path); | 46 PathService::Get(chrome::DIR_USER_DATA, &path); |
| 53 path = path.AppendASCII("test_profile"); | 47 path = path.AppendASCII("test_profile"); |
| 54 if (!base::PathExists(path)) | 48 if (!base::PathExists(path)) |
| 55 ASSERT_TRUE(base::CreateDirectory(path)); | 49 ASSERT_TRUE(base::CreateDirectory(path)); |
| 56 Profile* profile = | 50 Profile* profile = |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Verify that clicking again doesn't reshow it. | 99 // Verify that clicking again doesn't reshow it. |
| 106 AvatarMenuButton* button = GetAvatarMenuButton(); | 100 AvatarMenuButton* button = GetAvatarMenuButton(); |
| 107 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( | 101 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( |
| 108 NULL, gfx::Point()); | 102 NULL, gfx::Point()); |
| 109 // Hide the bubble manually. In the browser this would normally happen during | 103 // Hide the bubble manually. In the browser this would normally happen during |
| 110 // the event processing. | 104 // the event processing. |
| 111 AvatarMenuBubbleView::Hide(); | 105 AvatarMenuBubbleView::Hide(); |
| 112 base::MessageLoop::current()->RunUntilIdle(); | 106 base::MessageLoop::current()->RunUntilIdle(); |
| 113 EXPECT_FALSE(AvatarMenuBubbleView::IsShowing()); | 107 EXPECT_FALSE(AvatarMenuBubbleView::IsShowing()); |
| 114 } | 108 } |
| OLD | NEW |