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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 else: | 44 else: |
45 raise remote_device_helper.RemoteDeviceError( | 45 raise remote_device_helper.RemoteDeviceError( |
46 'Unkown device type: %s' % self._env.device_type) | 46 'Unkown device type: %s' % self._env.device_type) |
47 | 47 |
48 self._app_id = self._UploadAppToDevice(self._test_instance.app_under_test) | 48 self._app_id = self._UploadAppToDevice(self._test_instance.app_under_test) |
49 if not self._env.runner_type: | 49 if not self._env.runner_type: |
50 runner_type = default_runner_type | 50 runner_type = default_runner_type |
51 logging.info('Using default runner type: %s', default_runner_type) | 51 logging.info('Using default runner type: %s', default_runner_type) |
52 else: | 52 else: |
53 runner_type = self._env.runner_type | 53 runner_type = self._env.runner_type |
54 self._test_id = self._GetTestByName(runner_type) | 54 |
| 55 self._test_id = self._UploadTestToDevice( |
| 56 'android_robot', None, app_id=self._app_id) |
55 config_body = {'duration': self._test_instance.minutes} | 57 config_body = {'duration': self._test_instance.minutes} |
56 self._SetTestConfig(runner_type, config_body) | 58 self._SetTestConfig(runner_type, config_body) |
57 | 59 |
| 60 |
| 61 # TODO(rnephew): Switch to base class implementation when supported. |
| 62 #override |
| 63 def _UploadTestToDevice(self, test_type, test_path, app_id=None): |
| 64 if test_path: |
| 65 logging.info("Ignoring test path.") |
| 66 data = { |
| 67 'access_token':self._env.token, |
| 68 'test_type':test_type, |
| 69 'app_id':app_id, |
| 70 } |
| 71 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, |
| 72 logging.WARNING): |
| 73 test_upload_res = appurify_sanitized.utils.post('tests/upload', |
| 74 data, None) |
| 75 remote_device_helper.TestHttpResponse( |
| 76 test_upload_res, 'Unable to get UiRobot test id.') |
| 77 return test_upload_res.json()['response']['test_id'] |
| 78 |
58 #override | 79 #override |
59 def _ParseTestResults(self): | 80 def _ParseTestResults(self): |
60 logging.info('Parsing results from remote service.') | 81 logging.info('Parsing results from remote service.') |
61 results = base_test_result.TestRunResults() | 82 results = base_test_result.TestRunResults() |
62 if self._results['results']['pass']: | 83 if self._results['results']['pass']: |
63 result_type = base_test_result.ResultType.PASS | 84 result_type = base_test_result.ResultType.PASS |
64 else: | 85 else: |
65 result_type = base_test_result.ResultType.FAIL | 86 result_type = base_test_result.ResultType.FAIL |
66 results.AddResult(base_test_result.BaseTestResult('uirobot', result_type)) | 87 results.AddResult(base_test_result.BaseTestResult('uirobot', result_type)) |
67 return results | 88 return results |
OLD | NEW |