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/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
22 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 22 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
23 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 23 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "components/signin/core/common/profile_management_switches.h" | 27 #include "components/signin/core/common/profile_management_switches.h" |
28 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
29 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
30 #include "ui/events/event_utils.h" | 30 #include "ui/events/event_utils.h" |
| 31 #include "ui/views/controls/webview/webview.h" |
31 | 32 |
32 // ChromeOS and mobile platforms don't have a ProfileChooserView. | 33 // ChromeOS and mobile platforms don't have a ProfileChooserView. |
33 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) | 34 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 Profile* CreateTestingProfile(const std::string& profile_name) { | 38 Profile* CreateTestingProfile(const std::string& profile_name) { |
38 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 39 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
39 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); | 40 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); |
40 | 41 |
(...skipping 21 matching lines...) Expand all Loading... |
62 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( | 63 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( |
63 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); | 64 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); |
64 signed_in->GetPrefs()-> | 65 signed_in->GetPrefs()-> |
65 SetString(prefs::kGoogleServicesHostedDomain, "google.com"); | 66 SetString(prefs::kGoogleServicesHostedDomain, "google.com"); |
66 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath( | 67 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath( |
67 supervised->GetPath()), signed_in_email); | 68 supervised->GetPath()), signed_in_email); |
68 | 69 |
69 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); | 70 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); |
70 } | 71 } |
71 | 72 |
| 73 views::View* FindWebView(views::View* view) { |
| 74 std::queue<views::View*> queue; |
| 75 queue.push(view); |
| 76 while (!queue.empty()) { |
| 77 views::View* current = queue.front(); |
| 78 queue.pop(); |
| 79 if (current->GetClassName() == views::WebView::kViewClassName) |
| 80 return current; |
| 81 |
| 82 for (int i = 0; i < current->child_count(); ++i) |
| 83 queue.push(current->child_at(i)); |
| 84 } |
| 85 return nullptr; |
| 86 } |
| 87 |
72 } // namespace | 88 } // namespace |
73 | 89 |
74 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { | 90 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { |
75 public: | 91 public: |
76 ProfileChooserViewExtensionsTest() {} | 92 ProfileChooserViewExtensionsTest() {} |
77 ~ProfileChooserViewExtensionsTest() override {} | 93 ~ProfileChooserViewExtensionsTest() override {} |
78 | 94 |
79 protected: | 95 protected: |
80 void SetUp() override { | 96 void SetUp() override { |
81 ExtensionBrowserTest::SetUp(); | 97 ExtensionBrowserTest::SetUp(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // the UserManager is created and wait for that event. | 157 // the UserManager is created and wait for that event. |
142 if (!UserManager::IsShowing()) | 158 if (!UserManager::IsShowing()) |
143 base::MessageLoop::current()->RunUntilIdle(); | 159 base::MessageLoop::current()->RunUntilIdle(); |
144 EXPECT_TRUE(UserManager::IsShowing()); | 160 EXPECT_TRUE(UserManager::IsShowing()); |
145 } | 161 } |
146 | 162 |
147 content::WindowedNotificationObserver* window_close_observer() { | 163 content::WindowedNotificationObserver* window_close_observer() { |
148 return window_close_observer_.get(); | 164 return window_close_observer_.get(); |
149 } | 165 } |
150 | 166 |
| 167 ProfileChooserView* current_profile_bubble() { |
| 168 return ProfileChooserView::profile_bubble_; |
| 169 } |
| 170 |
| 171 void ShowSigninView() { |
| 172 DCHECK(current_profile_bubble()); |
| 173 DCHECK(current_profile_bubble()->avatar_menu_); |
| 174 current_profile_bubble()->ShowView( |
| 175 profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, |
| 176 current_profile_bubble()->avatar_menu_.get()); |
| 177 base::MessageLoop::current()->RunUntilIdle(); |
| 178 } |
| 179 |
151 private: | 180 private: |
152 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; | 181 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; |
153 | 182 |
154 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); | 183 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); |
155 }; | 184 }; |
156 | 185 |
| 186 // crbug.com/502370 |
| 187 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ContentAreaHasFocus) { |
| 188 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); |
| 189 |
| 190 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); |
| 191 |
| 192 ShowSigninView(); |
| 193 |
| 194 ASSERT_TRUE(current_profile_bubble()); |
| 195 views::View* web_view = FindWebView(current_profile_bubble()); |
| 196 ASSERT_TRUE(web_view); |
| 197 EXPECT_TRUE(web_view->HasFocus()); |
| 198 } |
| 199 |
157 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) { | 200 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) { |
158 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); | 201 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); |
159 | 202 |
160 base::HistogramTester histograms; | 203 base::HistogramTester histograms; |
161 Profile* profile = browser()->profile(); | 204 Profile* profile = browser()->profile(); |
162 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); | 205 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); |
163 | 206 |
164 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); | 207 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); |
165 | 208 |
166 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", | 209 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 WaitForUserManager(); | 283 WaitForUserManager(); |
241 // Assert that the first profile's extensions are not blocked. | 284 // Assert that the first profile's extensions are not blocked. |
242 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); | 285 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); |
243 ASSERT_EQ(0U, registry->blocked_extensions().size()); | 286 ASSERT_EQ(0U, registry->blocked_extensions().size()); |
244 | 287 |
245 // We need to hide the User Manager or else the process can't die. | 288 // We need to hide the User Manager or else the process can't die. |
246 UserManager::Hide(); | 289 UserManager::Hide(); |
247 } | 290 } |
248 | 291 |
249 #endif | 292 #endif |
OLD | NEW |