Add support for ios_uirobot
BUG=428729 Review URL: https://codereview.chromium.org/840393003 Cr-Original-Commit-Position: refs/heads/master@{#312854} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: a46fc56cbdf4fa62d3111f91cc81dc598b24b630
This commit is contained in:
Родитель
de6c27426f
Коммит
7d847fe2cf
|
@ -19,7 +19,6 @@ def CreateTestInstance(args, error_func):
|
|||
return instrumentation_test_instance.InstrumentationTestInstance(
|
||||
args, isolator.Isolator(constants.ISOLATE_DEPS_DIR), error_func)
|
||||
elif args.command == 'uirobot':
|
||||
return uirobot_test_instance.UirobotTestInstance(args)
|
||||
|
||||
return uirobot_test_instance.UirobotTestInstance(args, error_func)
|
||||
|
||||
error_func('Unable to create %s test instance.' % args.command)
|
||||
|
|
|
@ -211,6 +211,7 @@ LOCAL_MACHINE_TESTS = ['junit', 'python']
|
|||
VALID_ENVIRONMENTS = ['local', 'remote_device']
|
||||
VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey',
|
||||
'perf', 'python', 'uiautomator', 'uirobot']
|
||||
VALID_DEVICE_TYPES = ['Android', 'iOS']
|
||||
|
||||
|
||||
def GetBuildType():
|
||||
|
|
|
@ -65,6 +65,7 @@ class RemoteDeviceEnvironment(environment.Environment):
|
|||
self._runner_type = args.runner_type
|
||||
self._device = ''
|
||||
self._verbose_count = args.verbose_count
|
||||
self._device_type = args.device_type
|
||||
self._timeouts = {
|
||||
'queueing': 60 * 10,
|
||||
'installing': 60 * 10,
|
||||
|
@ -147,7 +148,7 @@ class RemoteDeviceEnvironment(environment.Environment):
|
|||
device_list = dev_list_res.json()['response']
|
||||
random.shuffle(device_list)
|
||||
for device in device_list:
|
||||
if device['os_name'] != 'Android':
|
||||
if device['os_name'] != self._device_type:
|
||||
continue
|
||||
if self._remote_device and device['name'] != self._remote_device:
|
||||
continue
|
||||
|
@ -169,9 +170,9 @@ class RemoteDeviceEnvironment(environment.Environment):
|
|||
return c
|
||||
return 0
|
||||
|
||||
logging.critical('Available Android Devices:')
|
||||
android_devices = (d for d in device_list if d['os_name'] == 'Android')
|
||||
for d in sorted(android_devices, compare_devices):
|
||||
logging.critical('Available %s Devices:', self._device_type)
|
||||
devices = (d for d in device_list if d['os_name'] == self._device_type)
|
||||
for d in sorted(devices, compare_devices):
|
||||
logging.critical(' %s %s', d['os_version'].ljust(7), d['name'])
|
||||
|
||||
def _NoDeviceFound(self, device_list):
|
||||
|
@ -218,3 +219,7 @@ class RemoteDeviceEnvironment(environment.Environment):
|
|||
@property
|
||||
def verbose_count(self):
|
||||
return self._verbose_count
|
||||
|
||||
@property
|
||||
def device_type(self):
|
||||
return self._device_type
|
||||
|
|
|
@ -18,7 +18,6 @@ from pylib.remote.device import remote_device_helper
|
|||
class RemoteDeviceUirobotTestRun(remote_device_test_run.RemoteDeviceTestRun):
|
||||
"""Run uirobot tests on a remote device."""
|
||||
|
||||
DEFAULT_RUNNER_TYPE = 'android_robot'
|
||||
|
||||
def __init__(self, env, test_instance):
|
||||
"""Constructor.
|
||||
|
@ -37,10 +36,19 @@ class RemoteDeviceUirobotTestRun(remote_device_test_run.RemoteDeviceTestRun):
|
|||
def _TriggerSetUp(self):
|
||||
"""Set up the triggering of a test run."""
|
||||
logging.info('Triggering test run.')
|
||||
self._app_id = self._UploadAppToDevice(self._test_instance.apk_under_test)
|
||||
|
||||
if self._env.device_type == 'Android':
|
||||
default_runner_type = 'android_robot'
|
||||
elif self._env.device_type == 'iOS':
|
||||
default_runner_type = 'ios_robot'
|
||||
else:
|
||||
raise remote_device_helper.RemoteDeviceError(
|
||||
'Unkown device type: %s' % self._env.device_type)
|
||||
|
||||
self._app_id = self._UploadAppToDevice(self._test_instance.app_under_test)
|
||||
if not self._env.runner_type:
|
||||
runner_type = self.DEFAULT_RUNNER_TYPE
|
||||
logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE)
|
||||
runner_type = default_runner_type
|
||||
logging.info('Using default runner type: %s', default_runner_type)
|
||||
else:
|
||||
runner_type = self._env.runner_type
|
||||
self._test_id = self._GetTestByName(runner_type)
|
||||
|
|
|
@ -10,18 +10,26 @@ from pylib.utils import apk_helper
|
|||
|
||||
class UirobotTestInstance(test_instance.TestInstance):
|
||||
|
||||
def __init__(self, args):
|
||||
def __init__(self, args, error_func):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
args: Command line arguments.
|
||||
"""
|
||||
super(UirobotTestInstance, self).__init__()
|
||||
self._apk_under_test = os.path.join(
|
||||
constants.GetOutDirectory(), args.app_under_test)
|
||||
if not args.app_under_test:
|
||||
error_func('Must set --app-under-test.')
|
||||
self._app_under_test = args.app_under_test
|
||||
|
||||
if args.device_type == 'Android':
|
||||
self._suite = 'Android Uirobot'
|
||||
self._package_name = apk_helper.GetPackageName(self._app_under_test)
|
||||
|
||||
elif args.device_type == 'iOS':
|
||||
self._suite = 'iOS Uirobot'
|
||||
self._package_name = self._app_under_test
|
||||
|
||||
self._minutes = args.minutes
|
||||
self._package_name = apk_helper.GetPackageName(self._apk_under_test)
|
||||
self._suite = 'Android Uirobot'
|
||||
|
||||
#override
|
||||
def TestType(self):
|
||||
|
@ -39,9 +47,9 @@ class UirobotTestInstance(test_instance.TestInstance):
|
|||
pass
|
||||
|
||||
@property
|
||||
def apk_under_test(self):
|
||||
def app_under_test(self):
|
||||
"""Returns the app to run the test on."""
|
||||
return self._apk_under_test
|
||||
return self._app_under_test
|
||||
|
||||
@property
|
||||
def minutes(self):
|
||||
|
|
|
@ -102,7 +102,6 @@ def AddCommonOptions(parser):
|
|||
help='If set, will dump results in JSON form '
|
||||
'to specified file.')
|
||||
|
||||
|
||||
def ProcessCommonOptions(args):
|
||||
"""Processes and handles all common options."""
|
||||
run_tests_helper.SetLogLevel(args.verbose_count)
|
||||
|
@ -140,10 +139,11 @@ def AddRemoteDeviceOptions(parser):
|
|||
group.add_argument('--api-port', help='Port to send HTTP requests to.')
|
||||
group.add_argument('--runner-type', default='',
|
||||
help='Type of test to run as.')
|
||||
group.add_argument('--runner-package', default='',
|
||||
help='Package name of test.')
|
||||
group.add_argument('--app-under-test', default='',
|
||||
help='APK to run tests on.')
|
||||
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'))
|
||||
|
||||
api_secret_group = group.add_mutually_exclusive_group()
|
||||
api_secret_group.add_argument('--api-secret', default='',
|
||||
|
|
Загрузка…
Ссылка в новой задаче