OLD | NEW |
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utility library for running a startup profile on an Android device. | 5 """Utility library for running a startup profile on an Android device. |
6 | 6 |
7 Sets up a device for cygprofile, disables sandboxing permissions, and sets up | 7 Sets up a device for cygprofile, disables sandboxing permissions, and sets up |
8 support for web page replay, device forwarding, and fake certificate authority | 8 support for web page replay, device forwarding, and fake certificate authority |
9 to make runs repeatable. | 9 to make runs repeatable. |
10 """ | 10 """ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 self._wpr_ca_cert_path = None | 72 self._wpr_ca_cert_path = None |
73 self._device_cert_util = None | 73 self._device_cert_util = None |
74 self._host_http_port = None | 74 self._host_http_port = None |
75 self._host_https_port = None | 75 self._host_https_port = None |
76 self._is_test_ca_installed = False | 76 self._is_test_ca_installed = False |
77 self._flag_changer = None | 77 self._flag_changer = None |
78 | 78 |
79 def Start(self): | 79 def Start(self): |
80 """Set up the device and host for WPR.""" | 80 """Set up the device and host for WPR.""" |
81 self.Stop() | 81 self.Stop() |
82 #TODO(azarchs): make self._InstallTestCa() work | 82 # TODO(lizeb,pasko): make self._InstallTestCa() work |
83 self._BringUpWpr() | 83 self._BringUpWpr() |
84 self._StartForwarder() | 84 self._StartForwarder() |
85 | 85 |
86 def Stop(self): | 86 def Stop(self): |
87 """Clean up the device and host's WPR setup.""" | 87 """Clean up the device and host's WPR setup.""" |
88 self._StopForwarder() | 88 self._StopForwarder() |
89 self._StopWpr() | 89 self._StopWpr() |
90 #TODO(azarchs): make self._RemoveTestCa() work | 90 # TODO(lizeb,pasko): make self._RemoveTestCa() work |
91 | 91 |
92 def __enter__(self): | 92 def __enter__(self): |
93 self.Start() | 93 self.Start() |
94 | 94 |
95 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb): | 95 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb): |
96 self.Stop() | 96 self.Stop() |
97 | 97 |
98 def _InstallTestCa(self): | 98 def _InstallTestCa(self): |
99 """Generates and deploys a test certificate authority.""" | 99 """Generates and deploys a test certificate authority.""" |
100 print 'Installing test certificate authority on device: %s' % ( | 100 print 'Installing test certificate authority on device: %s' % ( |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 print 'Pulling cyglog data...' | 352 print 'Pulling cyglog data...' |
353 self._SetUpHostFolders() | 353 self._SetUpHostFolders() |
354 self._device.PullFile( | 354 self._device.PullFile( |
355 self._DEVICE_CYGLOG_DIR, self._host_cyglog_dir) | 355 self._DEVICE_CYGLOG_DIR, self._host_cyglog_dir) |
356 files = os.listdir(self._host_cyglog_dir) | 356 files = os.listdir(self._host_cyglog_dir) |
357 | 357 |
358 if len(files) == 0: | 358 if len(files) == 0: |
359 raise NoCyglogDataError('No cyglog data was collected') | 359 raise NoCyglogDataError('No cyglog data was collected') |
360 | 360 |
361 return [os.path.join(self._host_cyglog_dir, x) for x in files] | 361 return [os.path.join(self._host_cyglog_dir, x) for x in files] |
OLD | NEW |