Chromium Code Reviews| 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 | |
| 33 device_type = device_json.get('device_type', 'Android') | |
|
jbudorick
2015/02/02 20:28:54
from the other review:
Perhaps we should either:
rnephew (Wrong account)
2015/02/02 20:41:03
Alternatively, I was thinking of having device_typ
| |
| 34 if args.device_type: | |
| 35 if device_type and device_type != args.device_type: | |
| 36 logging.info('Overriding device_type from %s to %s', | |
| 37 device_type, args.device_type) | |
| 38 device_type = args.device_type | |
| 39 | |
| 40 if device_type == 'Android': | |
| 25 self._suite = 'Android Uirobot' | 41 self._suite = 'Android Uirobot' |
| 26 self._package_name = apk_helper.GetPackageName(self._app_under_test) | 42 self._package_name = apk_helper.GetPackageName(self._app_under_test) |
| 27 | 43 elif device_type == 'iOS': |
| 28 elif args.device_type == 'iOS': | |
| 29 self._suite = 'iOS Uirobot' | 44 self._suite = 'iOS Uirobot' |
| 30 self._package_name = self._app_under_test | 45 self._package_name = self._app_under_test |
| 31 | 46 |
| 32 self._minutes = args.minutes | |
| 33 | 47 |
| 34 #override | 48 #override |
| 35 def TestType(self): | 49 def TestType(self): |
| 36 """Returns type of test.""" | 50 """Returns type of test.""" |
| 37 return 'uirobot' | 51 return 'uirobot' |
| 38 | 52 |
| 39 #override | 53 #override |
| 40 def SetUp(self): | 54 def SetUp(self): |
| 41 """Setup for test.""" | 55 """Setup for test.""" |
| 42 pass | 56 pass |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 57 return self._minutes | 71 return self._minutes |
| 58 | 72 |
| 59 @property | 73 @property |
| 60 def package_name(self): | 74 def package_name(self): |
| 61 """Returns the name of the package in the APK.""" | 75 """Returns the name of the package in the APK.""" |
| 62 return self._package_name | 76 return self._package_name |
| 63 | 77 |
| 64 @property | 78 @property |
| 65 def suite(self): | 79 def suite(self): |
| 66 return self._suite | 80 return self._suite |
| OLD | NEW |