Index: chrome/test/functional/passwords.py |
=================================================================== |
--- chrome/test/functional/passwords.py (revision 127222) |
+++ chrome/test/functional/passwords.py (working copy) |
@@ -13,7 +13,7 @@ |
class PasswordTest(pyauto.PyUITest): |
"""Tests that passwords work correctly.""" |
- INFOBAR_BUTTON_TEXT = 'Save password' |
+ INFOBAR_TYPE = 'password_infobar' |
def Debug(self): |
"""Test method for experimentation. |
@@ -81,24 +81,24 @@ |
self.ExecuteJavascript(js_template % 'Passwd', |
tab_index, window_index) != '')) |
- def _InfobarButtonContainsText(self, search_text, windex, tab_index): |
- """Identifies whether an infobar button exists with the specified text. |
+ def _InfobarTypeDisplayed(self, infobar_type, windex, tab_index): |
dennis_jeffrey
2012/03/20 21:17:58
Change the function name to something like "_GetIn
dyu1
2012/03/20 22:24:35
Done.
|
+ """Identifies whether an infobar displays and get the index. |
dennis_jeffrey
2012/03/20 21:17:58
Returns the index of the infobar of the given type
dyu1
2012/03/20 22:24:35
Done.
|
Args: |
- search_text: The text to search for on the infobar buttons. |
+ infobar_type: The infobar type displayed. |
windex: Window index. |
tab_index: Tab index. |
Returns: |
- True, if search_text is found in the buttons, or False otherwise. |
+ Index of infobar for infobar type, or -1 if not found. |
dennis_jeffrey
2012/03/20 21:17:58
Maybe we should return None in the event it's not
dyu1
2012/03/20 22:24:35
Done.
|
""" |
- infobar = ( |
+ infobar_list = ( |
self.GetBrowserInfo()['windows'][windex]['tabs'][tab_index] \ |
['infobars']) |
- for infobar_info in infobar: |
- if search_text in infobar_info['buttons']: |
- return True |
- return False |
+ for infobar in infobar_list: |
+ if infobar_type == infobar['type']: |
+ return infobar_list.index(infobar) |
+ return -1 |
dennis_jeffrey
2012/03/20 21:17:58
recommend changing '-1' to 'None'
dyu1
2012/03/20 22:24:35
Done.
|
def _WaitForSavePasswordInfobar(self, windex=0, tab_index=0): |
"""Wait for and asserts that the save password infobar appears. |
@@ -106,11 +106,17 @@ |
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. |
""" |
self.assertTrue( |
- self.WaitUntil(lambda: self._InfobarButtonContainsText( |
- self.INFOBAR_BUTTON_TEXT, windex, tab_index)), |
+ self.WaitUntil(lambda: self._InfobarTypeDisplayed( |
+ self.INFOBAR_TYPE, windex, tab_index) is not -1), |
dennis_jeffrey
2012/03/20 21:17:58
we can remove 'is not -1' if you address comment a
dyu1
2012/03/20 22:24:35
Done.
|
msg='Save password infobar did not appear.') |
+ infobar_index = self._InfobarTypeDisplayed( |
+ self.INFOBAR_TYPE, windex, tab_index) |
+ return infobar_index |
dennis_jeffrey
2012/03/20 21:17:58
combine the above 2 statements into a single state
dyu1
2012/03/20 22:24:35
Done
On 2012/03/20 21:17:58, dennis_jeffrey wrot
|
def testSavePassword(self): |
"""Test saving a password and getting saved passwords.""" |