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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( | 62 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( |
63 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); | 63 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email)); |
64 signed_in->GetPrefs()-> | 64 signed_in->GetPrefs()-> |
65 SetString(prefs::kGoogleServicesHostedDomain, "google.com"); | 65 SetString(prefs::kGoogleServicesHostedDomain, "google.com"); |
66 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath( | 66 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath( |
67 supervised->GetPath()), signed_in_email); | 67 supervised->GetPath()), signed_in_email); |
68 | 68 |
69 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); | 69 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); |
70 } | 70 } |
71 | 71 |
72 views::View* FindWebView(views::View* view) { | |
73 std::queue<views::View*> queue; | |
74 queue.push(view); | |
75 while (!queue.empty()) { | |
76 views::View* current = queue.front(); | |
77 queue.pop(); | |
78 if (std::string(current->GetClassName()).find("WebView") != | |
Nico
2015/07/02 20:07:22
Can you introduce WebView::kViewClassName and comp
wjmaclean
2015/07/02 20:47:18
Done.
| |
79 std::string::npos) { | |
80 return current; | |
81 } | |
82 | |
83 for (int i = 0; i < current->child_count(); ++i) | |
84 queue.push(current->child_at(i)); | |
85 } | |
86 return nullptr; | |
87 } | |
88 | |
72 } // namespace | 89 } // namespace |
73 | 90 |
74 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { | 91 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { |
75 public: | 92 public: |
76 ProfileChooserViewExtensionsTest() {} | 93 ProfileChooserViewExtensionsTest() {} |
77 ~ProfileChooserViewExtensionsTest() override {} | 94 ~ProfileChooserViewExtensionsTest() override {} |
78 | 95 |
79 protected: | 96 protected: |
80 void SetUp() override { | 97 void SetUp() override { |
81 ExtensionBrowserTest::SetUp(); | 98 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. | 158 // the UserManager is created and wait for that event. |
142 if (!UserManager::IsShowing()) | 159 if (!UserManager::IsShowing()) |
143 base::MessageLoop::current()->RunUntilIdle(); | 160 base::MessageLoop::current()->RunUntilIdle(); |
144 EXPECT_TRUE(UserManager::IsShowing()); | 161 EXPECT_TRUE(UserManager::IsShowing()); |
145 } | 162 } |
146 | 163 |
147 content::WindowedNotificationObserver* window_close_observer() { | 164 content::WindowedNotificationObserver* window_close_observer() { |
148 return window_close_observer_.get(); | 165 return window_close_observer_.get(); |
149 } | 166 } |
150 | 167 |
168 ProfileChooserView* current_profile_bubble() { | |
169 return ProfileChooserView::profile_bubble_; | |
170 } | |
171 | |
172 void ShowSigninView() { | |
173 DCHECK(current_profile_bubble()); | |
174 DCHECK(current_profile_bubble()->avatar_menu_); | |
175 current_profile_bubble()->ShowView( | |
176 profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, | |
177 current_profile_bubble()->avatar_menu_.get()); | |
178 base::MessageLoop::current()->RunUntilIdle(); | |
179 } | |
180 | |
151 private: | 181 private: |
152 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; | 182 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; |
153 | 183 |
154 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); | 184 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); |
155 }; | 185 }; |
156 | 186 |
187 // crbug.com/502370 | |
188 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ContentAreaHasFocus) { | |
189 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); | |
190 | |
191 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); | |
192 | |
193 ShowSigninView(); | |
194 | |
195 ASSERT_TRUE(current_profile_bubble()); | |
196 views::View* web_view = FindWebView(current_profile_bubble()); | |
197 ASSERT_TRUE(web_view); | |
198 EXPECT_TRUE(web_view->HasFocus()); | |
199 } | |
200 | |
157 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) { | 201 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) { |
158 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); | 202 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); |
159 | 203 |
160 base::HistogramTester histograms; | 204 base::HistogramTester histograms; |
161 Profile* profile = browser()->profile(); | 205 Profile* profile = browser()->profile(); |
162 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); | 206 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); |
163 | 207 |
164 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); | 208 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); |
165 | 209 |
166 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", | 210 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 WaitForUserManager(); | 284 WaitForUserManager(); |
241 // Assert that the first profile's extensions are not blocked. | 285 // Assert that the first profile's extensions are not blocked. |
242 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); | 286 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); |
243 ASSERT_EQ(0U, registry->blocked_extensions().size()); | 287 ASSERT_EQ(0U, registry->blocked_extensions().size()); |
244 | 288 |
245 // We need to hide the User Manager or else the process can't die. | 289 // We need to hide the User Manager or else the process can't die. |
246 UserManager::Hide(); | 290 UserManager::Hide(); |
247 } | 291 } |
248 | 292 |
249 #endif | 293 #endif |
OLD | NEW |