Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc

Issue 1212403004: Make sure content area is focused when signin-view bubble is opened. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use kViewClassName instead of string literal. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 (std::string(current->GetClassName())
80 .find(views::WebView::kViewClassName) != std::string::npos) {
Nico 2015/07/02 20:54:57 You can just compare with == now, right? if (cu
wjmaclean 2015/07/03 00:56:37 Done. But I'm generally loathe to compare strings
Nico 2015/07/03 01:00:23 Thanks!
81 return current;
82 }
83
84 for (int i = 0; i < current->child_count(); ++i)
85 queue.push(current->child_at(i));
86 }
87 return nullptr;
88 }
89
72 } // namespace 90 } // namespace
73 91
74 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { 92 class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest {
75 public: 93 public:
76 ProfileChooserViewExtensionsTest() {} 94 ProfileChooserViewExtensionsTest() {}
77 ~ProfileChooserViewExtensionsTest() override {} 95 ~ProfileChooserViewExtensionsTest() override {}
78 96
79 protected: 97 protected:
80 void SetUp() override { 98 void SetUp() override {
81 ExtensionBrowserTest::SetUp(); 99 ExtensionBrowserTest::SetUp();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // the UserManager is created and wait for that event. 159 // the UserManager is created and wait for that event.
142 if (!UserManager::IsShowing()) 160 if (!UserManager::IsShowing())
143 base::MessageLoop::current()->RunUntilIdle(); 161 base::MessageLoop::current()->RunUntilIdle();
144 EXPECT_TRUE(UserManager::IsShowing()); 162 EXPECT_TRUE(UserManager::IsShowing());
145 } 163 }
146 164
147 content::WindowedNotificationObserver* window_close_observer() { 165 content::WindowedNotificationObserver* window_close_observer() {
148 return window_close_observer_.get(); 166 return window_close_observer_.get();
149 } 167 }
150 168
169 ProfileChooserView* current_profile_bubble() {
170 return ProfileChooserView::profile_bubble_;
171 }
172
173 void ShowSigninView() {
174 DCHECK(current_profile_bubble());
175 DCHECK(current_profile_bubble()->avatar_menu_);
176 current_profile_bubble()->ShowView(
177 profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN,
178 current_profile_bubble()->avatar_menu_.get());
179 base::MessageLoop::current()->RunUntilIdle();
180 }
181
151 private: 182 private:
152 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_; 183 scoped_ptr<content::WindowedNotificationObserver> window_close_observer_;
153 184
154 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest); 185 DISALLOW_COPY_AND_ASSIGN(ProfileChooserViewExtensionsTest);
155 }; 186 };
156 187
188 // crbug.com/502370
189 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ContentAreaHasFocus) {
190 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled());
191
192 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser()));
193
194 ShowSigninView();
195
196 ASSERT_TRUE(current_profile_bubble());
197 views::View* web_view = FindWebView(current_profile_bubble());
198 ASSERT_TRUE(web_view);
199 EXPECT_TRUE(web_view->HasFocus());
200 }
201
157 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) { 202 IN_PROC_BROWSER_TEST_F(ProfileChooserViewExtensionsTest, ViewProfileUMA) {
158 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled()); 203 ASSERT_TRUE(profiles::IsMultipleProfilesEnabled());
159 204
160 base::HistogramTester histograms; 205 base::HistogramTester histograms;
161 Profile* profile = browser()->profile(); 206 Profile* profile = browser()->profile();
162 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0); 207 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarTutorialShown, 0);
163 208
164 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser())); 209 ASSERT_NO_FATAL_FAILURE(OpenProfileChooserView(browser()));
165 210
166 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade", 211 histograms.ExpectUniqueSample("Profile.NewAvatarMenu.Upgrade",
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 WaitForUserManager(); 285 WaitForUserManager();
241 // Assert that the first profile's extensions are not blocked. 286 // Assert that the first profile's extensions are not blocked.
242 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); 287 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size());
243 ASSERT_EQ(0U, registry->blocked_extensions().size()); 288 ASSERT_EQ(0U, registry->blocked_extensions().size());
244 289
245 // We need to hide the User Manager or else the process can't die. 290 // We need to hide the User Manager or else the process can't die.
246 UserManager::Hide(); 291 UserManager::Hide();
247 } 292 }
248 293
249 #endif 294 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698