Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 596f767e87dfebc38c8e854999c4c8aa393915d7..759d73ea8ac76a01fb064b5429689708f8ea0621 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -4694,6 +4694,35 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
'Chrome did not reopen the testing channel after login as guest.' |
self.SetUp() |
+ def LoginWithCachedCredentials(self, username, password): |
beeps
2012/09/18 17:59:14
Mimics def Login except for the actual hook it cal
craigdh
2012/09/18 18:16:35
Following my suggestion in testing_automation_prov
beeps
2012/09/19 16:29:02
Done.
|
+ """Login to chromeos with cached credentials. |
+ |
+ Returns: |
+ An error string if an error occured. |
+ None otherwise. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ """ |
+ self._GetResultFromJSONRequest({'command': 'AddLoginEventObserver'}, |
+ windex=None) |
+ cmd_dict = { |
+ 'command': 'LoginWithCachedCredentials', |
+ 'username': username, |
+ 'password': password, |
+ } |
+ self._GetResultFromJSONRequest(cmd_dict, windex=None) |
+ self.AddDomEventObserver('loginfail', automation_id=4444) |
+ try: |
+ # TODO(craigdh): Add login failure events once PyAuto switches to mocked |
+ # GAIA authentication. |
craigdh
2012/09/18 18:16:35
Please remove this todo, I already did this but mi
beeps
2012/09/19 16:29:02
Done.
|
+ if self.GetNextEvent().get('name') == 'loginfail': |
+ raise JSONInterfaceError('Login denied by auth server.') |
+ except JSONInterfaceError as e: |
+ raise JSONInterfaceError('Login failed. Perhaps Chrome crashed, ' |
+ 'failed to start, or the login flow is ' |
+ 'broken? Error message: %s' % str(e)) |
+ |
def Login(self, username, password): |
"""Login to chromeos. |