Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / profiles / avatar_menu_button_browsertest.cc
blob09265e862d43510851c65f8b135cab99409a06d7
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.
5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
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"
21 class AvatarMenuButtonTest : public InProcessBrowserTest {
22 public:
23 AvatarMenuButtonTest();
24 ~AvatarMenuButtonTest() override;
26 protected:
27 void SetUpCommandLine(base::CommandLine* command_line) override;
28 void CreateTestingProfile();
29 AvatarMenuButton* GetAvatarMenuButton();
30 void StartAvatarMenu();
32 private:
33 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonTest);
36 AvatarMenuButtonTest::AvatarMenuButtonTest() {
39 AvatarMenuButtonTest::~AvatarMenuButtonTest() {
42 void AvatarMenuButtonTest::SetUpCommandLine(base::CommandLine* command_line) {
43 switches::DisableNewAvatarMenuForTesting(command_line);
46 void AvatarMenuButtonTest::CreateTestingProfile() {
47 ProfileManager* profile_manager = g_browser_process->profile_manager();
48 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles());
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());
61 AvatarMenuButton* AvatarMenuButtonTest::GetAvatarMenuButton() {
62 BrowserView* browser_view = reinterpret_cast<BrowserView*>(
63 browser()->window());
64 return browser_view->frame()->GetAvatarMenuButton();