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

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 10944014: Fix to enable the cached credentials login test (Closed) Base URL: https://git.chromium.org/git/chromium/src@master
Patch Set: Replaced hook with boolean switch v2 Created 8 years, 3 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """PyAuto: Python Interface to Chromium's Automation Proxy. 6 """PyAuto: Python Interface to Chromium's Automation Proxy.
7 7
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. 8 PyAuto uses swig to expose Automation Proxy interfaces to Python.
9 For complete documentation on the functionality available, 9 For complete documentation on the functionality available,
10 run pydoc on this file. 10 run pydoc on this file.
(...skipping 4584 matching lines...) Expand 10 before | Expand all | Expand 10 after
4595 cmd_dict = { 'command': 'LoginAsGuest' } 4595 cmd_dict = { 'command': 'LoginAsGuest' }
4596 # Currently, logging in as guest causes session_manager to 4596 # Currently, logging in as guest causes session_manager to
4597 # restart Chrome, which will close the testing channel. 4597 # restart Chrome, which will close the testing channel.
4598 # We need to call SetUp() again to reconnect to the new channel. 4598 # We need to call SetUp() again to reconnect to the new channel.
4599 assert self._WaitForInodeChange( 4599 assert self._WaitForInodeChange(
4600 self._named_channel_id, 4600 self._named_channel_id,
4601 lambda: self._GetResultFromJSONRequest(cmd_dict, windex=None)), \ 4601 lambda: self._GetResultFromJSONRequest(cmd_dict, windex=None)), \
4602 'Chrome did not reopen the testing channel after login as guest.' 4602 'Chrome did not reopen the testing channel after login as guest.'
4603 self.SetUp() 4603 self.SetUp()
4604 4604
4605 def Login(self, username, password): 4605 def Login(self, username, password, use_cached_credentials=False):
4606 """Login to chromeos. 4606 """Login to chromeos.
4607 4607
4608 Waits until logged in and browser is ready. 4608 Waits until logged in and browser is ready.
4609 Should be displaying the login screen to work. 4609 Should be displaying the login screen to work.
4610 4610
4611 Note that in case of webui auth-extension-based login, gaia auth errors 4611 Note that in case of webui auth-extension-based login, gaia auth errors
4612 will not be noticed here, because the browser has no knowledge of it. In 4612 will not be noticed here, because the browser has no knowledge of it. In
4613 this case the GetNextEvent automation command will always time out. 4613 this case the GetNextEvent automation command will always time out.
Nirnimesh 2012/09/21 18:46:43 Add Args: section Explain what use_cached_credenti
beeps 2012/09/26 18:31:09 Done.
4614 4614
4615 Returns: 4615 Returns:
4616 An error string if an error occured. 4616 An error string if an error occured.
4617 None otherwise. 4617 None otherwise.
4618 4618
4619 Raises: 4619 Raises:
4620 pyauto_errors.JSONInterfaceError if the automation call returns an error. 4620 pyauto_errors.JSONInterfaceError if the automation call returns an error.
4621 """ 4621 """
4622 self._GetResultFromJSONRequest({'command': 'AddLoginEventObserver'}, 4622 self._GetResultFromJSONRequest({'command': 'AddLoginEventObserver'},
4623 windex=None) 4623 windex=None)
4624 cmd_dict = { 4624 cmd_dict = {
4625 'command': 'SubmitLoginForm', 4625 'command': 'SubmitLoginForm',
4626 'username': username, 4626 'username': username,
4627 'password': password, 4627 'password': password,
4628 'use_cached_credentials': use_cached_credentials,
4628 } 4629 }
4629 self._GetResultFromJSONRequest(cmd_dict, windex=None) 4630 self._GetResultFromJSONRequest(cmd_dict, windex=None)
4630 self.AddDomEventObserver('loginfail', automation_id=4444) 4631 self.AddDomEventObserver('loginfail', automation_id=4444)
4631 try: 4632 try:
4632 # TODO(craigdh): Add login failure events once PyAuto switches to mocked
4633 # GAIA authentication.
4634 if self.GetNextEvent().get('name') == 'loginfail': 4633 if self.GetNextEvent().get('name') == 'loginfail':
4635 raise JSONInterfaceError('Login denied by auth server.') 4634 raise JSONInterfaceError('Login denied by auth server.')
4636 except JSONInterfaceError as e: 4635 except JSONInterfaceError as e:
4637 raise JSONInterfaceError('Login failed. Perhaps Chrome crashed, ' 4636 raise JSONInterfaceError('Login failed. Perhaps Chrome crashed, '
4638 'failed to start, or the login flow is ' 4637 'failed to start, or the login flow is '
4639 'broken? Error message: %s' % str(e)) 4638 'broken? Error message: %s' % str(e))
4640 4639
4641 def Logout(self): 4640 def Logout(self):
4642 """Log out from ChromeOS and wait for session_manager to come up. 4641 """Log out from ChromeOS and wait for session_manager to come up.
4643 4642
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
6537 successful = result.wasSuccessful() 6536 successful = result.wasSuccessful()
6538 if not successful: 6537 if not successful:
6539 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6538 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6540 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6539 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6541 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6540 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6542 sys.exit(not successful) 6541 sys.exit(not successful)
6543 6542
6544 6543
6545 if __name__ == '__main__': 6544 if __name__ == '__main__':
6546 Main() 6545 Main()
OLDNEW
« chrome/test/functional/chromeos_login.py ('K') | « chrome/test/functional/chromeos_login.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698