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

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

Issue 10408072: Rewrite of the EnrollEnterpriseDevice PyAuto automation hook for WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: std::string -> const std::string& and style fixes Created 8 years, 7 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 | Annotate | Revision Log
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 raise 78 raise
79 79
80 # Should go after sys.path is set appropriately 80 # Should go after sys.path is set appropriately
81 import bookmark_model 81 import bookmark_model
82 import download_info 82 import download_info
83 import history_info 83 import history_info
84 import omnibox_info 84 import omnibox_info
85 import plugins_info 85 import plugins_info
86 import prefs_info 86 import prefs_info
87 from pyauto_errors import JSONInterfaceError 87 from pyauto_errors import JSONInterfaceError
88 from pyauto_errors import EnrollmentError
88 from pyauto_errors import NTPThumbnailNotShownError 89 from pyauto_errors import NTPThumbnailNotShownError
89 import pyauto_utils 90 import pyauto_utils
90 import simplejson as json # found in third_party 91 import simplejson as json # found in third_party
91 92
92 _CHROME_DRIVER_FACTORY = None 93 _CHROME_DRIVER_FACTORY = None
93 _HTTP_SERVER = None 94 _HTTP_SERVER = None
94 _REMOTE_PROXY = None 95 _REMOTE_PROXY = None
95 _OPTIONS = None 96 _OPTIONS = None
96 _BROWSER_PID = None 97 _BROWSER_PID = None
97 98
(...skipping 4806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 } 4905 }
4905 self._GetResultFromJSONRequest(cmd_dict, windex=None) 4906 self._GetResultFromJSONRequest(cmd_dict, windex=None)
4906 4907
4907 def EnrollEnterpriseDevice(self, user, password): 4908 def EnrollEnterpriseDevice(self, user, password):
4908 """Enrolls an unenrolled device as an enterprise device. 4909 """Enrolls an unenrolled device as an enterprise device.
4909 4910
4910 Expects the device to be unenrolled with the TPM unlocked. This is 4911 Expects the device to be unenrolled with the TPM unlocked. This is
4911 equivalent to pressing Ctrl-Alt-e to enroll the device from the login 4912 equivalent to pressing Ctrl-Alt-e to enroll the device from the login
4912 screen. 4913 screen.
4913 4914
4914 Returns:
4915 An error string if the enrollment fails.
4916 None otherwise.
4917
4918 Raises: 4915 Raises:
4919 pyauto_errors.JSONInterfaceError if the automation call returns an error. 4916 pyauto_errors.JSONInterfaceError if the automation call returns an error.
4917 pyauto_errors.EnrollmentError if the enrollment fails.
4920 """ 4918 """
4921 cmd_dict = { 4919 self._GetResultFromJSONRequest(
4922 'command': 'EnrollEnterpriseDevice', 4920 {'command': 'ShowEnterpriseWizard'}, windex=None)
4923 'user': user, 4921 observer_id = self._GetResultFromJSONRequest(
4924 'password': password, 4922 {'command': 'AddEnrollmentObserver'}, windex=None)['observer_id']
4925 } 4923 self.ExecuteJavascriptInOOBEWebUI("""
4926 time.sleep(5) # TODO(craigdh): Block until Install Attributes is ready. 4924 chrome.send("oauthEnrollCompleteLogin", ["%s", "%s"] );
4927 result = self._GetResultFromJSONRequest(cmd_dict, windex=None) 4925 window.domAutomationController.send("success");""" %
4928 return result.get('error_string') 4926 (user, password));
4927 response = self.GetNextEvent(observer_id)
4928 if 'error_string' in response:
4929 raise EnrollmentError(response['error_string'])
4929 4930
4930 def GetUpdateInfo(self): 4931 def GetUpdateInfo(self):
4931 """Gets the status of the ChromeOS updater. 4932 """Gets the status of the ChromeOS updater.
4932 4933
4933 Returns: 4934 Returns:
4934 a dictionary. 4935 a dictionary.
4935 Samples: 4936 Samples:
4936 { u'status': u'idle', 4937 { u'status': u'idle',
4937 u'release_track': u'beta-channel'} 4938 u'release_track': u'beta-channel'}
4938 4939
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
5774 successful = result.wasSuccessful() 5775 successful = result.wasSuccessful()
5775 if not successful: 5776 if not successful:
5776 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5777 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5777 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5778 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5778 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5779 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5779 sys.exit(not successful) 5780 sys.exit(not successful)
5780 5781
5781 5782
5782 if __name__ == '__main__': 5783 if __name__ == '__main__':
5783 Main() 5784 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698