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