| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/path_service.h" | |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "chrome/browser/profiles/profile_manager.h" | |
| 11 #include "chrome/browser/profiles/profiles_state.h" | |
| 12 #include "chrome/browser/ui/browser_list.h" | |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 14 #include "chrome/common/chrome_paths.h" | |
| 15 #include "chrome/common/chrome_switches.h" | |
| 16 #include "chrome/test/base/in_process_browser_test.h" | |
| 17 #include "chrome/test/base/test_switches.h" | |
| 18 #include "chrome/test/base/testing_browser_process.h" | |
| 19 #include "components/signin/core/common/profile_management_switches.h" | |
| 20 | |
| 21 class AvatarMenuButtonTest : public InProcessBrowserTest { | |
| 22 public: | |
| 23 AvatarMenuButtonTest(); | |
| 24 ~AvatarMenuButtonTest() override; | |
| 25 | |
| 26 protected: | |
| 27 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 28 void CreateTestingProfile(); | |
| 29 AvatarMenuButton* GetAvatarMenuButton(); | |
| 30 void StartAvatarMenu(); | |
| 31 | |
| 32 private: | |
| 33 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonTest); | |
| 34 }; | |
| 35 | |
| 36 AvatarMenuButtonTest::AvatarMenuButtonTest() { | |
| 37 } | |
| 38 | |
| 39 AvatarMenuButtonTest::~AvatarMenuButtonTest() { | |
| 40 } | |
| 41 | |
| 42 void AvatarMenuButtonTest::SetUpCommandLine(base::CommandLine* command_line) { | |
| 43 switches::DisableNewAvatarMenuForTesting(command_line); | |
| 44 } | |
| 45 | |
| 46 void AvatarMenuButtonTest::CreateTestingProfile() { | |
| 47 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 48 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); | |
| 49 | |
| 50 base::FilePath path; | |
| 51 PathService::Get(chrome::DIR_USER_DATA, &path); | |
| 52 path = path.AppendASCII("test_profile"); | |
| 53 if (!base::PathExists(path)) | |
| 54 ASSERT_TRUE(base::CreateDirectory(path)); | |
| 55 Profile* profile = | |
| 56 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | |
| 57 profile_manager->RegisterTestingProfile(profile, true, false); | |
| 58 EXPECT_EQ(2u, profile_manager->GetNumberOfProfiles()); | |
| 59 } | |
| 60 | |
| 61 AvatarMenuButton* AvatarMenuButtonTest::GetAvatarMenuButton() { | |
| 62 BrowserView* browser_view = reinterpret_cast<BrowserView*>( | |
| 63 browser()->window()); | |
| 64 return browser_view->frame()->GetAvatarMenuButton(); | |
| 65 } | |
| OLD | NEW |