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.
9 from pylib
import constants
10 from pylib
.base
import test_instance
11 from pylib
.utils
import apk_helper
13 class UirobotTestInstance(test_instance
.TestInstance
):
15 def __init__(self
, args
, error_func
):
19 args: Command line arguments.
21 super(UirobotTestInstance
, self
).__init
__()
22 if not args
.app_under_test
:
23 error_func('Must set --app-under-test.')
24 self
._app
_under
_test
= args
.app_under_test
25 self
._minutes
= args
.minutes
27 if args
.remote_device_file
:
28 with
open(args
.remote_device_file
) as remote_device_file
:
29 device_json
= json
.load(remote_device_file
)
32 device_type
= device_json
.get('device_type', 'Android')
34 if device_type
and device_type
!= args
.device_type
:
35 logging
.info('Overriding device_type from %s to %s',
36 device_type
, args
.device_type
)
37 device_type
= args
.device_type
39 if device_type
== 'Android':
40 self
._suite
= 'Android Uirobot'
41 self
._package
_name
= apk_helper
.GetPackageName(self
._app
_under
_test
)
42 elif device_type
== 'iOS':
43 self
._suite
= 'iOS Uirobot'
44 self
._package
_name
= self
._app
_under
_test
49 """Returns type of test."""
59 """Teardown for test."""
63 def app_under_test(self
):
64 """Returns the app to run the test on."""
65 return self
._app
_under
_test
69 """Returns the number of minutes to run the uirobot for."""
73 def package_name(self
):
74 """Returns the name of the package in the APK."""
75 return self
._package
_name