OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 """Provides stubs for os, sys and subprocess for testing | 5 """Provides stubs for os, sys and subprocess for testing |
6 | 6 |
7 This test allows one to test code that itself uses os, sys, and subprocess. | 7 This test allows one to test code that itself uses os, sys, and subprocess. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
11 import re | 11 import re |
12 import shlex | 12 import shlex |
13 import sys | 13 import sys |
14 | 14 |
15 | 15 |
16 class Override(object): | 16 class Override(object): |
17 def __init__(self, base_module, module_list): | 17 def __init__(self, base_module, module_list): |
18 stubs = {'adb_commands': AdbCommandsModuleStub, | 18 stubs = {'adb_commands': AdbCommandsModuleStub, |
19 'cloud_storage': CloudStorageModuleStub, | 19 'cloud_storage': CloudStorageModuleStub, |
20 'open': OpenFunctionStub, | 20 'open': OpenFunctionStub, |
21 'os': OsModuleStub, | 21 'os': OsModuleStub, |
22 'perf_control': PerfControlModuleStub, | 22 'perf_control': PerfControlModuleStub, |
23 'raw_input': RawInputFunctionStub, | 23 'raw_input': RawInputFunctionStub, |
24 'subprocess': SubprocessModuleStub, | 24 'subprocess': SubprocessModuleStub, |
25 'sys': SysModuleStub, | 25 'sys': SysModuleStub, |
26 'thermal_throttle': ThermalThrottleModuleStub, | 26 'thermal_throttle': ThermalThrottleModuleStub, |
27 'logging': LoggingStub, | 27 'logging': LoggingStub, |
28 'certutils': CertUtilsStub, | 28 'certutils': CertUtilsStub, |
29 'adb_install_cert': AdbInstallCertStub | 29 'adb_install_cert': AdbInstallCertStub, |
| 30 'platformsettings': PlatformSettingsStub, |
30 } | 31 } |
31 self.adb_commands = None | 32 self.adb_commands = None |
32 self.os = None | 33 self.os = None |
33 self.subprocess = None | 34 self.subprocess = None |
34 self.sys = None | 35 self.sys = None |
35 | 36 |
36 self._base_module = base_module | 37 self._base_module = base_module |
37 self._overrides = {} | 38 self._overrides = {} |
38 | 39 |
39 for module_name in module_list: | 40 for module_name in module_list: |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 openssl_import_error = None | 519 openssl_import_error = None |
519 | 520 |
520 @staticmethod | 521 @staticmethod |
521 def write_dummy_ca_cert(_ca_cert_str, _key_str, cert_path): | 522 def write_dummy_ca_cert(_ca_cert_str, _key_str, cert_path): |
522 pass | 523 pass |
523 | 524 |
524 @staticmethod | 525 @staticmethod |
525 def generate_dummy_ca_cert(): | 526 def generate_dummy_ca_cert(): |
526 return '-', '-' | 527 return '-', '-' |
527 | 528 |
528 @staticmethod | |
529 def has_sni(): | |
530 return True | |
531 | |
532 class AdbInstallCertStub(object): | 529 class AdbInstallCertStub(object): |
533 class AndroidCertInstaller(object): | 530 class AndroidCertInstaller(object): |
534 def __init__(self, device_id, _cert_name, _cert_path): | 531 def __init__(self, device_id, _cert_name, _cert_path): |
535 if device_id == 'success': | 532 if device_id == 'success': |
536 pass | 533 pass |
537 elif device_id == 'failure': | 534 elif device_id == 'failure': |
538 raise Exception('Test exception.') | 535 raise Exception('Test exception.') |
539 | 536 |
540 def install_cert(self, overwrite_cert=False): | 537 def install_cert(self, overwrite_cert=False): |
541 pass | 538 pass |
| 539 |
| 540 class PlatformSettingsStub(object): |
| 541 @staticmethod |
| 542 def HasSniSupport(): |
| 543 return True |
OLD | NEW |