| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2017 The Chromium Authors. All rights reserved. | 3 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Helper script to launch Chrome on device and WebPageReplay on host.""" | 7 """Helper script to launch Chrome on device and WebPageReplay on host.""" |
| 8 | 8 |
| 9 import logging | 9 import logging |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import sys | 12 import sys |
| 13 import time | 13 import time |
| 14 | 14 |
| 15 _SRC_PATH = os.path.abspath(os.path.join( | 15 _SRC_PATH = os.path.abspath(os.path.join( |
| 16 os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)) | 16 os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)) |
| 17 | 17 |
| 18 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil')) | 18 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil')) |
| 19 from devil.android import device_utils | 19 from devil.android import device_utils |
| 20 from devil.android import flag_changer |
| 20 from devil.android.constants import chrome | 21 from devil.android.constants import chrome |
| 21 from devil.android.perf import cache_control | 22 from devil.android.perf import cache_control |
| 22 from devil.android.sdk import intent | 23 from devil.android.sdk import intent |
| 23 | 24 |
| 24 sys.path.append(os.path.join(_SRC_PATH, 'build', 'android')) | 25 sys.path.append(os.path.join(_SRC_PATH, 'build', 'android')) |
| 25 import devil_chromium | 26 import devil_chromium |
| 26 | 27 |
| 27 import chrome_setup | 28 import chrome_setup |
| 28 import device_setup | 29 import device_setup |
| 29 | 30 |
| 30 | 31 |
| 31 def RunChrome(device, cold, chrome_args, package_info): | 32 def RunChrome(device, cold, chrome_args, package_info): |
| 32 """Runs Chrome on the device. | 33 """Runs Chrome on the device. |
| 33 | 34 |
| 34 Args: | 35 Args: |
| 35 device: (DeviceUtils) device to run the tests on. | 36 device: (DeviceUtils) device to run the tests on. |
| 36 cold: (bool) Whether caches should be dropped. | 37 cold: (bool) Whether caches should be dropped. |
| 37 chrome_args: ([str]) List of arguments to pass to Chrome. | 38 chrome_args: ([str]) List of arguments to pass to Chrome. |
| 38 package_info: (PackageInfo) Chrome package info. | 39 package_info: (PackageInfo) Chrome package info. |
| 39 """ | 40 """ |
| 40 if not device.HasRoot(): | 41 if not device.HasRoot(): |
| 41 device.EnableRoot() | 42 device.EnableRoot() |
| 42 | 43 |
| 43 cmdline_file = package_info.cmdline_file | 44 cmdline_file = package_info.cmdline_file |
| 44 package = package_info.package | 45 package = package_info.package |
| 45 with device_setup.FlagReplacer(device, cmdline_file, chrome_args): | 46 with flag_changer.CustomCommandLineFlags(device, cmdline_file, chrome_args): |
| 46 device.ForceStop(package) | 47 device.ForceStop(package) |
| 47 | 48 |
| 48 if cold: | 49 if cold: |
| 49 chrome_setup.ResetChromeLocalState(device, package) | 50 chrome_setup.ResetChromeLocalState(device, package) |
| 50 cache_control.CacheControl(device).DropRamCaches() | 51 cache_control.CacheControl(device).DropRamCaches() |
| 51 | 52 |
| 52 start_intent = intent.Intent(package=package, data='about:blank', | 53 start_intent = intent.Intent(package=package, data='about:blank', |
| 53 activity=package_info.activity) | 54 activity=package_info.activity) |
| 54 try: | 55 try: |
| 55 device.StartActivity(start_intent, blocking=True) | 56 device.StartActivity(start_intent, blocking=True) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 with device_setup.RemoteWprHost(device, args[0], options.record, | 117 with device_setup.RemoteWprHost(device, args[0], options.record, |
| 117 options.network_condition, | 118 options.network_condition, |
| 118 out_log_path=options.wpr_log) as wpr_attr: | 119 out_log_path=options.wpr_log) as wpr_attr: |
| 119 RunChrome(device, options.cold, | 120 RunChrome(device, options.cold, |
| 120 chrome_setup.CHROME_ARGS + wpr_attr.chrome_args, | 121 chrome_setup.CHROME_ARGS + wpr_attr.chrome_args, |
| 121 chrome.PACKAGE_INFO[options.chrome_package_name]) | 122 chrome.PACKAGE_INFO[options.chrome_package_name]) |
| 122 | 123 |
| 123 | 124 |
| 124 if __name__ == '__main__': | 125 if __name__ == '__main__': |
| 125 main() | 126 main() |
| OLD | NEW |