| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 # | |
| 6 # The script follows mojo/services/html_viewer/view_url.py and modified it for | |
| 7 # test the mojo media renderer. The page will be rendered in a headless mode. | |
| 8 # | |
| 9 # TODO(xhwang): Explore the possibility of running this with the Kiosk window | |
| 10 # manager. See http://crbug.com/467176 | |
| 11 | 5 |
| 12 import argparse | 6 import argparse |
| 13 import os | 7 import os |
| 14 import subprocess | 8 import subprocess |
| 15 import sys | 9 import sys |
| 16 | 10 |
| 17 root_path = os.path.realpath( | 11 root_path = os.path.realpath( |
| 18 os.path.join( | 12 os.path.join( |
| 19 os.path.dirname( | 13 os.path.dirname( |
| 20 os.path.realpath(__file__)), | 14 os.path.realpath(__file__)), |
| 21 os.pardir, | 15 os.pardir, |
| 22 os.pardir, | 16 os.pardir, |
| 23 os.pardir)) | 17 os.pardir)) |
| 24 | 18 |
| 25 def _BuildShellCommand(args): | 19 def _BuildShellCommand(args): |
| 26 sdk_version = subprocess.check_output(["cat", | 20 sdk_version = subprocess.check_output(["cat", |
| 27 "third_party/mojo/src/mojo/public/VERSION"], cwd=root_path) | 21 "third_party/mojo/src/mojo/public/VERSION"], cwd=root_path) |
| 28 build_dir = os.path.join(root_path, args.build_dir) | 22 build_dir = os.path.join(root_path, args.build_dir) |
| 29 | 23 |
| 30 shell_command = [os.path.join(build_dir, "mojo_shell")] | 24 shell_command = [os.path.join(build_dir, "mojo_shell")] |
| 31 | 25 |
| 32 options = [] | 26 options = [] |
| 33 | |
| 34 options.append( | 27 options.append( |
| 35 "--origin=https://storage.googleapis.com/mojo/services/linux-x64/%s" % | 28 "--origin=https://storage.googleapis.com/mojo/services/linux-x64/%s" % |
| 36 sdk_version) | 29 sdk_version) |
| 37 options.append("--url-mappings=mojo:html_viewer=file://%s/html_viewer.mojo," | 30 options.append("--url-mappings=mojo:html_viewer=file://%s/html_viewer.mojo" % |
| 38 "mojo:media=file://%s/media.mojo" % (build_dir, build_dir)) | 31 build_dir) |
| 32 options.append('--args-for=mojo:kiosk_wm %s' % args.url) |
| 39 | 33 |
| 40 args_for_html_viewer = "--enable-mojo-media-renderer --is-headless " | 34 app_to_run = "mojo:kiosk_wm" |
| 41 if args.verbose: | |
| 42 args_for_html_viewer += \ | |
| 43 "--vmodule=pipeline*=3,*renderer_impl*=3,*mojo_demuxer*=3" | |
| 44 options.append("--args-for=mojo:html_viewer %s" % args_for_html_viewer) | |
| 45 | 35 |
| 46 if args.verbose: | 36 return shell_command + options + [app_to_run] |
| 47 args_for_media = "--vmodule=mojo*service=3" | |
| 48 options.append("--args-for=mojo:media %s" % args_for_media) | |
| 49 | |
| 50 full_command = shell_command + options + [args.url] | |
| 51 | |
| 52 if args.verbose: | |
| 53 print full_command | |
| 54 | |
| 55 return full_command | |
| 56 | 37 |
| 57 def main(): | 38 def main(): |
| 58 parser = argparse.ArgumentParser( | 39 parser = argparse.ArgumentParser( |
| 59 description="View a URL with HTMLViewer with mojo media renderer. " | 40 description="View a URL with HTMLViewer in the Kiosk window manager. " |
| 60 "You must have built //mojo/services/html_viewer, " | 41 "You must have built //mojo/services/html_viewer and " |
| 61 "//mojo/services/network and //media/mojo/services first. " | 42 "//mojo/services/network first. Note that this will " |
| 62 " Note that this will currently often fail spectacularly due " | 43 "currently often fail spectacularly due to lack of binary " |
| 63 " to lack of binary stability in Mojo.") | 44 "stability in Mojo.") |
| 64 parser.add_argument( | 45 parser.add_argument( |
| 65 "--build-dir", | 46 "--build-dir", |
| 66 help="Path to the dir containing the linux-x64 binaries relative to the " | 47 help="Path to the dir containing the linux-x64 binaries relative to the " |
| 67 "repo root (default: %(default)s)", | 48 "repo root (default: %(default)s)", |
| 68 default="out/Release") | 49 default="out/Release") |
| 69 parser.add_argument("--verbose", help="Increase output verbosity.", | |
| 70 action="store_true") | |
| 71 parser.add_argument("url", | 50 parser.add_argument("url", |
| 72 help="The URL to be viewed") | 51 help="The URL to be viewed") |
| 73 | 52 |
| 74 args = parser.parse_args() | 53 args = parser.parse_args() |
| 75 return subprocess.call(_BuildShellCommand(args)) | 54 return subprocess.call(_BuildShellCommand(args)) |
| 76 | 55 |
| 77 if __name__ == '__main__': | 56 if __name__ == '__main__': |
| 78 sys.exit(main()) | 57 sys.exit(main()) |
| OLD | NEW |