OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Blimp Client + Engine integration test system | 6 """Blimp Client + Engine integration test system |
7 | 7 |
8 Set up Client and Engine | 8 Set up Client and Engine |
9 Set up Forward to connect machine host with client device. | 9 Set up Forward to connect machine host with client device. |
10 Start Engine and run blimp on Android Client. | 10 Start Engine and run blimp on Android Client. |
11 """ | 11 """ |
12 | 12 |
13 import argparse | 13 import argparse |
14 import json | 14 import json |
15 import logging | 15 import logging |
16 import posixpath | 16 import posixpath |
17 import os | 17 import os |
18 import re | 18 import re |
19 import signal | 19 import signal |
20 import subprocess | 20 import subprocess |
21 import sys | 21 import sys |
22 | 22 |
23 SRC_PATH = os.path.abspath( | 23 SRC_PATH = os.path.abspath( |
24 os.path.join(os.path.dirname(__file__), '..', '..')) | 24 os.path.join(os.path.dirname(__file__), '..', '..')) |
25 | 25 |
26 ADB_PATH = os.path.join(SRC_PATH, 'third_party', 'android_tools', | |
jbudorick
2016/11/15 03:15:13
nit: remove this, per below.
shenghuazhang
2016/11/15 03:59:17
Done.
| |
27 'sdk', 'platform-tools', 'adb') | |
26 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', | 28 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', |
27 'devil') | 29 'devil') |
30 DEVIL_CHROMIUM_PATH = os.path.join(SRC_PATH, 'build', 'android') | |
31 | |
32 if DEVIL_CHROMIUM_PATH not in sys.path: | |
33 sys.path.append(DEVIL_CHROMIUM_PATH) | |
34 | |
35 import devil_chromium | |
28 | 36 |
29 if DEVIL_PATH not in sys.path: | 37 if DEVIL_PATH not in sys.path: |
30 sys.path.append(DEVIL_PATH) | 38 sys.path.append(DEVIL_PATH) |
31 | 39 |
32 from devil.android import device_blacklist | 40 from devil.android import device_blacklist |
33 from devil.android import device_utils | 41 from devil.android import device_utils |
34 from devil.android import forwarder | 42 from devil.android import forwarder |
35 from devil.android.sdk import intent | 43 from devil.android.sdk import intent |
36 from devil.android.sdk import version_codes | 44 from devil.android.sdk import version_codes |
37 from devil.utils import cmd_helper | 45 from devil.utils import cmd_helper |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 os.remove(json_file_path) | 274 os.remove(json_file_path) |
267 | 275 |
268 | 276 |
269 def main(): | 277 def main(): |
270 parser = argparse.ArgumentParser() | 278 parser = argparse.ArgumentParser() |
271 parser.add_argument('-l', | 279 parser.add_argument('-l', |
272 '--output-linux-directory', | 280 '--output-linux-directory', |
273 required=True, | 281 required=True, |
274 help='Path to the root linux build directory.' | 282 help='Path to the root linux build directory.' |
275 ' Example: "out-linux/Debug"') | 283 ' Example: "out-linux/Debug"') |
284 parser.add_argument('--adb-path', | |
285 default=ADB_PATH, | |
jbudorick
2016/11/15 03:15:13
nit: you don't need to set this as the default. de
shenghuazhang
2016/11/15 03:59:17
Done.
| |
286 type=os.path.abspath, | |
287 help='Path to the adb binary.') | |
276 subparsers = parser.add_subparsers(dest="subparser_name") | 288 subparsers = parser.add_subparsers(dest="subparser_name") |
277 | 289 |
278 start_parser = subparsers.add_parser('start') | 290 start_parser = subparsers.add_parser('start') |
279 start_parser.set_defaults(func=_Start) | 291 start_parser.set_defaults(func=_Start) |
280 AddStartArguments(start_parser) | 292 AddStartArguments(start_parser) |
281 | 293 |
282 run_parser = subparsers.add_parser('run') | 294 run_parser = subparsers.add_parser('run') |
283 run_parser.set_defaults(func=_Run) | 295 run_parser.set_defaults(func=_Run) |
284 AddStartArguments(run_parser) | 296 AddStartArguments(run_parser) |
285 | 297 |
286 load_parser = subparsers.add_parser('load') | 298 load_parser = subparsers.add_parser('load') |
287 load_parser.set_defaults(func=_Load) | 299 load_parser.set_defaults(func=_Load) |
288 load_parser.add_argument('-p', | 300 load_parser.add_argument('-p', |
289 '--apk-path', | 301 '--apk-path', |
290 required=True, | 302 required=True, |
291 help='The path to the APK to install. ' | 303 help='The path to the APK to install. ' |
292 'Including the name of the apk containing ' | 304 'Including the name of the apk containing ' |
293 'the application (with the .apk extension).') | 305 'the application (with the .apk extension).') |
294 load_parser.add_argument('-u', | 306 load_parser.add_argument('-u', |
295 '--optional-url', | 307 '--optional-url', |
296 help='URL to navigate to.') | 308 help='URL to navigate to.') |
297 | 309 |
298 stop_parser = subparsers.add_parser('stop') | 310 stop_parser = subparsers.add_parser('stop') |
299 stop_parser.set_defaults(func=_Stop) | 311 stop_parser.set_defaults(func=_Stop) |
300 | 312 |
301 args = parser.parse_args() | 313 args = parser.parse_args() |
314 devil_chromium.Initialize(adb_path=args.adb_path) | |
302 | 315 |
303 json_file_path = os.path.join(SRC_PATH, args.output_linux_directory, | 316 json_file_path = os.path.join(SRC_PATH, args.output_linux_directory, |
304 ARGS_JSON_FILE) | 317 ARGS_JSON_FILE) |
305 blacklist_file = '' | 318 blacklist_file = '' |
306 serial = '' | 319 serial = '' |
307 if args.subparser_name == 'start' or args.subparser_name == 'run': | 320 if args.subparser_name == 'start' or args.subparser_name == 'run': |
308 blacklist_file = args.blacklist_file | 321 blacklist_file = args.blacklist_file |
309 serial = args.device | 322 serial = args.device |
310 else: | 323 else: |
311 if not _IsNonEmptyFile(json_file_path): | 324 if not _IsNonEmptyFile(json_file_path): |
(...skipping 10 matching lines...) Expand all Loading... | |
322 if blacklist_file | 335 if blacklist_file |
323 else None) | 336 else None) |
324 device = device_utils.DeviceUtils.HealthyDevices( | 337 device = device_utils.DeviceUtils.HealthyDevices( |
325 blacklist=blacklist, device_arg=serial)[0] | 338 blacklist=blacklist, device_arg=serial)[0] |
326 | 339 |
327 args.func(args, json_file_path, device) | 340 args.func(args, json_file_path, device) |
328 | 341 |
329 | 342 |
330 if __name__ == '__main__': | 343 if __name__ == '__main__': |
331 main() | 344 main() |
OLD | NEW |