OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
| 6 import json |
| 7 import logging |
6 | 8 |
7 from pylib import constants | 9 from pylib import constants |
8 from pylib.base import test_instance | 10 from pylib.base import test_instance |
9 from pylib.utils import apk_helper | 11 from pylib.utils import apk_helper |
10 | 12 |
11 class UirobotTestInstance(test_instance.TestInstance): | 13 class UirobotTestInstance(test_instance.TestInstance): |
12 | 14 |
13 def __init__(self, args, error_func): | 15 def __init__(self, args, error_func): |
14 """Constructor. | 16 """Constructor. |
15 | 17 |
16 Args: | 18 Args: |
17 args: Command line arguments. | 19 args: Command line arguments. |
18 """ | 20 """ |
19 super(UirobotTestInstance, self).__init__() | 21 super(UirobotTestInstance, self).__init__() |
20 if not args.app_under_test: | 22 if not args.app_under_test: |
21 error_func('Must set --app-under-test.') | 23 error_func('Must set --app-under-test.') |
22 self._app_under_test = args.app_under_test | 24 self._app_under_test = args.app_under_test |
| 25 self._minutes = args.minutes |
23 | 26 |
24 if args.device_type == 'Android': | 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': |
25 self._suite = 'Android Uirobot' | 40 self._suite = 'Android Uirobot' |
26 self._package_name = apk_helper.GetPackageName(self._app_under_test) | 41 self._package_name = apk_helper.GetPackageName(self._app_under_test) |
27 | 42 elif device_type == 'iOS': |
28 elif args.device_type == 'iOS': | |
29 self._suite = 'iOS Uirobot' | 43 self._suite = 'iOS Uirobot' |
30 self._package_name = self._app_under_test | 44 self._package_name = self._app_under_test |
31 | 45 |
32 self._minutes = args.minutes | |
33 | 46 |
34 #override | 47 #override |
35 def TestType(self): | 48 def TestType(self): |
36 """Returns type of test.""" | 49 """Returns type of test.""" |
37 return 'uirobot' | 50 return 'uirobot' |
38 | 51 |
39 #override | 52 #override |
40 def SetUp(self): | 53 def SetUp(self): |
41 """Setup for test.""" | 54 """Setup for test.""" |
42 pass | 55 pass |
(...skipping 14 matching lines...) Expand all Loading... |
57 return self._minutes | 70 return self._minutes |
58 | 71 |
59 @property | 72 @property |
60 def package_name(self): | 73 def package_name(self): |
61 """Returns the name of the package in the APK.""" | 74 """Returns the name of the package in the APK.""" |
62 return self._package_name | 75 return self._package_name |
63 | 76 |
64 @property | 77 @property |
65 def suite(self): | 78 def suite(self): |
66 return self._suite | 79 return self._suite |
OLD | NEW |