Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 97b1ba3cb80a0d199adac453d7592c97254d9a84..2736d14b659376d8a0e297ee52a15541f7a08741 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -3083,23 +3083,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
except JSONInterfaceError: |
raise JSONInterfaceError(msg) |
- def _AddLoginEventObserver(self): |
- """Adds a LoginEventObserver associated with the AutomationEventQueue. |
- |
- The LoginEventObserver will generate an event when login completes. |
- |
- Returns: |
- The id of the created observer, which can be used with GetNextEvent(id) |
- and RemoveEventObserver(id). |
- |
- Raises: |
- pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- """ |
- cmd_dict = { |
- 'command': 'AddLoginEventObserver', |
- } |
- return self._GetResultFromJSONRequest(cmd_dict, windex=None)['observer_id'] |
- |
def GetNextEvent(self, observer_id=-1, blocking=True, timeout=-1): |
"""Waits for an observed event to occur. |
@@ -4134,22 +4117,31 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
Waits until logged in and browser is ready. |
Should be displaying the login screen to work. |
+ Note that in case of webui auth-extension-based login, gaia auth errors |
+ will not be noticed here, because the browser has no knowledge of it. |
Nirnimesh
2012/06/07 00:30:55
Add: All such scenarios will lead to timeout of th
craigdh
2012/06/07 19:12:01
Done.
|
+ |
+ Returns: |
+ An error string if an error occured. |
+ None otherwise. |
+ |
Raises: |
pyauto_errors.JSONInterfaceError if the automation call returns an error. |
- pyauto_errors.LoginError if the login fails. |
""" |
- observer_id = self._AddLoginEventObserver() |
- ret = self.ExecuteJavascriptInOOBEWebUI(""" |
- chrome.send("completeLogin", ["%s", "%s"] ); |
- window.domAutomationController.send("success");""" % |
- (username, password)); |
+ self._GetResultFromJSONRequest({'command': 'AddLoginEventObserver'}, |
+ windex=None) |
+ cmd_dict = { |
+ 'command': 'StartLogin', |
+ 'username': username, |
+ 'password': password, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=None) |
try: |
- response = self.GetNextEvent(observer_id) |
+ # TODO(craigdh): Add login failure events once PyAuto switches to mocked |
+ # GAIA authentication. |
+ self.GetNextEvent() |
except JSONInterfaceError as e: |
- raise JSONInterfaceError( |
- str(e) + '\n Perhaps Chrome crashed or login is broken?') |
- if 'error_string' in response: |
- raise LoginError(response['error_string']) |
+ raise JSONInterfaceError('%s\nLogin failed. Perhaps Chrome crashed or ' |
+ 'the login flow is broken?' % str(e)) |
def Logout(self): |
"""Log out from ChromeOS and wait for session_manager to come up. |