| 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 15 matching lines...) Expand all Loading... |
| 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 | 28 |
| 29 if DEVIL_PATH not in sys.path: | 29 if DEVIL_PATH not in sys.path: |
| 30 sys.path.append(DEVIL_PATH) | 30 sys.path.append(DEVIL_PATH) |
| 31 | 31 |
| 32 from devil.android import device_blacklist | 32 from devil.android import device_blacklist |
| 33 from devil.android import device_utils | 33 from devil.android import device_utils |
| 34 from devil.android import forwarder | 34 from devil.android import forwarder |
| 35 from devil.android.sdk import intent | 35 from devil.android.sdk import intent |
| 36 from devil.android.sdk import version_codes |
| 36 from devil.utils import cmd_helper | 37 from devil.utils import cmd_helper |
| 37 | 38 |
| 38 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', | 39 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', |
| 39 'org.chromium.blimp', | 40 'org.chromium.blimp', |
| 40 'blimp_client_token') | 41 'blimp_client_token') |
| 41 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', | 42 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', |
| 42 'test_client_token') | 43 'test_client_token') |
| 43 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') | 44 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') |
| 44 ARGS_JSON_FILE = 'blimp_script_args.json' | 45 ARGS_JSON_FILE = 'blimp_script_args.json' |
| 45 | 46 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 optional_url: (str) URL to navigate to. | 68 optional_url: (str) URL to navigate to. |
| 68 """ | 69 """ |
| 69 run_client_intent = intent.Intent( | 70 run_client_intent = intent.Intent( |
| 70 action='android.intent.action.VIEW', | 71 action='android.intent.action.VIEW', |
| 71 package='org.chromium.blimp', | 72 package='org.chromium.blimp', |
| 72 activity='org.chromium.blimp.BlimpRendererActivity', | 73 activity='org.chromium.blimp.BlimpRendererActivity', |
| 73 data=optional_url) | 74 data=optional_url) |
| 74 device.StartActivity(run_client_intent, blocking=True) | 75 device.StartActivity(run_client_intent, blocking=True) |
| 75 | 76 |
| 76 | 77 |
| 77 def RunEngine(output_linux_directory, token_file_path): | 78 def RunEngine(output_linux_directory, token_file_path, device): |
| 78 """Start running engine | 79 """Start running engine |
| 79 | 80 |
| 80 Args: | 81 Args: |
| 81 output_linux_directory: (str) Path to the root linux build directory. | 82 output_linux_directory: (str) Path to the root linux build directory. |
| 82 token_file_path: (str) Path to the client auth token file. | 83 token_file_path: (str) Path to the client auth token file. |
| 83 | 84 |
| 84 Returns: | 85 Returns: |
| 85 port: (str) Engine port number generated by engine session. | 86 port: (str) Engine port number generated by engine session. |
| 86 """ | 87 """ |
| 87 port = '0' | 88 port = '0' |
| 88 blimp_engine_app = os.path.join(output_linux_directory, | 89 blimp_engine_app = os.path.join(output_linux_directory, |
| 89 'blimp_engine_app') | 90 'blimp_engine_app') |
| 91 |
| 92 sub_dir = "marshmallow" |
| 93 if device.build_version_sdk == version_codes.KITKAT: |
| 94 sub_dir = "kitkat" |
| 90 blimp_fonts_path = os.path.join(output_linux_directory, 'gen', | 95 blimp_fonts_path = os.path.join(output_linux_directory, 'gen', |
| 91 'third_party', 'blimp_fonts') | 96 'third_party', 'blimp_fonts', |
| 97 'font_bundle', sub_dir) |
| 98 |
| 92 run_engine_cmd = [ | 99 run_engine_cmd = [ |
| 93 blimp_engine_app + | 100 blimp_engine_app + |
| 94 ' --android-fonts-path=' + blimp_fonts_path + | 101 ' --android-fonts-path=' + blimp_fonts_path + |
| 95 ' --blimp-client-token-path=' + token_file_path + | 102 ' --blimp-client-token-path=' + token_file_path + |
| 96 ' --enable-logging=stderr' + | 103 ' --enable-logging=stderr' + |
| 97 ' -v=0' + | 104 ' -v=0' + |
| 98 ' --vmodule="blimp*=1"'] | 105 ' --vmodule="blimp*=1"'] |
| 99 p = subprocess.Popen(run_engine_cmd, shell=True, | 106 p = subprocess.Popen(run_engine_cmd, shell=True, |
| 100 stdout=subprocess.PIPE, | 107 stdout=subprocess.PIPE, |
| 101 stderr=subprocess.STDOUT) | 108 stderr=subprocess.STDOUT) |
| (...skipping 61 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 not None: | 186 if engine_process.poll() is not None: |
| 180 logging.error('Engine failed to start. Return code: %d', | 187 logging.error('Engine failed to start. Return code: %d', |
| 181 engine_process.poll()) | 188 engine_process.poll()) |
| 182 else: | 189 else: |
| 183 try: | 190 try: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 else None) | 321 else None) |
| 315 device = device_utils.DeviceUtils.HealthyDevices( | 322 device = device_utils.DeviceUtils.HealthyDevices( |
| 316 blacklist=blacklist, device_arg=serial)[0] | 323 blacklist=blacklist, device_arg=serial)[0] |
| 317 | 324 |
| 318 args.func(args, json_file_path, device) | 325 args.func(args, json_file_path, device) |
| 319 | 326 |
| 320 | 327 |
| 321 if __name__ == '__main__': | 328 if __name__ == '__main__': |
| 322 main() | 329 main() |
| 323 | 330 |
| OLD | NEW |