| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Run specific test on specific environment.""" | 5 """Run specific test on specific environment.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 |
| 11 from pylib import constants | 12 from pylib import constants |
| 13 |
| 14 sys.path.append(os.path.join( |
| 15 constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib')) |
| 16 |
| 12 from pylib.base import base_test_result | 17 from pylib.base import base_test_result |
| 13 from pylib.remote.device import appurify_sanitized | 18 from pylib.remote.device import appurify_sanitized |
| 14 from pylib.remote.device import remote_device_test_run | 19 from pylib.remote.device import remote_device_test_run |
| 15 from pylib.remote.device import remote_device_helper | 20 from pylib.remote.device import remote_device_helper |
| 16 | 21 |
| 17 | 22 |
| 18 class RemoteDeviceUirobotRun(remote_device_test_run.RemoteDeviceTestRun): | 23 class RemoteDeviceUirobotRun(remote_device_test_run.RemoteDeviceTestRun): |
| 19 """Run uirobot tests on a remote device.""" | 24 """Run uirobot tests on a remote device.""" |
| 20 | 25 |
| 21 DEFAULT_RUNNER_TYPE = 'android_robot' | 26 DEFAULT_RUNNER_TYPE = 'ios_robot' |
| 22 | 27 |
| 23 def __init__(self, env, test_instance): | 28 def __init__(self, env, test_instance): |
| 24 """Constructor. | 29 """Constructor. |
| 25 | 30 |
| 26 Args: | 31 Args: |
| 27 env: Environment the tests will run in. | 32 env: Environment the tests will run in. |
| 28 test_instance: The test that will be run. | 33 test_instance: The test that will be run. |
| 29 """ | 34 """ |
| 30 super(RemoteDeviceUirobotRun, self).__init__(env, test_instance) | 35 super(RemoteDeviceUirobotRun, self).__init__(env, test_instance) |
| 31 | 36 |
| 32 #override | 37 #override |
| 33 def TestPackage(self): | 38 def TestPackage(self): |
| 34 return self._test_instance.package_name | 39 return self._test_instance.package_name |
| 35 | 40 |
| 36 #override | 41 #override |
| 37 def _TriggerSetUp(self): | 42 def _TriggerSetUp(self): |
| 38 """Set up the triggering of a test run.""" | 43 """Set up the triggering of a test run.""" |
| 39 logging.info('Triggering test run.') | 44 logging.info('Triggering test run.') |
| 40 self._app_id = self._UploadAppToDevice(self._test_instance.apk_under_test) | 45 self._app_id = self._UploadAppToDevice(self._test_instance.app_under_test) |
| 41 if not self._env.runner_type: | 46 if not self._env.runner_type: |
| 42 runner_type = self.DEFAULT_RUNNER_TYPE | 47 runner_type = self.DEFAULT_RUNNER_TYPE |
| 43 logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE) | 48 logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE) |
| 44 else: | 49 else: |
| 45 runner_type = self._env.runner_type | 50 runner_type = self._env.runner_type |
| 46 self._test_id = self._GetTestByName(runner_type) | 51 self._test_id = self._GetTestByName(runner_type) |
| 47 config_body = {'duration': self._test_instance.minutes} | 52 config_body = {'duration': self._test_instance.minutes} |
| 48 self._SetTestConfig(runner_type, config_body) | 53 self._SetTestConfig(runner_type, config_body) |
| 49 | 54 |
| 50 #override | 55 #override |
| 51 def _ParseTestResults(self): | 56 def _ParseTestResults(self): |
| 52 logging.info('Parsing results from remote service.') | 57 logging.info('Parsing results from remote service.') |
| 53 results = base_test_result.TestRunResults() | 58 results = base_test_result.TestRunResults() |
| 54 if self._results['results']['pass']: | 59 if self._results['results']['pass']: |
| 55 result_type = base_test_result.ResultType.PASS | 60 result_type = base_test_result.ResultType.PASS |
| 56 else: | 61 else: |
| 57 result_type = base_test_result.ResultType.FAIL | 62 result_type = base_test_result.ResultType.FAIL |
| 58 results.AddResult(base_test_result.BaseTestResult('uirobot', result_type)) | 63 results.AddResult(base_test_result.BaseTestResult('uirobot', result_type)) |
| 59 return results | 64 return results |
| OLD | NEW |