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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/infobars.py
===================================================================
--- chrome/test/functional/infobars.py (revision 132411)
+++ chrome/test/functional/infobars.py (working copy)
@@ -183,5 +183,174 @@
self.assertEqual(len(infobar), 1)
+class OneClickInfobarTest(pyauto.PyUITest):
+ """Tests for one-click sign in infobar."""
+
+ BLOCK_COOKIE_PATTERN = {'https://accounts.google.com/': {'cookies': 2}}
+ OC_INFOBAR_TYPE = 'oneclicklogin_infobar'
+ PW_INFOBAR_TYPE = 'password_infobar'
+ URL = 'https://www.google.com/accounts/ServiceLogin'
+ URL_LOGIN = 'https://www.google.com/accounts/Login'
+ URL_LOGOUT = 'https://www.google.com/accounts/Logout'
+
+ def setUp(self):
+ pyauto.PyUITest.setUp(self)
+ self._driver = self.NewWebDriver()
+
+ def _LogIntoGoogleAccount(self, tab_index=0, windex=0):
+ """Log into Google account.
+
+ Args:
+ tab_index: The tab index, default is 0.
+ windex: The window index, default is 0.
+ """
+ creds = self.GetPrivateInfo()['test_google_account']
+ username = creds['username']
+ password = creds['password']
+ test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex)
+ # Wait until page completes loading.
Nirnimesh 2012/04/24 00:32:14 Remove redundant comment
dyu1 2012/04/24 03:06:15 Done.
+ self.WaitUntilNavigationCompletes(tab_index=tab_index, windex=windex)
Nirnimesh 2012/04/24 00:32:14 Please note that since this hook got added only to
dyu1 2012/04/24 03:06:15 This might not be checked in until tomorrow ;) On
+
+ def _PerformActionOnInfobar(self, action):
+ """Perform an action on the infobar: accept, cancel, or dismiss.
+
+ If action is accept then the account is synced.
Nirnimesh 2012/04/24 00:32:14 Declare the expectations. One-click infobar must b
dyu1 2012/04/24 03:06:15 Done.
+
+ Args:
+ action: The action to perform on the infobar.
+ """
+ self.PerformActionOnInfobar(
+ action, infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
Nirnimesh 2012/04/24 00:32:14 save infobar index to a var before calling Perform
dyu1 2012/04/24 03:06:15 Done.
+ self, self.OC_INFOBAR_TYPE))
+
+ def _DisplayOneClickInfobar(self, tab_index=0, windex=0):
+ """One-click sign in infobar appears after logging into google account.
+
+ Args:
+ tab_index=: The tab index, default is 0.
Nirnimesh 2012/04/24 00:32:14 remove =
dyu1 2012/04/24 03:06:15 Done.
+ windex: The window index, default is 0.
+ """
+ self._LogIntoGoogleAccount(tab_index=tab_index, windex=windex)
+ self.assertTrue(self.WaitUntil(
Nirnimesh 2012/04/24 00:32:14 multiple lined function nesting while using lambda
dyu1 2012/04/24 03:06:15 I tried this before and I couldn't get it to work.
+ lambda: test_utils.GetInfobarIndexByType(
+ self, self.OC_INFOBAR_TYPE,
+ tab_index=tab_index, windex=windex) is not None),
Nirnimesh 2012/04/24 00:32:14 'is not None' is redundant
dyu1 2012/04/24 03:06:15 Done.
+ msg='The one-click login infobar did not appear.')
+
+ def testDisplayOneClickInfobar(self):
+ """Verify one-click infobar appears after logging into google account.
Nirnimesh 2012/04/24 00:32:14 s/logging/login/
dyu1 2012/04/24 03:06:15 Done.
+
+ One-click infobar should appear after signing into a google account
+ for the first time using a clean profile.
+ """
+ self._DisplayOneClickInfobar()
+
+ def testNoOneClickInfobarAfterCancel(self):
+ """Verify one-click infobar does not appear again after clicking cancel.
+
+ The one-click infobar should not display again after logging into an
+ account and selecting to reject sync the first time.
+
+ This test also verifies that the password infobar displays.
+ """
+ self._DisplayOneClickInfobar()
+ self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button.
+ self.NavigateToURL(self.URL_LOGOUT)
+ self._LogIntoGoogleAccount()
+ test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
Nirnimesh 2012/04/24 00:32:14 Move this after the next line so that the positive
dyu1 2012/04/24 03:06:15 Done.
+ test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE)
Nirnimesh 2012/04/24 00:32:14 Maybe extend this test.. and verify again after re
dyu1 2012/04/24 03:06:15 Done.
+
+ def testDisplayOneClickInfobarAfterDismiss(self):
+ """Verify one-click infobar appears again after clicking dismiss button.
+
+ The one-click infobar should display again after logging into an
+ account and clicking to dismiss the infobar the first time.
+
+ This test also verifies that the password infobar does not display.
+ The one-click infobar should supersede the password infobar.
+ """
+ self._DisplayOneClickInfobar()
+ self._PerformActionOnInfobar(action='dismiss') # Click 'x' button.
+ self.NavigateToURL(self.URL_LOGOUT)
+ self._LogIntoGoogleAccount()
+ test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
+ test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE)
+
+ def _CheckNumProfiles(self, expected_number):
Nirnimesh 2012/04/24 00:32:14 'Check' in the function is a misnomer. How about:
dyu1 2012/04/24 03:06:15 Done.
+ """Returns True if |expected_number| is equal to the number of profiles."""
+ # TODO(dyu): Remove when crbug.com/108761 is fixed.
+ multi_profile = self.GetMultiProfileInfo()
+ return expected_number == len(multi_profile['profiles'])
+
+ def testDisplayOneClickInfobarPerProfile(self):
+ """Verify one-click infobar appears for each profile after sign-in."""
+ # Default profile.
+ self._DisplayOneClickInfobar()
+ # Create a new multi-profile user.
+ self.OpenNewBrowserWindowWithNewProfile()
+ # Wait until the profile has been created.
Nirnimesh 2012/04/24 00:32:14 Create a local helper _OpenSecondProfile() instead
dyu1 2012/04/24 03:06:15 Done.
+ # TODO(dyu): Remove when crbug.com/108761 is fixed.
+ # Verify 2 profiles exist.
+ self.assertTrue(
+ self.WaitUntil(self._CheckNumProfiles, args=[2]),
+ msg='The second profile was not created.')
+ self._DisplayOneClickInfobar(windex=1)
+
+ def testNoSameIDSigninForTwoProfiles(self):
+ """Verify two profiles cannot be signed in with same ID.
+
+ Make sure that the one-click sign in infobar does not appear for two
+ profiles trying to sign in with the same ID. This test creates a profile
+ and connects it to a Google account. Another new profile is created and
+ tries to login with the connected account from the first profile.
+
+ This test verifies the following bug: crbug.com/122975
+ """
+ test_utils.SignInToSyncAndVerifyState(self, 'test_google_account')
+ # Create a new multi-profile user.
+ self.OpenNewBrowserWindowWithNewProfile()
+ # Wait until the profile has been created.
+ # TODO(dyu): Remove when crbug.com/108761 is fixed.
+ # Verify 2 profiles exist.
+ self.assertTrue(
+ self.WaitUntil(self._CheckNumProfiles, args=[2]),
+ msg='The second profile was not created.')
+ self._LogIntoGoogleAccount(tab_index=0, windex=1)
+ self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType(
Nirnimesh 2012/04/24 00:32:14 why is the waitUntil required?
dyu1 2012/04/24 03:06:15 Done.
+ self, self.OC_INFOBAR_TYPE, tab_index=0, windex=1) is None))
+
+ def testNoOneClickInfobarWhenCookiesBlocked(self):
+ """Verify one-click infobar does not show when cookies are blocked.
+
+ One-click sign in should not be enabled if cookies are blocked for Google
+ accounts domain.
+
+ This test verifies the following bug: crbug.com/117841
+ """
+ # Block cookies for Google accounts domain.
+ self.SetPrefs(pyauto.kContentSettingsPatternPairs,
+ self.BLOCK_COOKIE_PATTERN)
+ self._LogIntoGoogleAccount()
+ test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
+
+ def testOneClickInfobarShownWhenWinLoseFocus(self):
+ """Verify one-click infobar still shows when window loses focus.
+
+ This test verifies the following bug: crbug.com/121739
+ """
+ self._LogIntoGoogleAccount()
+ test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
+ # Open new window to shift focus away.
+ self.OpenNewBrowserWindow(True)
+ test_utils.GetInfobarIndexByType(self, self.OC_INFOBAR_TYPE)
+
+ def testNoOneClickInfobarInIncognito(self):
+ """Verify that one-click infobar does not show up in incognito mode."""
+ self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
+ self._LogIntoGoogleAccount(windex=1)
+ test_utils.AssertInfobarTypeDoesNotAppear(
+ self, self.OC_INFOBAR_TYPE, windex=1)
+
+
if __name__ == '__main__':
pyauto_functional.Main()
« 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