OLD | NEW |
| (Empty) |
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. | |
4 | |
5 import json | |
6 import logging | |
7 | |
8 from devil.android import apk_helper | |
9 from pylib.base import test_instance | |
10 | |
11 class UirobotTestInstance(test_instance.TestInstance): | |
12 | |
13 def __init__(self, args, error_func): | |
14 """Constructor. | |
15 | |
16 Args: | |
17 args: Command line arguments. | |
18 """ | |
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 | |
24 | |
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) | |
28 else: | |
29 device_json = {} | |
30 device_type = device_json.get('device_type', 'Android') | |
31 if args.device_type: | |
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 | |
36 | |
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 | |
43 | |
44 | |
45 #override | |
46 def TestType(self): | |
47 """Returns type of test.""" | |
48 return 'uirobot' | |
49 | |
50 #override | |
51 def SetUp(self): | |
52 """Setup for test.""" | |
53 pass | |
54 | |
55 #override | |
56 def TearDown(self): | |
57 """Teardown for test.""" | |
58 pass | |
59 | |
60 @property | |
61 def app_under_test(self): | |
62 """Returns the app to run the test on.""" | |
63 return self._app_under_test | |
64 | |
65 @property | |
66 def minutes(self): | |
67 """Returns the number of minutes to run the uirobot for.""" | |
68 return self._minutes | |
69 | |
70 @property | |
71 def package_name(self): | |
72 """Returns the name of the package in the APK.""" | |
73 return self._package_name | |
74 | |
75 @property | |
76 def suite(self): | |
77 return self._suite | |
OLD | NEW |