From f5a3874ebf6d7ccb163f4c84fc1df04cfcb26a8c Mon Sep 17 00:00:00 2001 From: rnephew Date: Fri, 23 Jan 2015 14:20:14 -0800 Subject: [PATCH] Use upload test to get uirobot test id. BUG= Review URL: https://codereview.chromium.org/872783003 Cr-Original-Commit-Position: refs/heads/master@{#312946} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 3932d125d7a8c73e41fc1f768d5ea443f349aa9d --- .../remote/device/remote_device_test_run.py | 2 +- .../device/remote_device_uirobot_test_run.py | 23 ++++++++++++++++++- android/test_runner.py | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/android/pylib/remote/device/remote_device_test_run.py b/android/pylib/remote/device/remote_device_test_run.py index c4f75b01f..0b2deae4c 100644 --- a/android/pylib/remote/device/remote_device_test_run.py +++ b/android/pylib/remote/device/remote_device_test_run.py @@ -19,7 +19,7 @@ from pylib.remote.device import remote_device_helper from pylib.utils import zip_utils class RemoteDeviceTestRun(test_run.TestRun): - """Run gtests and uirobot tests on a remote device.""" + """Run tests on a remote device.""" _TEST_RUN_KEY = 'test_run' _TEST_RUN_ID_KEY = 'test_run_id' diff --git a/android/pylib/remote/device/remote_device_uirobot_test_run.py b/android/pylib/remote/device/remote_device_uirobot_test_run.py index ed8db49c4..936db0a45 100644 --- a/android/pylib/remote/device/remote_device_uirobot_test_run.py +++ b/android/pylib/remote/device/remote_device_uirobot_test_run.py @@ -51,10 +51,31 @@ class RemoteDeviceUirobotTestRun(remote_device_test_run.RemoteDeviceTestRun): logging.info('Using default runner type: %s', default_runner_type) else: runner_type = self._env.runner_type - self._test_id = self._GetTestByName(runner_type) + + self._test_id = self._UploadTestToDevice( + 'android_robot', None, app_id=self._app_id) config_body = {'duration': self._test_instance.minutes} self._SetTestConfig(runner_type, config_body) + + # TODO(rnephew): Switch to base class implementation when supported. + #override + def _UploadTestToDevice(self, test_type, test_path, app_id=None): + if test_path: + logging.info("Ignoring test path.") + data = { + 'access_token':self._env.token, + 'test_type':test_type, + 'app_id':app_id, + } + with appurify_sanitized.SanitizeLogging(self._env.verbose_count, + logging.WARNING): + test_upload_res = appurify_sanitized.utils.post('tests/upload', + data, None) + remote_device_helper.TestHttpResponse( + test_upload_res, 'Unable to get UiRobot test id.') + return test_upload_res.json()['response']['test_id'] + #override def _ParseTestResults(self): logging.info('Parsing results from remote service.') diff --git a/android/test_runner.py b/android/test_runner.py index 19649ff39..6eb368af4 100755 --- a/android/test_runner.py +++ b/android/test_runner.py @@ -140,7 +140,6 @@ def AddRemoteDeviceOptions(parser): group.add_argument('--runner-type', default='', help='Type of test to run as.') group.add_argument('--runner-package', help='Package name of test.') - group.add_argument('--app-under-test', help='APK to run tests on.') group.add_argument('--device-type', default='Android', choices=constants.VALID_DEVICE_TYPES, help=('Type of device to run on. iOS or android')) @@ -507,6 +506,7 @@ def AddUirobotTestOptions(parser): """Adds uirobot test options to |option_parser|.""" group = parser.add_argument_group('Uirobot Test Options') + group.add_argument('--app-under-test', help='APK to run tests on.') group.add_argument( '--minutes', default=5, type=int, help='Number of minutes to run uirobot test [default: %default].')