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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
11 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.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_button.h" | 14 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
15 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 15 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
16 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 16 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
17 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 17 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/test_switches.h" | 21 #include "chrome/test/base/test_switches.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 23 #include "components/signin/core/common/profile_management_switches.h" |
23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
25 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
26 | 27 |
27 class NewAvatarMenuButtonTest : public InProcessBrowserTest { | 28 class NewAvatarMenuButtonTest : public InProcessBrowserTest { |
28 public: | 29 public: |
29 NewAvatarMenuButtonTest(); | 30 NewAvatarMenuButtonTest(); |
30 virtual ~NewAvatarMenuButtonTest(); | 31 virtual ~NewAvatarMenuButtonTest(); |
31 | 32 |
32 protected: | 33 protected: |
33 virtual void SetUp() OVERRIDE; | 34 virtual void SetUp() OVERRIDE; |
34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
35 void CreateTestingProfile(); | 36 void CreateTestingProfile(); |
36 void StartAvatarMenu(); | 37 void StartAvatarMenu(); |
37 | 38 |
38 private: | 39 private: |
39 DISALLOW_COPY_AND_ASSIGN(NewAvatarMenuButtonTest); | 40 DISALLOW_COPY_AND_ASSIGN(NewAvatarMenuButtonTest); |
40 }; | 41 }; |
41 | 42 |
42 NewAvatarMenuButtonTest::NewAvatarMenuButtonTest() { | 43 NewAvatarMenuButtonTest::NewAvatarMenuButtonTest() { |
43 } | 44 } |
44 | 45 |
45 NewAvatarMenuButtonTest::~NewAvatarMenuButtonTest() { | 46 NewAvatarMenuButtonTest::~NewAvatarMenuButtonTest() { |
46 } | 47 } |
47 | 48 |
48 void NewAvatarMenuButtonTest::SetUp() { | 49 void NewAvatarMenuButtonTest::SetUp() { |
49 InProcessBrowserTest::SetUp(); | 50 InProcessBrowserTest::SetUp(); |
50 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 51 DCHECK(switches::IsNewProfileManagement()); |
51 switches::kNewProfileManagement)); | |
52 } | 52 } |
53 | 53 |
54 void NewAvatarMenuButtonTest::SetUpCommandLine(CommandLine* command_line) { | 54 void NewAvatarMenuButtonTest::SetUpCommandLine(CommandLine* command_line) { |
55 command_line->AppendSwitch(switches::kNewProfileManagement); | 55 switches::EnableNewProfileManagementForTesting(command_line); |
56 } | 56 } |
57 | 57 |
58 void NewAvatarMenuButtonTest::CreateTestingProfile() { | 58 void NewAvatarMenuButtonTest::CreateTestingProfile() { |
59 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 59 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
60 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); | 60 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); |
61 | 61 |
62 // Sign in the default profile | 62 // Sign in the default profile |
63 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 63 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
64 cache.SetUserNameOfProfileAtIndex(0, base::UTF8ToUTF16("user_name")); | 64 cache.SetUserNameOfProfileAtIndex(0, base::UTF8ToUTF16("user_name")); |
65 | 65 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 window_close_observer.Wait(); // Rely on test timeout for failure indication. | 132 window_close_observer.Wait(); // Rely on test timeout for failure indication. |
133 EXPECT_TRUE(browser_list->empty()); | 133 EXPECT_TRUE(browser_list->empty()); |
134 | 134 |
135 // If the User Manager hasn't shown yet, wait for it to show up. | 135 // If the User Manager hasn't shown yet, wait for it to show up. |
136 if (!UserManagerView::IsShowing()) | 136 if (!UserManagerView::IsShowing()) |
137 base::MessageLoop::current()->RunUntilIdle(); | 137 base::MessageLoop::current()->RunUntilIdle(); |
138 | 138 |
139 // We need to hide the User Manager or else the process can't die. | 139 // We need to hide the User Manager or else the process can't die. |
140 chrome::HideUserManager(); | 140 chrome::HideUserManager(); |
141 } | 141 } |
OLD | NEW |