| 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. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', | 27 DEVIL_PATH = os.path.join(SRC_PATH, 'third_party', 'catapult', |
| 28 'devil') | 28 'devil') |
| 29 | 29 |
| 30 if DEVIL_PATH not in sys.path: | 30 if DEVIL_PATH not in sys.path: |
| 31 sys.path.append(DEVIL_PATH) | 31 sys.path.append(DEVIL_PATH) |
| 32 | 32 |
| 33 from devil.android import device_blacklist | 33 from devil.android import device_blacklist |
| 34 from devil.android import device_utils | 34 from devil.android import device_utils |
| 35 from devil.android import forwarder | 35 from devil.android import forwarder |
| 36 from devil.android.sdk import intent | 36 from devil.android.sdk import intent |
| 37 from devil.android.sdk import version_codes |
| 37 from devil.utils import cmd_helper | 38 from devil.utils import cmd_helper |
| 38 | 39 |
| 39 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', | 40 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', |
| 40 'org.chromium.blimp', | 41 'org.chromium.blimp', |
| 41 'blimp_client_token') | 42 'blimp_client_token') |
| 42 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', | 43 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', |
| 43 'test_client_token') | 44 'test_client_token') |
| 44 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') | 45 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') |
| 45 ARGS_JSON_FILE = 'blimp_script_args.json' | 46 ARGS_JSON_FILE = 'blimp_script_args.json' |
| 46 | 47 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 optional_url: (str) URL to navigate to. | 69 optional_url: (str) URL to navigate to. |
| 69 """ | 70 """ |
| 70 run_client_intent = intent.Intent( | 71 run_client_intent = intent.Intent( |
| 71 action='android.intent.action.VIEW', | 72 action='android.intent.action.VIEW', |
| 72 package='org.chromium.blimp', | 73 package='org.chromium.blimp', |
| 73 activity='org.chromium.blimp.BlimpRendererActivity', | 74 activity='org.chromium.blimp.BlimpRendererActivity', |
| 74 data=optional_url) | 75 data=optional_url) |
| 75 device.StartActivity(run_client_intent, blocking=True) | 76 device.StartActivity(run_client_intent, blocking=True) |
| 76 | 77 |
| 77 | 78 |
| 78 def RunEngine(output_linux_directory, token_file_path): | 79 def RunEngine(output_linux_directory, token_file_path, device): |
| 79 """Start running engine | 80 """Start running engine |
| 80 | 81 |
| 81 Args: | 82 Args: |
| 82 output_linux_directory: (str) Path to the root linux build directory. | 83 output_linux_directory: (str) Path to the root linux build directory. |
| 83 token_file_path: (str) Path to the client auth token file. | 84 token_file_path: (str) Path to the client auth token file. |
| 84 | 85 |
| 85 Returns: | 86 Returns: |
| 86 port: (str) Engine port number generated by engine session. | 87 port: (str) Engine port number generated by engine session. |
| 87 """ | 88 """ |
| 88 port = '0' | 89 port = '0' |
| 89 blimp_engine_app = os.path.join(output_linux_directory, | 90 blimp_engine_app = os.path.join(output_linux_directory, |
| 90 'blimp_engine_app') | 91 'blimp_engine_app') |
| 92 |
| 93 sub_dir = "marshmallow" |
| 94 if device.build_version_sdk == version_codes.KITKAT: |
| 95 sub_dir = "kitkat" |
| 91 blimp_fonts_path = os.path.join(output_linux_directory, 'gen', | 96 blimp_fonts_path = os.path.join(output_linux_directory, 'gen', |
| 92 'third_party', 'blimp_fonts') | 97 'third_party', 'blimp_fonts', |
| 98 'font_bundle', sub_dir) |
| 99 |
| 93 run_engine_cmd = [ | 100 run_engine_cmd = [ |
| 94 blimp_engine_app + | 101 blimp_engine_app + |
| 95 ' --android-fonts-path=' + blimp_fonts_path + | 102 ' --android-fonts-path=' + blimp_fonts_path + |
| 96 ' --blimp-client-token-path=' + token_file_path + | 103 ' --blimp-client-token-path=' + token_file_path + |
| 97 ' --enable-logging=stderr' + | 104 ' --enable-logging=stderr' + |
| 98 ' -v=0' + | 105 ' -v=0' + |
| 99 ' --vmodule="blimp*=1"'] | 106 ' --vmodule="blimp*=1"'] |
| 100 p = subprocess.Popen(run_engine_cmd, shell=True, | 107 p = subprocess.Popen(run_engine_cmd, shell=True, |
| 101 stdout=subprocess.PIPE, | 108 stdout=subprocess.PIPE, |
| 102 stderr=subprocess.STDOUT) | 109 stderr=subprocess.STDOUT) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 json_args = argparse.Namespace() | 170 json_args = argparse.Namespace() |
| 164 for k in args.__dict__: | 171 for k in args.__dict__: |
| 165 if not k == "func": | 172 if not k == "func": |
| 166 setattr(json_args, k, args.__dict__[k]) | 173 setattr(json_args, k, args.__dict__[k]) |
| 167 json_object = {'args': json_args} | 174 json_object = {'args': json_args} |
| 168 device.EnableRoot() | 175 device.EnableRoot() |
| 169 host_device_tuples = [(_TOKEN_FILE_PATH, _CLIENT_TOKEN_PATH)] | 176 host_device_tuples = [(_TOKEN_FILE_PATH, _CLIENT_TOKEN_PATH)] |
| 170 device.PushChangedFiles(host_device_tuples) | 177 device.PushChangedFiles(host_device_tuples) |
| 171 | 178 |
| 172 port_number, engine_process = RunEngine( | 179 port_number, engine_process = RunEngine( |
| 173 args.output_linux_directory, _TOKEN_FILE_PATH) | 180 args.output_linux_directory, _TOKEN_FILE_PATH, device) |
| 174 json_object['port_number'] = port_number | 181 json_object['port_number'] = port_number |
| 175 json_object['pid'] = engine_process.pid | 182 json_object['pid'] = engine_process.pid |
| 176 logging.info("Engine port number: %s", port_number) | 183 logging.info("Engine port number: %s", port_number) |
| 177 logging.info("Engine running PID: %d", engine_process.pid) | 184 logging.info("Engine running PID: %d", engine_process.pid) |
| 178 | 185 |
| 179 if engine_process.poll() is None: | 186 if engine_process.poll() is None: |
| 180 try: | 187 try: |
| 181 port_pairs = [(port_number, port_number)] | 188 port_pairs = [(port_number, port_number)] |
| 182 forwarder.Forwarder.Map(port_pairs, device) | 189 forwarder.Forwarder.Map(port_pairs, device) |
| 183 SetCommandFlag(device, args.engine_ip, port_number) | 190 SetCommandFlag(device, args.engine_ip, port_number) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 else None) | 316 else None) |
| 310 device = device_utils.DeviceUtils.HealthyDevices( | 317 device = device_utils.DeviceUtils.HealthyDevices( |
| 311 blacklist=blacklist, device_arg=serial)[0] | 318 blacklist=blacklist, device_arg=serial)[0] |
| 312 | 319 |
| 313 args.func(args, json_file_path, device) | 320 args.func(args, json_file_path, device) |
| 314 | 321 |
| 315 | 322 |
| 316 if __name__ == '__main__': | 323 if __name__ == '__main__': |
| 317 main() | 324 main() |
| 318 | 325 |
| OLD | NEW |