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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10533038: Switch back to the old method of launching the login flow while keeping some of the benefits of the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned some logging and comments. Created 8 years, 6 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
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 97b1ba3cb80a0d199adac453d7592c97254d9a84..35a9c5d2a2e1506b8a9819014579f5e10fb63501 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -85,7 +85,6 @@ import omnibox_info
import plugins_info
import prefs_info
from pyauto_errors import JSONInterfaceError
-from pyauto_errors import LoginError
Nirnimesh 2012/06/07 19:17:04 Also remove LoginError from pyauto_errors?
craigdh 2012/06/07 23:16:52 Done.
from pyauto_errors import NTPThumbnailNotShownError
import pyauto_utils
import simplejson as json # found in third_party
@@ -3083,23 +3082,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 +4116,33 @@ 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. In
+ this case the GetNextEvent automation command will always time out.
+
+ 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, '
+ 'failed to start, or the login flow is '
+ 'broken?' % str(e))
def Logout(self):
"""Log out from ChromeOS and wait for session_manager to come up.

Powered by Google App Engine
This is Rietveld 408576698