| OLD | NEW | 
|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. | 
| 6 | 6 | 
| 7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. | 
| 8 """ | 8 """ | 
| 9 | 9 | 
| 10 import collections | 10 import collections | 
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1004 | 1004 | 
| 1005     Args: | 1005     Args: | 
| 1006       file_name: Full path of file to check. | 1006       file_name: Full path of file to check. | 
| 1007 | 1007 | 
| 1008     Returns: | 1008     Returns: | 
| 1009       True if the file exists, False otherwise. | 1009       True if the file exists, False otherwise. | 
| 1010     """ | 1010     """ | 
| 1011     assert '"' not in file_name, 'file_name cannot contain double quotes' | 1011     assert '"' not in file_name, 'file_name cannot contain double quotes' | 
| 1012     status = self._adb.SendShellCommand( | 1012     status = self._adb.SendShellCommand( | 
| 1013         '\'test -f "%s"; echo $?\'' % (file_name)) | 1013         '\'test -f "%s"; echo $?\'' % (file_name)) | 
| 1014     return int(status) == 0 | 1014     if not status[0].find('test: not found'): | 
|  | 1015       return int(status) == 0 | 
|  | 1016 | 
|  | 1017     status = self._adb.SendShellCommand('ls "%s"' % (file_name)) | 
|  | 1018     if 'No such file or directory' not in status[0]: | 
|  | 1019       return True | 
|  | 1020 | 
|  | 1021     return False | 
| 1015 | 1022 | 
| 1016   def RunMonkey(self, package_name, category=None, throttle=100, seed=None, | 1023   def RunMonkey(self, package_name, category=None, throttle=100, seed=None, | 
| 1017                 event_count=10000, verbosity=1, extra_args=''): | 1024                 event_count=10000, verbosity=1, extra_args=''): | 
| 1018     """Runs monkey test for a given package. | 1025     """Runs monkey test for a given package. | 
| 1019 | 1026 | 
| 1020     Args: | 1027     Args: | 
| 1021       package_name: Allowed package. | 1028       package_name: Allowed package. | 
| 1022       category: A list of allowed categories. | 1029       category: A list of allowed categories. | 
| 1023       throttle: Delay between events (ms). | 1030       throttle: Delay between events (ms). | 
| 1024       seed: Seed value for pseduo-random generator. Same seed value | 1031       seed: Seed value for pseduo-random generator. Same seed value | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 1039            ' '.join(['-c %s' % c for c in category]), | 1046            ' '.join(['-c %s' % c for c in category]), | 
| 1040            '--throttle %d' % throttle, | 1047            '--throttle %d' % throttle, | 
| 1041            '-s %d' % seed, | 1048            '-s %d' % seed, | 
| 1042            '-v ' * verbosity, | 1049            '-v ' * verbosity, | 
| 1043            '--monitor-native-crashes', | 1050            '--monitor-native-crashes', | 
| 1044            '--kill-process-after-error', | 1051            '--kill-process-after-error', | 
| 1045            extra_args, | 1052            extra_args, | 
| 1046            '%d' % event_count] | 1053            '%d' % event_count] | 
| 1047     return self.RunShellCommand(' '.join(cmd), | 1054     return self.RunShellCommand(' '.join(cmd), | 
| 1048                                 timeout_time=event_count*throttle*1.5) | 1055                                 timeout_time=event_count*throttle*1.5) | 
| OLD | NEW | 
|---|