Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: chrome/test/vr/perf/latency/android_webvr_latency_test.py

Issue 2823883003: Make VR latency results compatible with perf dashboard, refactor into classes (Closed)
Patch Set: Address nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/vr/perf/latency/__init__.py ('k') | chrome/test/vr/perf/latency/motopho_thread.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import webvr_latency_test
6
7 import logging
8 import os
9 import time
10
11
12 DEFAULT_SCREEN_WIDTH = 720
13 DEFAULT_SCREEN_HEIGHT = 1280
14 NUM_VR_ENTRY_ATTEMPTS = 5
15
16
17 class AndroidWebVrLatencyTest(webvr_latency_test.WebVrLatencyTest):
18 """Android implementation of the WebVR latency test."""
19 def __init__(self, args):
20 super(AndroidWebVrLatencyTest, self).__init__(args)
21 self._device_name = self._Adb(['shell', 'getprop',
22 'ro.product.name']).strip()
23
24 def _Setup(self):
25 self._Adb(['root'])
26
27 # Install the latest VrCore and Chrome APKs
28 self._Adb(['install', '-r', '-d',
29 '../../third_party/gvr-android-sdk/test-apks/vr_services'
30 '/vr_services_current.apk'])
31 self._SaveInstalledVrCoreVersion()
32 # TODO(bsheedy): Make APK path configurable so usable with other channels
33 self._Adb(['install', '-r', 'apks/ChromePublic.apk'])
34
35 # Force WebVR support, remove open tabs, and don't have first run
36 # experience.
37 self._SetChromeCommandLineFlags(['--enable-webvr', '--no-restore-state',
38 '--disable-fre'])
39 # Wake up the device and sleep, otherwise WebGL can crash on startup.
40 self._Adb(['shell', 'input', 'keyevent', 'KEYCODE_WAKEUP'])
41 time.sleep(1)
42
43 # Start Chrome
44 self._Adb(['shell', 'am', 'start',
45 '-a', 'android.intent.action.MAIN',
46 '-n', 'org.chromium.chrome/com.google.android.apps.chrome.Main',
47 self._flicker_app_url])
48 time.sleep(10)
49
50 # Tap the center of the screen to start presenting.
51 # It's technically possible that the screen tap won't enter VR on the first
52 # time, so try several times by checking for the logcat output from
53 # entering VR
54 (width, height) = self._GetScreenResolution()
55 entered_vr = False
56 for _ in xrange(NUM_VR_ENTRY_ATTEMPTS):
57 self._Adb(['logcat', '-c'])
58 self._Adb(['shell', 'input', 'touchscreen', 'tap', str(width/2),
59 str(height/2)])
60 time.sleep(5)
61 output = self._Adb(['logcat', '-d'])
62 if 'Initialized GVR version' in output:
63 entered_vr = True
64 break
65 logging.warning('Failed to enter VR, retrying')
66 if not entered_vr:
67 raise RuntimeError('Failed to enter VR after %d attempts'
68 % NUM_VR_ENTRY_ATTEMPTS)
69
70 def _Teardown(self):
71 # Exit VR and close Chrome
72 self._Adb(['shell', 'input', 'keyevent', 'KEYCODE_BACK'])
73 self._Adb(['shell', 'am', 'force-stop', 'org.chromium.chrome'])
74 # Turn off the screen
75 self._Adb(['shell', 'input', 'keyevent', 'KEYCODE_POWER'])
76
77 def _Adb(self, cmd):
78 """Runs the given command via adb.
79
80 Returns:
81 A string containing the stdout and stderr of the adb command.
82 """
83 # TODO(bsheedy): Maybe migrate to use Devil (overkill?)
84 return self._RunCommand([self.args.adb_path] + cmd)
85
86 def _SaveInstalledVrCoreVersion(self):
87 """Retrieves the VrCore version and saves it for dashboard uploading."""
88 output = self._Adb(['shell', 'dumpsys', 'package', 'com.google.vr.vrcore'])
89 version = None
90 for line in output.split('\n'):
91 if 'versionName' in line:
92 version = line.split('=')[1]
93 break
94 if version:
95 logging.info('VrCore version is %s', version)
96 else:
97 logging.info('VrCore version not retrieved')
98 version = '0'
99 if not (self.args.output_dir and os.path.isdir(self.args.output_dir)):
100 logging.warning('No output directory, not saving VrCore version')
101 return
102 with file(os.path.join(self.args.output_dir,
103 self.args.vrcore_version_file), 'w') as outfile:
104 outfile.write(version)
105
106 def _SetChromeCommandLineFlags(self, flags):
107 """Sets the Chrome command line flags to the given list."""
108 self._Adb(['shell', "echo 'chrome " + ' '.join(flags) + "' > "
109 + '/data/local/tmp/chrome-command-line'])
110
111 def _GetScreenResolution(self):
112 """Retrieves the device's screen resolution, or a default if not found.
113
114 Returns:
115 A tuple (width, height).
116 """
117 output = self._Adb(['shell', 'dumpsys', 'display'])
118 width = None
119 height = None
120 for line in output.split('\n'):
121 if 'mDisplayWidth' in line:
122 width = int(line.split('=')[1])
123 elif 'mDisplayHeight' in line:
124 height = int(line.split('=')[1])
125 if width and height:
126 break
127 if not width:
128 logging.warning('Could not get actual screen width, defaulting to %d',
129 DEFAULT_SCREEN_WIDTH)
130 width = DEFAULT_SCREEN_WIDTH
131 if not height:
132 logging.warning('Could not get actual screen height, defaulting to %d',
133 DEFAULT_SCREEN_HEIGHT)
134 height = DEFAULT_SCREEN_HEIGHT
135 return (width, height)
OLDNEW
« no previous file with comments | « chrome/test/vr/perf/latency/__init__.py ('k') | chrome/test/vr/perf/latency/motopho_thread.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698