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

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,168 @@
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.
+ self.WaitUntil(
Nirnimesh 2012/04/23 22:07:45 Suggestion: Craig recently (actually, 2 hours ago
dyu1 2012/04/23 22:53:09 Done.
+ lambda: self.GetDOMValue('document.readyState'),
+ expect_retval='complete')
+
+ def _PerformActionOnInfobar(self, action):
+ """Perform an action on the infobar: accept, cancel, or dismiss.
+
+ If action is accept then the account is synced.
+
+ Args:
+ action: The action to perform on the infobar.
+ """
+ self.PerformActionOnInfobar(
+ action, infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
+ self, self.OC_INFOBAR_TYPE))
+
+ 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
+ """Verify one-click infobar appears after logging into google account.
+
+ One-click infobar should appear after signing into a google account
+ for the first time using a clean profile.
+ """
+ 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.
+ self.assertTrue(self.WaitUntil(
+ lambda: test_utils.GetInfobarIndexByType(
+ self, self.OC_INFOBAR_TYPE, tab_index=0, windex=0) is not None),
+ msg='The one-click login infobar did not appear.')
+
+ 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.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
+ self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button.
+ self.NavigateToURL(self.URL_LOGOUT)
+ self._LogIntoGoogleAccount()
+ test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
+ test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE)
+
+ 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.testDisplayOneClickInfobar
dennis_jeffrey 2012/04/23 21:59:52 need parens?
dyu1 2012/04/23 22:53:09 Done.
+ 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):
+ """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.testDisplayOneClickInfobar
dennis_jeffrey 2012/04/23 21:59:52 need parens?
dyu1 2012/04/23 22:53:09 Done.
+ # 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='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.
+ self.testDisplayOneClickInfobar(tab_index=0, 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='One-click login infobar appeared for only one profile.')
+ self._LogIntoGoogleAccount(tab_index=0, windex=1)
+ self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType(
+ 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,
+ # {'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.
+ 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