| 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 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', | 26 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', |
| 27 'devil') | 27 'devil') |
| 28 DEVIL_CHROMIUM_PATH = os.path.join(SRC_PATH, 'build', 'android') |
| 29 |
| 30 if DEVIL_CHROMIUM_PATH not in sys.path: |
| 31 sys.path.append(DEVIL_CHROMIUM_PATH) |
| 32 |
| 33 import devil_chromium |
| 28 | 34 |
| 29 if DEVIL_PATH not in sys.path: | 35 if DEVIL_PATH not in sys.path: |
| 30 sys.path.append(DEVIL_PATH) | 36 sys.path.append(DEVIL_PATH) |
| 31 | 37 |
| 32 from devil.android import device_blacklist | 38 from devil.android import device_blacklist |
| 33 from devil.android import device_utils | 39 from devil.android import device_utils |
| 34 from devil.android import forwarder | 40 from devil.android import forwarder |
| 35 from devil.android.sdk import intent | 41 from devil.android.sdk import intent |
| 36 from devil.android.sdk import version_codes | 42 from devil.android.sdk import version_codes |
| 37 from devil.utils import cmd_helper | 43 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) | 272 os.remove(json_file_path) |
| 267 | 273 |
| 268 | 274 |
| 269 def main(): | 275 def main(): |
| 270 parser = argparse.ArgumentParser() | 276 parser = argparse.ArgumentParser() |
| 271 parser.add_argument('-l', | 277 parser.add_argument('-l', |
| 272 '--output-linux-directory', | 278 '--output-linux-directory', |
| 273 required=True, | 279 required=True, |
| 274 help='Path to the root linux build directory.' | 280 help='Path to the root linux build directory.' |
| 275 ' Example: "out-linux/Debug"') | 281 ' Example: "out-linux/Debug"') |
| 282 parser.add_argument('--adb-path', |
| 283 type=os.path.abspath, |
| 284 help='Path to the adb binary.') |
| 276 subparsers = parser.add_subparsers(dest="subparser_name") | 285 subparsers = parser.add_subparsers(dest="subparser_name") |
| 277 | 286 |
| 278 start_parser = subparsers.add_parser('start') | 287 start_parser = subparsers.add_parser('start') |
| 279 start_parser.set_defaults(func=_Start) | 288 start_parser.set_defaults(func=_Start) |
| 280 AddStartArguments(start_parser) | 289 AddStartArguments(start_parser) |
| 281 | 290 |
| 282 run_parser = subparsers.add_parser('run') | 291 run_parser = subparsers.add_parser('run') |
| 283 run_parser.set_defaults(func=_Run) | 292 run_parser.set_defaults(func=_Run) |
| 284 AddStartArguments(run_parser) | 293 AddStartArguments(run_parser) |
| 285 | 294 |
| 286 load_parser = subparsers.add_parser('load') | 295 load_parser = subparsers.add_parser('load') |
| 287 load_parser.set_defaults(func=_Load) | 296 load_parser.set_defaults(func=_Load) |
| 288 load_parser.add_argument('-p', | 297 load_parser.add_argument('-p', |
| 289 '--apk-path', | 298 '--apk-path', |
| 290 required=True, | 299 required=True, |
| 291 help='The path to the APK to install. ' | 300 help='The path to the APK to install. ' |
| 292 'Including the name of the apk containing ' | 301 'Including the name of the apk containing ' |
| 293 'the application (with the .apk extension).') | 302 'the application (with the .apk extension).') |
| 294 load_parser.add_argument('-u', | 303 load_parser.add_argument('-u', |
| 295 '--optional-url', | 304 '--optional-url', |
| 296 help='URL to navigate to.') | 305 help='URL to navigate to.') |
| 297 | 306 |
| 298 stop_parser = subparsers.add_parser('stop') | 307 stop_parser = subparsers.add_parser('stop') |
| 299 stop_parser.set_defaults(func=_Stop) | 308 stop_parser.set_defaults(func=_Stop) |
| 300 | 309 |
| 301 args = parser.parse_args() | 310 args = parser.parse_args() |
| 311 devil_chromium.Initialize(adb_path=args.adb_path) |
| 302 | 312 |
| 303 json_file_path = os.path.join(SRC_PATH, args.output_linux_directory, | 313 json_file_path = os.path.join(SRC_PATH, args.output_linux_directory, |
| 304 ARGS_JSON_FILE) | 314 ARGS_JSON_FILE) |
| 305 blacklist_file = '' | 315 blacklist_file = '' |
| 306 serial = '' | 316 serial = '' |
| 307 if args.subparser_name == 'start' or args.subparser_name == 'run': | 317 if args.subparser_name == 'start' or args.subparser_name == 'run': |
| 308 blacklist_file = args.blacklist_file | 318 blacklist_file = args.blacklist_file |
| 309 serial = args.device | 319 serial = args.device |
| 310 else: | 320 else: |
| 311 if not _IsNonEmptyFile(json_file_path): | 321 if not _IsNonEmptyFile(json_file_path): |
| (...skipping 10 matching lines...) Expand all Loading... |
| 322 if blacklist_file | 332 if blacklist_file |
| 323 else None) | 333 else None) |
| 324 device = device_utils.DeviceUtils.HealthyDevices( | 334 device = device_utils.DeviceUtils.HealthyDevices( |
| 325 blacklist=blacklist, device_arg=serial)[0] | 335 blacklist=blacklist, device_arg=serial)[0] |
| 326 | 336 |
| 327 args.func(args, json_file_path, device) | 337 args.func(args, json_file_path, device) |
| 328 | 338 |
| 329 | 339 |
| 330 if __name__ == '__main__': | 340 if __name__ == '__main__': |
| 331 main() | 341 main() |
| OLD | NEW |