Chromium Code Reviews| Index: chrome/test/functional/infobars.py |
| =================================================================== |
| --- chrome/test/functional/infobars.py (revision 132411) |
| +++ chrome/test/functional/infobars.py (working copy) |
| @@ -183,5 +183,180 @@ |
| self.assertEqual(len(infobar), 1) |
| +class OneClickInfobarTest(pyauto.PyUITest): |
| + """Tests for one-click sign in infobar.""" |
| + |
| + OC_INFOBAR_TYPE = 'oneclicklogin_infobar' |
| + PW_INFOBAR_TYPE = 'password_infobar' |
| + URL = 'https://www.google.com/accounts/ServiceLogin' |
| + URL_HTTPS = 'https://www.google.com/accounts/Login' |
|
dennis_jeffrey
2012/04/20 17:35:04
maybe name this URL_LOGIN to correspond with URL_L
dyu1
2012/04/23 21:46:10
Done.
|
| + 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. |
| + """ |
| + test_utils.ClearPasswords(self) |
|
Nirnimesh
2012/04/20 18:12:05
Each test begins with a clean profile. This is not
dyu1
2012/04/23 21:46:10
Done.
|
| + 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( |
| + 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)) |
|
dennis_jeffrey
2012/04/20 17:35:04
Probably not worth declaring this as a function.
dyu1
2012/04/23 21:46:10
Yes I thought about it, I left it for later, when
|
| + |
| + def testDisplayOneClickInfobar(self): |
| + """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() |
| + self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType( |
|
Nirnimesh
2012/04/20 18:12:05
Use WaitForInfobarCount(1)
Then verify that it's
dyu1
2012/04/23 21:46:10
I'm hesitant on using WaitForInfobarCount(1) since
|
| + self, self.OC_INFOBAR_TYPE) is not None)) |
|
Nirnimesh
2012/04/20 18:12:05
add a msg= param
dyu1
2012/04/23 21:46:10
Done.
|
| + |
| + 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._LogIntoGoogleAccount() |
| + self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType( |
|
Nirnimesh
2012/04/20 18:12:05
just call test testDisplayOneClickInfobar() instea
dyu1
2012/04/23 21:46:10
Done.
|
| + self, self.OC_INFOBAR_TYPE) is not None)) |
| + 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 appear again after clicking dismiss button. |
|
dennis_jeffrey
2012/04/20 17:35:04
'appear' --> 'appears'
dyu1
2012/04/23 21:46:10
Done.
|
| + |
| + 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 superceed the password infobar. |
|
dennis_jeffrey
2012/04/20 17:35:04
'superceed' --> 'supersede'
dyu1
2012/04/23 21:46:10
Done.
|
| + """ |
| + self._LogIntoGoogleAccount() |
| + self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType( |
| + self, self.OC_INFOBAR_TYPE) is not None)) |
|
Nirnimesh
2012/04/20 18:12:05
use testDisplayOneClickInfobar. Repeat elsewhere
dyu1
2012/04/23 21:46:10
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: Remove when crbug.com/108761 is fixed. |
|
dennis_jeffrey
2012/04/20 17:35:04
add LDAP to the TODO
dyu1
2012/04/23 21:46:10
Done.
|
| + 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._LogIntoGoogleAccount() |
| + self.assertTrue(self.WaitUntil(lambda: test_utils.GetInfobarIndexByType( |
| + self, self.OC_INFOBAR_TYPE) is not None)) |
| + # Create a new multi-profile user. |
| + self.OpenNewBrowserWindowWithNewProfile() |
| + # Wait until the profile has been created. |
| + # TODO: Remove when crbug.com/108761 is fixed. |
|
dennis_jeffrey
2012/04/20 17:35:04
add LDAP
dyu1
2012/04/23 21:46:10
Done.
|
| + self.WaitUntil(self._CheckNumProfiles, args=[2]) # Verify 2 profiles exist. |
|
Nirnimesh
2012/04/20 18:12:05
wrap inside assertTrue
dyu1
2012/04/23 21:46:10
Done.
|
| + 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 not None)) |
| + |
| + 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 connect it to a Google account. Another new profile is created and |
|
dennis_jeffrey
2012/04/20 17:35:04
'connect' --> 'connects'
dyu1
2012/04/23 21:46:10
Done.
|
| + tries to login with the connected account from the first profile. |
| + |
| + Regress crbug.com/122975 |
|
dennis_jeffrey
2012/04/20 17:35:04
what does this mean?
dyu1
2012/04/23 21:46:10
I wrote a test for that bug. So if the test fails
|
| + """ |
| + test_utils.SignInToSyncAndVerifyState(self, 'test_google_account') |
|
Nirnimesh
2012/04/20 18:12:05
The sync tests are disabled. Are you sure this wor
dyu1
2012/04/23 21:46:10
Yes, this function works. This is the only way to
|
| + # Create a new multi-profile user. |
| + self.OpenNewBrowserWindowWithNewProfile() |
|
Nirnimesh
2012/04/20 18:12:05
I'd suggest creating a local wrapper function with
dyu1
2012/04/23 21:46:10
Do you mean 306 to 309? 307 and 308 are just comme
|
| + # Wait until the profile has been created. |
| + # TODO: Remove when crbug.com/108761 is fixed. |
|
dennis_jeffrey
2012/04/20 17:35:04
add LDAP
dyu1
2012/04/23 21:46:10
Done.
|
| + self.WaitUntil(self._CheckNumProfiles, args=[2]) # Verify 2 profiles exist. |
| + 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 _VerifyContentExceptionUI(self, content_type, hostname_pattern, behavior, |
|
Nirnimesh
2012/04/20 18:12:05
unused?
dyu1
2012/04/23 21:46:10
Done.
|
| + incognito=False): |
| + """Find hostname pattern and behavior within UI on content exceptions page. |
| + |
| + Args: |
| + content_type: The string content settings type to manage. |
| + hostname_pattern: The URL or pattern associated with the behavior. |
| + behavior: The exception to allow or block the hostname. |
| + incognito: Incognito list displayed on exceptions settings page. |
| + Default to False. |
| + """ |
| + page = settings.ManageExceptionsPage.FromNavigation( |
| + self._driver, content_type) |
| + self.assertTrue(page.GetExceptions(incognito).has_key(hostname_pattern), |
| + msg=('No displayed host name matches pattern "%s"' |
| + % hostname_pattern)) |
| + self.assertEqual(behavior, page.GetExceptions(incognito)[hostname_pattern], |
| + msg=('Displayed behavior "%s" does not match behavior "%s"' |
| + % (page.GetExceptions(incognito)[hostname_pattern], |
| + behavior))) |
| + |
| + 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. |
| + |
| + Regress crbug.com/117841 |
| + """ |
| + # Block cookies for Google accounts domain. |
| + self.SetPrefs(pyauto.kContentSettingsPatternPairs, |
| + {'https://accounts.google.com/': {'cookies': 2}}) |
|
Nirnimesh
2012/04/20 18:12:05
move the pattern at the top, along with all the ot
dyu1
2012/04/23 21:46:10
Done.
|
| + self._LogIntoGoogleAccount() |
| + test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
| + |
| + def testOneClickInfobarShownWhenWinLoseFocus(self): |
| + """Verify one-click infobar still shows when window loses focus. |
| + |
| + Regress 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.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE) |
|
Nirnimesh
2012/04/20 18:12:05
you should not "wait" anymore. Just check that the
dyu1
2012/04/23 21:46:10
Done.
|
| + |
| + |
| if __name__ == '__main__': |
| pyauto_functional.Main() |