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
3 # found in the LICENSE file.
8 from devil
.android
import apk_helper
9 from pylib
.base
import test_instance
11 class UirobotTestInstance(test_instance
.TestInstance
):
13 def __init__(self
, args
, error_func
):
17 args: Command line arguments.
19 super(UirobotTestInstance
, self
).__init
__()
20 if not args
.app_under_test
:
21 error_func('Must set --app-under-test.')
22 self
._app
_under
_test
= args
.app_under_test
23 self
._minutes
= args
.minutes
25 if args
.remote_device_file
:
26 with
open(args
.remote_device_file
) as remote_device_file
:
27 device_json
= json
.load(remote_device_file
)
30 device_type
= device_json
.get('device_type', 'Android')
32 if device_type
and device_type
!= args
.device_type
:
33 logging
.info('Overriding device_type from %s to %s',
34 device_type
, args
.device_type
)
35 device_type
= args
.device_type
37 if device_type
== 'Android':
38 self
._suite
= 'Android Uirobot'
39 self
._package
_name
= apk_helper
.GetPackageName(self
._app
_under
_test
)
40 elif device_type
== 'iOS':
41 self
._suite
= 'iOS Uirobot'
42 self
._package
_name
= self
._app
_under
_test
47 """Returns type of test."""
57 """Teardown for test."""
61 def app_under_test(self
):
62 """Returns the app to run the test on."""
63 return self
._app
_under
_test
67 """Returns the number of minutes to run the uirobot for."""
71 def package_name(self
):
72 """Returns the name of the package in the APK."""
73 return self
._package
_name