Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 import tempfile | 12 import tempfile |
| 13 import time | 13 import time |
| 14 | 14 |
| 15 _SRC_DIR = os.path.abspath(os.path.join( | 15 _SRC_DIR = os.path.abspath(os.path.join( |
| 16 os.path.dirname(__file__), '..', '..', '..')) | 16 os.path.dirname(__file__), '..', '..', '..')) |
| 17 | 17 |
| 18 _CATAPULT_DIR = os.path.join(_SRC_DIR, 'third_party', 'catapult') | 18 _CATAPULT_DIR = os.path.join(_SRC_DIR, 'third_party', 'catapult') |
| 19 sys.path.append(os.path.join(_CATAPULT_DIR, 'devil')) | 19 sys.path.append(os.path.join(_CATAPULT_DIR, 'devil')) |
| 20 from devil.android import device_utils | 20 from devil.android import device_utils |
| 21 from devil.android import flag_changer | 21 from devil.android import flag_changer |
| 22 from devil.android import forwarder | 22 from devil.android import forwarder |
| 23 from devil.android.sdk import adb_wrapper | |
| 23 from devil.android.sdk import intent | 24 from devil.android.sdk import intent |
| 24 | 25 |
| 25 sys.path.append(os.path.join(_SRC_DIR, 'build', 'android')) | 26 sys.path.append(os.path.join(_SRC_DIR, 'build', 'android')) |
| 26 from pylib import constants | 27 from pylib import constants |
| 27 from video_recorder import video_recorder | 28 from video_recorder import video_recorder |
| 28 | 29 |
| 29 sys.path.append(os.path.join(_SRC_DIR, 'tools', 'perf')) | 30 sys.path.append(os.path.join(_SRC_DIR, 'tools', 'perf')) |
| 30 from chrome_telemetry_build import chromium_config | 31 from chrome_telemetry_build import chromium_config |
| 31 | 32 |
| 32 sys.path.append(chromium_config.GetTelemetryDir()) | 33 sys.path.append(chromium_config.GetTelemetryDir()) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 wpr_server_args.extend(['--should_generate_certs', | 209 wpr_server_args.extend(['--should_generate_certs', |
| 209 '--https_root_ca_cert_path=' + PathWorkaround(wpr_ca_cert_path)]) | 210 '--https_root_ca_cert_path=' + PathWorkaround(wpr_ca_cert_path)]) |
| 210 if out_log_path: | 211 if out_log_path: |
| 211 # --log_level debug to extract the served URLs requests from the log. | 212 # --log_level debug to extract the served URLs requests from the log. |
| 212 wpr_server_args.extend(['--log_level', 'debug', | 213 wpr_server_args.extend(['--log_level', 'debug', |
| 213 '--log_file', PathWorkaround(out_log_path)]) | 214 '--log_file', PathWorkaround(out_log_path)]) |
| 214 # Don't append to previously existing log. | 215 # Don't append to previously existing log. |
| 215 if os.path.exists(out_log_path): | 216 if os.path.exists(out_log_path): |
| 216 os.remove(out_log_path) | 217 os.remove(out_log_path) |
| 217 | 218 |
| 218 # Set up WPR server and device forwarder. | 219 #Set up WPR server and device forwarder. |
|
Benoit L
2017/03/02 09:43:08
nit: remove this from the diff.
mattcary
2017/03/02 09:55:16
oops, thanks
| |
| 219 server = wpr_server.ReplayServer(PathWorkaround(wpr_archive_path), | 220 server = wpr_server.ReplayServer(PathWorkaround(wpr_archive_path), |
| 220 '127.0.0.1', 0, 0, None, wpr_server_args) | 221 '127.0.0.1', 0, 0, None, wpr_server_args) |
| 221 http_port, https_port = server.StartServer()[:-1] | 222 http_port, https_port = server.StartServer()[:-1] |
| 222 | 223 |
| 223 logging.info('WPR server listening on HTTP=%s, HTTPS=%s (options=%s)' % ( | 224 logging.info('WPR server listening on HTTP=%s, HTTPS=%s (options=%s)' % ( |
| 224 http_port, https_port, wpr_server_args)) | 225 http_port, https_port, wpr_server_args)) |
| 225 try: | 226 try: |
| 226 yield http_port, https_port | 227 yield http_port, https_port |
| 227 finally: | 228 finally: |
| 228 server.StopServer() | 229 server.StopServer() |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 if wpr_archive_path == None: | 312 if wpr_archive_path == None: |
| 312 _VerifySilentWprHost(record, network_condition_name) | 313 _VerifySilentWprHost(record, network_condition_name) |
| 313 yield [] | 314 yield [] |
| 314 return | 315 return |
| 315 # Deploy certification authority to the device. | 316 # Deploy certification authority to the device. |
| 316 temp_certificate_dir = tempfile.mkdtemp() | 317 temp_certificate_dir = tempfile.mkdtemp() |
| 317 wpr_ca_cert_path = os.path.join(temp_certificate_dir, 'testca.pem') | 318 wpr_ca_cert_path = os.path.join(temp_certificate_dir, 'testca.pem') |
| 318 certutils.write_dummy_ca_cert(*certutils.generate_dummy_ca_cert(), | 319 certutils.write_dummy_ca_cert(*certutils.generate_dummy_ca_cert(), |
| 319 cert_path=wpr_ca_cert_path) | 320 cert_path=wpr_ca_cert_path) |
| 320 device_cert_util = adb_install_cert.AndroidCertInstaller( | 321 device_cert_util = adb_install_cert.AndroidCertInstaller( |
| 321 device.adb.GetDeviceSerial(), None, wpr_ca_cert_path) | 322 device.adb.GetDeviceSerial(), None, wpr_ca_cert_path, |
| 323 adb_wrapper.AdbWrapper.GetAdbPath()) | |
| 322 device_cert_util.install_cert(overwrite_cert=True) | 324 device_cert_util.install_cert(overwrite_cert=True) |
| 323 try: | 325 try: |
| 324 # Set up WPR server | 326 # Set up WPR server |
| 325 with _WprHost( | 327 with _WprHost( |
| 326 wpr_archive_path, | 328 wpr_archive_path, |
| 327 record=record, | 329 record=record, |
| 328 network_condition_name=network_condition_name, | 330 network_condition_name=network_condition_name, |
| 329 disable_script_injection=disable_script_injection, | 331 disable_script_injection=disable_script_injection, |
| 330 wpr_ca_cert_path=wpr_ca_cert_path, | 332 wpr_ca_cert_path=wpr_ca_cert_path, |
| 331 out_log_path=out_log_path) as (http_port, https_port): | 333 out_log_path=out_log_path) as (http_port, https_port): |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 # speed index measurement. | 425 # speed index measurement. |
| 424 connection.ExecuteJavaScript(""" | 426 connection.ExecuteJavaScript(""" |
| 425 (function() { | 427 (function() { |
| 426 requestAnimationFrame(function() { | 428 requestAnimationFrame(function() { |
| 427 var screen = window.__speedindex_screen; | 429 var screen = window.__speedindex_screen; |
| 428 screen.style.background = 'rgb(255, 255, 255)'; | 430 screen.style.background = 'rgb(255, 255, 255)'; |
| 429 }); | 431 }); |
| 430 })(); | 432 })(); |
| 431 """) | 433 """) |
| 432 yield | 434 yield |
| OLD | NEW |