Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | |
|
jbudorick
2014/11/21 00:17:24
These three remote_device_* files should be in bui
rnephew (Reviews Here)
2014/11/21 18:26:46
Done.
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Creates test config files for remote devices.""" | |
| 6 | |
| 7 import os | |
| 8 | |
| 9 | |
| 10 class RemoteDeviceConfig(object): | |
| 11 | |
| 12 """Config file object used with remote device tests.""" | |
| 13 | |
| 14 def __init__(self, test_type, app, extras=None, | |
| 15 config_path='/tmp/remote_device_temp.config'): | |
| 16 self._config_path = config_path | |
| 17 self._test_type = test_type | |
| 18 self._extras = extras | |
| 19 self._app = app | |
| 20 | |
| 21 def __enter__(self): | |
| 22 self.GenerateTestConfig() | |
| 23 return self | |
| 24 | |
| 25 def __exit__(self, exc_type, exc_val, exc_tb): | |
| 26 os.remove(self._config_path) | |
| 27 | |
| 28 def GenerateTestConfig(self): | |
| 29 | |
| 30 """Uses test_type and extras dict to create config file.""" | |
| 31 | |
| 32 config_data = [] | |
| 33 config_data.append('[appurify]') | |
| 34 if self._test_type == 'gtest': | |
| 35 config_data.append('[robotium]') | |
|
jbudorick
2014/11/21 00:17:24
This should probably be configurable.
rnephew (Reviews Here)
2014/11/21 18:26:46
Added to do for this. Will do before landing CL. (
rnephew (Reviews Here)
2014/11/21 22:37:01
Done in the latest patch set. Still a lot of room
| |
| 36 config_data.append('runner=org.chromium.native_test.' | |
|
jbudorick
2014/11/21 00:17:24
This will need to be configurable.
rnephew (Reviews Here)
2014/11/21 18:26:47
Same.
| |
| 37 'ChromiumNativeTestInstrumentationTestRunner') | |
| 38 elif self._test_type == 'uiautomator': | |
| 39 config_data.append('[android_uiautomator]') | |
| 40 raise NotImplementedError | |
| 41 elif self._test_type == 'uirobot': | |
| 42 if self._app.endswith('.apk'): | |
|
jbudorick
2014/11/21 00:17:24
1. Don't add support for iOS yet.
2. When we do ad
rnephew (Reviews Here)
2014/11/21 18:26:47
Removed.
| |
| 43 config_data.append('[android_robot]') | |
| 44 elif self._app.endswith('.ipa'): | |
| 45 config_data.append('[ios_robot]') | |
| 46 else: | |
| 47 raise NotImplementedError | |
| 48 if self._extras: | |
| 49 for key in self._extras: | |
|
jbudorick
2014/11/21 00:17:24
config_data.extend('%s=%s' % (k, v) for k, v in se
rnephew (Reviews Here)
2014/11/21 18:26:47
Done.
| |
| 50 entry = key + '=' + self._extras[key] | |
| 51 config_data.append(entry) | |
| 52 with open(self._config_path, 'w') as config_file: | |
| 53 for line in config_data: | |
|
jbudorick
2014/11/21 00:17:24
config_file.write('%s\n' % line for line in config
rnephew (Reviews Here)
2014/11/21 18:26:46
That didn't work but I switched to using writeline
| |
| 54 config_file.write(line + '\n') | |
| 55 | |
| 56 @property | |
| 57 def path(self): | |
| 58 return self._config_path | |
| OLD | NEW |