| 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 if original_module is None: | 53 if original_module is None: |
| 54 # This will happen when we override built-in functions, like open. | 54 # This will happen when we override built-in functions, like open. |
| 55 # If we don't delete the attribute, we will shadow the built-in | 55 # If we don't delete the attribute, we will shadow the built-in |
| 56 # function with an attribute set to None. | 56 # function with an attribute set to None. |
| 57 delattr(self._base_module, module_name) | 57 delattr(self._base_module, module_name) |
| 58 else: | 58 else: |
| 59 setattr(self._base_module, module_name, original_module) | 59 setattr(self._base_module, module_name, original_module) |
| 60 self._overrides = {} | 60 self._overrides = {} |
| 61 | 61 |
| 62 | 62 |
| 63 class AndroidCommands(object): | |
| 64 | |
| 65 def __init__(self): | |
| 66 self.can_access_protected_file_contents = False | |
| 67 | |
| 68 def CanAccessProtectedFileContents(self): | |
| 69 return self.can_access_protected_file_contents | |
| 70 | |
| 71 | |
| 72 class AdbDevice(object): | 63 class AdbDevice(object): |
| 73 | 64 |
| 74 def __init__(self): | 65 def __init__(self): |
| 66 self.has_root = False |
| 67 self.needs_su = False |
| 75 self.shell_command_handlers = {} | 68 self.shell_command_handlers = {} |
| 76 self.mock_content = [] | 69 self.mock_content = [] |
| 77 self.system_properties = {} | 70 self.system_properties = {} |
| 78 if self.system_properties.get('ro.product.cpu.abi') == None: | 71 if self.system_properties.get('ro.product.cpu.abi') == None: |
| 79 self.system_properties['ro.product.cpu.abi'] = 'armeabi-v7a' | 72 self.system_properties['ro.product.cpu.abi'] = 'armeabi-v7a' |
| 80 self.old_interface = AndroidCommands() | 73 |
| 74 def HasRoot(self): |
| 75 return self.has_root |
| 76 |
| 77 def NeedsSU(self): |
| 78 return self.needs_su |
| 81 | 79 |
| 82 def RunShellCommand(self, args, **_kwargs): | 80 def RunShellCommand(self, args, **_kwargs): |
| 83 if isinstance(args, basestring): | 81 if isinstance(args, basestring): |
| 84 args = shlex.split(args) | 82 args = shlex.split(args) |
| 85 handler = self.shell_command_handlers[args[0]] | 83 handler = self.shell_command_handlers[args[0]] |
| 86 return handler(args) | 84 return handler(args) |
| 87 | 85 |
| 88 def FileExists(self, _): | 86 def FileExists(self, _): |
| 89 return False | 87 return False |
| 90 | 88 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 elif device_id == 'failure': | 532 elif device_id == 'failure': |
| 535 raise Exception('Test exception.') | 533 raise Exception('Test exception.') |
| 536 | 534 |
| 537 def install_cert(self, overwrite_cert=False): | 535 def install_cert(self, overwrite_cert=False): |
| 538 pass | 536 pass |
| 539 | 537 |
| 540 class PlatformSettingsStub(object): | 538 class PlatformSettingsStub(object): |
| 541 @staticmethod | 539 @staticmethod |
| 542 def HasSniSupport(): | 540 def HasSniSupport(): |
| 543 return True | 541 return True |
| OLD | NEW |