Commit 6eaeb55f authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add support for VR browsing assets in benchmarks

Adds code to the VR Telemetry benchmarks to support the copying of the
VR browsing assets that are normally downloaded via component updater
onto the device before each story run. This allows the assets to be used
without actually downloading anything.

Bug: 808465
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I320c14e16eb411dd0bf29c57a330e3825fe4dcd6
Reviewed-on: https://chromium-review.googlesource.com/938398
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539983}
parent 84dda214
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//chrome/browser/vr/features.gni")
assert(is_android)
group("vr_perf_tests") {
......@@ -28,7 +30,36 @@ group("vr_perf_tests") {
data_deps = [
"//chrome/android:vr_nfc_simulator_apk",
]
# We'll only ever use the assets if it's a Chrome-branded build. We don't have
# a way of checking whether the files are actually present to copy, but the
# script will deal with that.
if (use_vr_assets_component) {
data_deps += [ ":generate_vr_assets_profile" ]
}
deps = [
"//tools/perf:perf",
]
}
# Copies files to the gen/ directory and creates a manifest so that the VR
# assets component can be used during Telemetry tests.
action("generate_vr_assets_profile") {
script = "generate_vr_assets_profile.py"
# We should re-run anytime the version or any related files change.
inputs = [
"//chrome/browser/resources/vr/assets/google_chrome",
"//chrome/browser/resources/vr/assets/VERSION",
"//chrome/browser/resources/vr/assets/vr_assets_component_files.json",
]
outputs = [
"$target_gen_dir/vr_assets_profile/",
]
args = [
"--output",
rebase_path(target_gen_dir, root_build_dir),
"--asset-dir",
rebase_path("//chrome/browser/resources/vr/assets", root_build_dir),
]
}
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Generates a Chrome profile that allows VR asset use in Telemetry tests.
Copies all necessary files into a generated directory and creates a manifest.
"""
import argparse
import json
import os
import shutil
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--output',
required=True,
help='The gen directory to put the profile directory in')
parser.add_argument('--asset-dir',
required=True,
help='The directory containing the asset information')
args, _ = parser.parse_known_args()
# Add the directory to the path so we can get the parse_version script.
asset_dir = args.asset_dir
sys.path.append(asset_dir)
#pylint: disable=import-error
import parse_version
# Get the assets version.
with open(os.path.join(asset_dir, 'VERSION'), 'r') as version_file:
version = parse_version.ParseVersion(version_file.readlines())
if not version:
raise RuntimeError('Could not get version for VR assets')
# Clean up a pre-existing profile and create the necessary directories.
profile_dir = os.path.join(args.output, 'vr_assets_profile')
if os.path.isdir(profile_dir):
shutil.rmtree(profile_dir)
# Check whether there are actually files to copy - if not, the lack of a
# directory will cause Telemetry to fail if we actually try to use the profile
# directory. This is a workaround for not being able to check whether we
# should have the files in GN. This way, we won't just fail silently during
# tests, i.e. use the fallback assets, but we don't get build errors on bots
# due to trying to copy non-existent files.
found_asset = False
for asset in os.listdir(os.path.join(asset_dir, 'google_chrome')):
if asset.endswith('.png') or asset.endswith('.jpeg'):
found_asset = True
break
if not found_asset:
return
profile_dir = os.path.join(profile_dir, 'VrAssets',
'%d.%d' % (version.major, version.minor))
os.makedirs(profile_dir)
# Only copy the files specified by the asset JSON file.
with open(os.path.join(asset_dir,
'vr_assets_component_files.json'), 'r') as asset_json_file:
asset_files = json.load(asset_json_file)
for asset in asset_files:
shutil.copy(os.path.join(asset_dir, asset), profile_dir)
# Generate the manifest file.
with open(os.path.join(profile_dir, 'manifest.json'), 'w') as manifest_file:
json.dump({
'manifest_version': 2,
'name': 'VrAssets',
'version': '%d.%d' % (version.major, version.minor)}, manifest_file)
if __name__ == '__main__':
main()
......@@ -10,9 +10,9 @@ from contrib.vr_benchmarks.vr_sample_page import VrSamplePage
class Simple2dStillPage(VrSamplePage):
"""A simple 2D page without user interactions."""
def __init__(self, page_set):
def __init__(self, page_set, sample_page='index'):
super(Simple2dStillPage, self).__init__(
sample_page='index', page_set=page_set)
sample_page=sample_page, page_set=page_set)
def RunPageInteractions(self, action_runner):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment