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 19 matching lines...) Expand all Loading... |
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.android.sdk import version_codes |
37 from devil.utils import cmd_helper | 37 from devil.utils import cmd_helper |
38 | 38 |
39 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', | 39 _CLIENT_TOKEN_PATH = posixpath.join('/', 'data', 'data', |
40 'org.chromium.blimp', | 40 'org.chromium.chrome', |
41 'blimp_client_token') | 41 'blimp_client_token') |
42 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', | 42 _TOKEN_FILE_PATH = os.path.join(SRC_PATH, 'blimp', 'test', 'data', |
43 'test_client_token') | 43 'test_client_token') |
44 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') | 44 PORT_PATTERN = re.compile(r'.*Engine port #: (\d+)') |
45 ARGS_JSON_FILE = 'blimp_script_args.json' | 45 ARGS_JSON_FILE = 'blimp_script_args.json' |
46 | 46 |
47 def AddStartArguments(parser): | 47 def AddStartArguments(parser): |
48 parser.add_argument('-d', | 48 parser.add_argument('-d', |
49 '--device', | 49 '--device', |
50 help='Serial number of device we should use.') | 50 help='Serial number of device we should use.') |
(...skipping 11 matching lines...) Expand all Loading... |
62 | 62 |
63 def RunClient(device, optional_url): | 63 def RunClient(device, optional_url): |
64 """Run Blimp client. | 64 """Run Blimp client. |
65 | 65 |
66 Args: | 66 Args: |
67 device: (DeviceUtils) device to run the tests on. | 67 device: (DeviceUtils) device to run the tests on. |
68 optional_url: (str) URL to navigate to. | 68 optional_url: (str) URL to navigate to. |
69 """ | 69 """ |
70 run_client_intent = intent.Intent( | 70 run_client_intent = intent.Intent( |
71 action='android.intent.action.VIEW', | 71 action='android.intent.action.VIEW', |
72 package='org.chromium.blimp', | 72 package='org.chromium.chrome', |
73 activity='org.chromium.blimp.BlimpRendererActivity', | 73 activity='com.google.android.apps.chrome.Main', |
74 data=optional_url) | 74 data=optional_url) |
75 device.StartActivity(run_client_intent, blocking=True) | 75 device.StartActivity(run_client_intent, blocking=True) |
76 | 76 |
77 | 77 |
78 def RunEngine(output_linux_directory, token_file_path, device): | 78 def RunEngine(output_linux_directory, token_file_path, device): |
79 """Start running engine | 79 """Start running engine |
80 | 80 |
81 Args: | 81 Args: |
82 output_linux_directory: (str) Path to the root linux build directory. | 82 output_linux_directory: (str) Path to the root linux build directory. |
83 token_file_path: (str) Path to the client auth token file. | 83 token_file_path: (str) Path to the client auth token file. |
(...skipping 29 matching lines...) Expand all Loading... |
113 l = line.rstrip() | 113 l = line.rstrip() |
114 match = re.match(PORT_PATTERN, l) | 114 match = re.match(PORT_PATTERN, l) |
115 if match: | 115 if match: |
116 port = match.group(1) | 116 port = match.group(1) |
117 break | 117 break |
118 | 118 |
119 return port, p | 119 return port, p |
120 | 120 |
121 | 121 |
122 def SetCommandFlag(device, engine_ip, engine_port): | 122 def SetCommandFlag(device, engine_ip, engine_port): |
123 """Set up adb Blimp command line flags | 123 """Set up adb Chrome command line flags |
124 | 124 |
125 Args: | 125 Args: |
126 device: (str) Serial number of device we should use. | 126 device: (str) Serial number of device we should use. |
127 engine_ip: (str) Blimp engine IP address. | 127 engine_ip: (str) Blimp engine IP address. |
128 engine_port: (str) Port on the engine. | 128 engine_port: (str) Port on the engine. |
129 """ | 129 """ |
130 cmd_helper.GetCmdStatusAndOutput([ | 130 cmd_helper.GetCmdStatusAndOutput([ |
131 os.path.join(SRC_PATH, 'build', 'android', | 131 os.path.join(SRC_PATH, 'build', 'android', |
132 'adb_blimp_command_line'), | 132 'adb_chrome_command_line'), |
133 '--device=' + str(device), | 133 '--device=' + str(device), |
| 134 '--enable-blimp', |
134 '--engine-ip=' + engine_ip, | 135 '--engine-ip=' + engine_ip, |
135 '--engine-port=' + engine_port, | 136 '--engine-port=' + engine_port, |
136 '--engine-transport=tcp', | 137 '--engine-transport=tcp', |
137 '-v=0', | 138 '-v=0', |
138 '--vmodule=*blimp*=1', | 139 '--vmodule=*blimp*=1', |
139 '--blimp-client-token-path=' + _CLIENT_TOKEN_PATH]) | 140 '--blimp-client-token-path=' + _CLIENT_TOKEN_PATH]) |
140 | 141 |
141 | 142 |
142 def _JsonEncodeDefault(obj): | 143 def _JsonEncodeDefault(obj): |
143 if isinstance(obj, argparse.Namespace): | 144 if isinstance(obj, argparse.Namespace): |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 230 |
230 Args: | 231 Args: |
231 args: parsed command line arguments. | 232 args: parsed command line arguments. |
232 json_file_path: json file path which keeps the script variables. | 233 json_file_path: json file path which keeps the script variables. |
233 device: (DeviceUtils) device to run the tests on. | 234 device: (DeviceUtils) device to run the tests on. |
234 """ | 235 """ |
235 device.Install(os.path.join(SRC_PATH, args.apk_path), | 236 device.Install(os.path.join(SRC_PATH, args.apk_path), |
236 reinstall=True) | 237 reinstall=True) |
237 run_client_intent = intent.Intent( | 238 run_client_intent = intent.Intent( |
238 action='android.intent.action.VIEW', | 239 action='android.intent.action.VIEW', |
239 package='org.chromium.blimp', | 240 package='org.chromium.chrome', |
240 activity='org.chromium.blimp.BlimpRendererActivity', | 241 activity='com.google.android.apps.chrome.Main', |
241 data=args.optional_url) | 242 data=args.optional_url) |
242 device.StartActivity(run_client_intent, blocking=True) | 243 device.StartActivity(run_client_intent, blocking=True) |
243 | 244 |
244 | 245 |
245 def _Stop(args, json_file_path, device): # pylint: disable=unused-argument | 246 def _Stop(args, json_file_path, device): # pylint: disable=unused-argument |
246 """Stop engine and forwarder | 247 """Stop engine and forwarder |
247 | 248 |
248 Args: | 249 Args: |
249 args: (unused) parsed command line arguments. | 250 args: (unused) parsed command line arguments. |
250 json_file_path: json file path which keeps the script variables. | 251 json_file_path: json file path which keeps the script variables. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if blacklist_file | 322 if blacklist_file |
322 else None) | 323 else None) |
323 device = device_utils.DeviceUtils.HealthyDevices( | 324 device = device_utils.DeviceUtils.HealthyDevices( |
324 blacklist=blacklist, device_arg=serial)[0] | 325 blacklist=blacklist, device_arg=serial)[0] |
325 | 326 |
326 args.func(args, json_file_path, device) | 327 args.func(args, json_file_path, device) |
327 | 328 |
328 | 329 |
329 if __name__ == '__main__': | 330 if __name__ == '__main__': |
330 main() | 331 main() |
331 | |
OLD | NEW |