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

Side by Side Diff: chrome/test/functional/infobars.py

Issue 10152004: Add tests for one-click sign in infobar. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import re 8 import re
9 9
10 import pyauto_functional # Must be imported before pyauto 10 import pyauto_functional # Must be imported before pyauto
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 msg='Did not expect crash infobar in tab at index %d' % i) 176 msg='Did not expect crash infobar in tab at index %d' % i)
177 elif urls_type[i]: 177 elif urls_type[i]:
178 self.assertTrue( 178 self.assertTrue(
179 self.WaitForInfobarCount(1, windex=0, tab_index=i), 179 self.WaitForInfobarCount(1, windex=0, tab_index=i),
180 msg='Expected crash infobar in tab at index %d' % i) 180 msg='Expected crash infobar in tab at index %d' % i)
181 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][i]['infobars'] 181 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][i]['infobars']
182 self.assertEqual(infobar[0]['type'], 'confirm_infobar') 182 self.assertEqual(infobar[0]['type'], 'confirm_infobar')
183 self.assertEqual(len(infobar), 1) 183 self.assertEqual(len(infobar), 1)
184 184
185 185
186 class OneClickInfobarTest(pyauto.PyUITest):
187 """Tests for one-click sign in infobar."""
188
189 BLOCK_COOKIE_PATTERN = {'https://accounts.google.com/': {'cookies': 2}}
190 OC_INFOBAR_TYPE = 'oneclicklogin_infobar'
191 PW_INFOBAR_TYPE = 'password_infobar'
192 URL = 'https://www.google.com/accounts/ServiceLogin'
193 URL_LOGIN = 'https://www.google.com/accounts/Login'
194 URL_LOGOUT = 'https://www.google.com/accounts/Logout'
195
196 def setUp(self):
197 pyauto.PyUITest.setUp(self)
198 self._driver = self.NewWebDriver()
199
200 def _LogIntoGoogleAccount(self, tab_index=0, windex=0):
201 """Log into Google account.
202
203 Args:
204 tab_index: The tab index, default is 0.
205 windex: The window index, default is 0.
206 """
207 creds = self.GetPrivateInfo()['test_google_account']
208 username = creds['username']
209 password = creds['password']
210 test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex)
211 # Wait until page completes loading.
212 self.WaitUntil(
Nirnimesh 2012/04/23 22:07:45 Suggestion: Craig recently (actually, 2 hours ago
dyu1 2012/04/23 22:53:09 Done.
213 lambda: self.GetDOMValue('document.readyState'),
214 expect_retval='complete')
215
216 def _PerformActionOnInfobar(self, action):
217 """Perform an action on the infobar: accept, cancel, or dismiss.
218
219 If action is accept then the account is synced.
220
221 Args:
222 action: The action to perform on the infobar.
223 """
224 self.PerformActionOnInfobar(
225 action, infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
226 self, self.OC_INFOBAR_TYPE))
227
228 def testDisplayOneClickInfobar(self, tab_index=0, windex=0):
Nirnimesh 2012/04/23 22:07:45 what are the args for? I don't see them used anywh
dyu1 2012/04/23 22:53:09 Used on line 289. On 2012/04/23 22:07:45, Nirnime
229 """Verify one-click infobar appears after logging into google account.
230
231 One-click infobar should appear after signing into a google account
232 for the first time using a clean profile.
233 """
234 self._LogIntoGoogleAccount(tab_index=0, windex=0)
Nirnimesh 2012/04/23 22:07:45 pass along tab_index & windex, instead of hardcodi
dyu1 2012/04/23 22:53:09 Done.
235 self.assertTrue(self.WaitUntil(
236 lambda: test_utils.GetInfobarIndexByType(
237 self, self.OC_INFOBAR_TYPE, tab_index=0, windex=0) is not None),
238 msg='The one-click login infobar did not appear.')
239
240 def testNoOneClickInfobarAfterCancel(self):
241 """Verify one-click infobar does not appear again after clicking cancel.
242
243 The one-click infobar should not display again after logging into an
244 account and selecting to reject sync the first time.
245
246 This test also verifies that the password infobar displays.
247 """
248 self.testDisplayOneClickInfobar
dennis_jeffrey 2012/04/23 21:59:52 need parens? Also, this is not a big deal, but I'
Nirnimesh 2012/04/23 22:07:45 this is a no-op. You didn't call it.
dyu1 2012/04/23 22:53:09 Done.
dyu1 2012/04/23 22:53:09 Yes I thought of that originally but then that one
dennis_jeffrey 2012/04/23 23:19:32 I don't consider my recommendation as evil at all
249 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button.
250 self.NavigateToURL(self.URL_LOGOUT)
251 self._LogIntoGoogleAccount()
252 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
253 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE)
254
255 def testDisplayOneClickInfobarAfterDismiss(self):
256 """Verify one-click infobar appears again after clicking dismiss button.
257
258 The one-click infobar should display again after logging into an
259 account and clicking to dismiss the infobar the first time.
260
261 This test also verifies that the password infobar does not display.
262 The one-click infobar should supersede the password infobar.
263 """
264 self.testDisplayOneClickInfobar
dennis_jeffrey 2012/04/23 21:59:52 need parens?
dyu1 2012/04/23 22:53:09 Done.
265 self._PerformActionOnInfobar(action='dismiss') # Click 'x' button.
266 self.NavigateToURL(self.URL_LOGOUT)
267 self._LogIntoGoogleAccount()
268 test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
269 test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE)
270
271 def _CheckNumProfiles(self, expected_number):
272 """Returns True if |expected_number| is equal to the number of profiles."""
273 # TODO(dyu): Remove when crbug.com/108761 is fixed.
274 multi_profile = self.GetMultiProfileInfo()
275 return expected_number == len(multi_profile['profiles'])
276
277 def testDisplayOneClickInfobarPerProfile(self):
278 """Verify one-click infobar appears for each profile after sign-in."""
279 # Default profile.
280 self.testDisplayOneClickInfobar
dennis_jeffrey 2012/04/23 21:59:52 need parens?
dyu1 2012/04/23 22:53:09 Done.
281 # Create a new multi-profile user.
282 self.OpenNewBrowserWindowWithNewProfile()
283 # Wait until the profile has been created.
284 # TODO(dyu): Remove when crbug.com/108761 is fixed.
285 # Verify 2 profiles exist.
286 self.assertTrue(
287 self.WaitUntil(self._CheckNumProfiles, args=[2]),
288 msg='One-click login infobar appeared for only one profile.')
dennis_jeffrey 2012/04/23 21:59:52 are you sure this failure message will necessarily
dyu1 2012/04/23 22:53:09 Done.
289 self.testDisplayOneClickInfobar(tab_index=0, windex=1)
290
291 def testNoSameIDSigninForTwoProfiles(self):
292 """Verify two profiles cannot be signed in with same ID.
293
294 Make sure that the one-click sign in infobar does not appear for two
295 profiles trying to sign in with the same ID. This test creates a profile
296 and connects it to a Google account. Another new profile is created and
297 tries to login with the connected account from the first profile.
298
299 This test verifies the following bug: crbug.com/122975
300 """
301 test_utils.SignInToSyncAndVerifyState(self, 'test_google_account')
302 # Create a new multi-profile user.
303 self.OpenNewBrowserWindowWithNewProfile()
304 # Wait until the profile has been created.
305 # TODO(dyu): Remove when crbug.com/108761 is fixed.
306 # Verify 2 profiles exist.
307 self.assertTrue(
308 self.WaitUntil(self._CheckNumProfiles, args=[2]),
309 msg='One-click login infobar appeared for only one profile.')
310 self._LogIntoGoogleAccount(tab_index=0, windex=1)
311 self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType(
312 self, self.OC_INFOBAR_TYPE, tab_index=0, windex=1) is None))
313
314 def testNoOneClickInfobarWhenCookiesBlocked(self):
315 """Verify one-click infobar does not show when cookies are blocked.
316
317 One-click sign in should not be enabled if cookies are blocked for Google
318 accounts domain.
319
320 This test verifies the following bug: crbug.com/117841
321 """
322 # Block cookies for Google accounts domain.
323 #self.SetPrefs(pyauto.kContentSettingsPatternPairs,
324 # {'https://accounts.google.com/': {'cookies': 2}})
dennis_jeffrey 2012/04/23 21:59:52 remove commented-out code?
dyu1 2012/04/23 22:53:09 Done.
325 self.SetPrefs(pyauto.kContentSettingsPatternPairs,
326 self.BLOCK_COOKIE_PATTERN)
327 self._LogIntoGoogleAccount()
328 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
329
330 def testOneClickInfobarShownWhenWinLoseFocus(self):
331 """Verify one-click infobar still shows when window loses focus.
332
333 This test verifies the following bug: crbug.com/121739
334 """
335 self._LogIntoGoogleAccount()
336 test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
337 # Open new window to shift focus away.
338 self.OpenNewBrowserWindow(True)
339 test_utils.GetInfobarIndexByType(self, self.OC_INFOBAR_TYPE)
340
341 def testNoOneClickInfobarInIncognito(self):
342 """Verify that one-click infobar does not show up in incognito mode."""
343 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
344 self._LogIntoGoogleAccount(windex=1)
345 test_utils.AssertInfobarTypeDoesNotAppear(
346 self, self.OC_INFOBAR_TYPE, windex=1)
347
348
186 if __name__ == '__main__': 349 if __name__ == '__main__':
187 pyauto_functional.Main() 350 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698