summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/test/functional/passwords.py31
-rwxr-xr-xchrome/test/functional/prefs.py28
2 files changed, 27 insertions, 32 deletions
diff --git a/chrome/test/functional/passwords.py b/chrome/test/functional/passwords.py
index 78679cd..e54d421 100755
--- a/chrome/test/functional/passwords.py
+++ b/chrome/test/functional/passwords.py
@@ -112,10 +112,9 @@ class PasswordTest(pyauto.PyUITest):
"""
self.assertTrue(
self.WaitUntil(lambda: self._GetInfobarIndexByType(
- self.INFOBAR_TYPE, windex, tab_index)),
+ self.INFOBAR_TYPE, windex, tab_index) is not None),
msg='Save password infobar did not appear.')
# Return the infobar index.
- # TODO(dyu): Use the return value in future tests.
return self._GetInfobarIndexByType(
self.INFOBAR_TYPE, windex, tab_index)
@@ -163,10 +162,8 @@ class PasswordTest(pyauto.PyUITest):
self.WaitUntil(
lambda: self.GetDOMValue('document.readyState'),
expect_retval='complete')
- self._GetIndexForSavePasswordInfobar()
- infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']
- self.assertEqual(infobar[0]['type'], 'password_infobar')
- self.PerformActionOnInfobar('accept', infobar_index=0)
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.NavigateToURL(url_logout)
self.NavigateToURL(url_https)
self._ClickOnLoginPage(0, 0)
@@ -179,8 +176,8 @@ class PasswordTest(pyauto.PyUITest):
creds1 = self.GetPrivateInfo()['test_google_account']
test_utils.GoogleAccountsLogin(
self, creds1['username'], creds1['password'])
- self._GetIndexForSavePasswordInfobar()
- self.PerformActionOnInfobar('accept', infobar_index=0)
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.assertEquals(1, len(self.GetSavedPasswords()))
self.AppendTab(pyauto.GURL(creds1['logout_url']))
creds2 = self.GetPrivateInfo()['test_google_account_2']
@@ -204,9 +201,8 @@ class PasswordTest(pyauto.PyUITest):
password = creds['password']
# Login to Google a/c
test_utils.GoogleAccountsLogin(self, username, password)
- self._GetIndexForSavePasswordInfobar()
- self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
- self.PerformActionOnInfobar('accept', infobar_index=0)
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.NavigateToURL(url_logout)
self.NavigateToURL(url)
self._ClickOnLoginPage(0, 0)
@@ -228,8 +224,8 @@ class PasswordTest(pyauto.PyUITest):
creds = self.GetPrivateInfo()['test_google_account']
# Login to Google a/c
test_utils.GoogleAccountsLogin(self, creds['username'], creds['password'])
- self._GetIndexForSavePasswordInfobar()
- self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.NavigateToURL('chrome://history')
self.assertTrue(self.WaitForInfobarCount(0))
# To make sure user is navigated to History page.
@@ -241,8 +237,8 @@ class PasswordTest(pyauto.PyUITest):
creds = self.GetPrivateInfo()['test_google_account']
# Login to Google a/c
test_utils.GoogleAccountsLogin(self, creds['username'], creds['password'])
- self._GetIndexForSavePasswordInfobar()
- self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.GetBrowserWindow(0).GetTab(0).Reload()
self.assertTrue(self.WaitForInfobarCount(0))
self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
@@ -298,9 +294,8 @@ class PasswordTest(pyauto.PyUITest):
password = creds['password']
# Login to Google a/c
test_utils.GoogleAccountsLogin(self, username, password)
- self._GetIndexForSavePasswordInfobar()
- self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
- self.PerformActionOnInfobar('accept', infobar_index=0)
+ self.PerformActionOnInfobar(
+ 'accept', infobar_index=self._GetIndexForSavePasswordInfobar())
self.NavigateToURL(url_logout)
self.NavigateToURL(url)
self._ClickOnLoginPage(0, 0)
diff --git a/chrome/test/functional/prefs.py b/chrome/test/functional/prefs.py
index 76ef92a..8f94fa4 100755
--- a/chrome/test/functional/prefs.py
+++ b/chrome/test/functional/prefs.py
@@ -281,50 +281,50 @@ class PrefsTest(pyauto.PyUITest):
self.assertFalse(driver.execute_script(script),
msg='At least one visible image found.')
- def _InfobarTypeDisplayed(self, infobar_type, windex, tab_index):
- """Identifies whether an infobar displays and get the index.
+ def _GetInfobarIndexByType(self, infobar_type, windex, tab_index):
+ # TODO(dyu): Move this helper function into test_util file.
+ """Returns the index of the infobar of the given type.
Args:
- infobar_type: The infobar type displayed.
+ infobar_type: The infobar type to look for.
windex: Window index.
tab_index: Tab index.
Returns:
- Index of infobar for infobar type, or -1 if not found.
+ Index of infobar for infobar type, or None if not found.
"""
infobar_list = (
self.GetBrowserInfo()['windows'][windex]['tabs'][tab_index] \
['infobars'])
- print infobar_list
for infobar in infobar_list:
if infobar_type == infobar['type']:
return infobar_list.index(infobar)
- return -1
+ return None
- def _WaitForHandlerInfobar(self, windex=0, tab_index=0):
- """Wait for and asserts that the handler protocol infobar appears.
+ def _GetIndexForRPHInfobar(self, windex=0, tab_index=0):
+ """Waits for RPH infobar to appear and returns its index.
Args:
windex: Window index. Defaults to 0 (first window).
tab_index: Tab index. Defaults to 0 (first tab).
Returns:
- Index of infobar for infobar type.
+ Index of RPH infobar.
"""
self.assertTrue(
- self.WaitUntil(lambda: self._InfobarTypeDisplayed(
- self.INFOBAR_TYPE, windex, tab_index) is not -1),
+ self.WaitUntil(lambda: self._GetInfobarIndexByType(
+ self.INFOBAR_TYPE, windex, tab_index) is not None),
msg='Registered Handler Protocol infobar did not appear.')
- infobar_index = self._InfobarTypeDisplayed(
+ # Return the infobar index.
+ return self._GetInfobarIndexByType(
self.INFOBAR_TYPE, windex, tab_index)
- return infobar_index
def testProtocolHandlerRegisteredCorrectly(self):
"""Verify sites that ask to be default handlers registers correctly."""
url = self.GetHttpURLForDataPath('settings', 'protocol_handler.html')
self.NavigateToURL(url)
self.PerformActionOnInfobar(
- 'accept', infobar_index=self._WaitForHandlerInfobar())
+ 'accept', infobar_index=self._GetIndexForRPHInfobar())
driver = self.NewWebDriver()
driver.find_element_by_id('test_protocol').click()
self.assertTrue(