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

Side by Side Diff: chrome/test/data/android/webvr_instrumentation/resources/webvr_boilerplate.js

Issue 2883273006: Better generalize VR test framework (Closed)
Patch Set: Make VrTestRule extend ChromeTabbedActivityTestRule Created 3 years, 6 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Add additional setup steps to the object from webvr_e2e.js if it exists
tiborg 2017/05/30 14:41:23 Nit: end with period.
bsheedy 2017/05/30 18:15:36 Done.
6 if (typeof initializationSteps !== "undefined") {
7 initializationSteps["getVRDisplays"] = false;
8 } else {
9 // Create here if it doesn't exist so we can access it later without checking
10 // if it's defined
tiborg 2017/05/30 14:41:23 Nit: end with period.
bsheedy 2017/05/30 18:15:36 Done.
11 var initializationSteps = {};
12 }
13
5 var webglCanvas = document.getElementById("webgl-canvas"); 14 var webglCanvas = document.getElementById("webgl-canvas");
6 var glAttribs = { 15 var glAttribs = {
7 alpha: false, 16 alpha: false,
8 }; 17 };
9 var gl = webglCanvas.getContext("webgl", glAttribs); 18 var gl = webglCanvas.getContext("webgl", glAttribs);
10 var vrDisplay = null; 19 var vrDisplay = null;
11 var frameData = null; 20 var frameData = null;
12 var onAnimationFrameCallback = null; 21 var onAnimationFrameCallback = null;
13 22
14 function onResize() { 23 function onResize() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 69 }
61 } 70 }
62 71
63 if (navigator.getVRDisplays) { 72 if (navigator.getVRDisplays) {
64 frameData = new VRFrameData(); 73 frameData = new VRFrameData();
65 navigator.getVRDisplays().then( (displays) => { 74 navigator.getVRDisplays().then( (displays) => {
66 if (displays.length > 0) { 75 if (displays.length > 0) {
67 vrDisplay = displays[0]; 76 vrDisplay = displays[0];
68 } 77 }
69 }).then( () => { 78 }).then( () => {
70 vrDisplayPromiseDone = true; 79 initializationSteps["getVRDisplays"] = true;
71 }); 80 });
72 } else { 81 } else {
73 vrDisplayPromiseDone = true; 82 initializationSteps["getVRDisplays"] = true;
74 } 83 }
75 84
76 gl.clearColor(1.0, 0.0, 0.0, 1.0); 85 gl.clearColor(1.0, 0.0, 0.0, 1.0);
77 gl.enable(gl.DEPTH_TEST); 86 gl.enable(gl.DEPTH_TEST);
78 gl.enable(gl.CULL_FACE); 87 gl.enable(gl.CULL_FACE);
79 window.addEventListener("resize", onResize, false); 88 window.addEventListener("resize", onResize, false);
80 window.addEventListener("vrdisplaypresentchange", onVrPresentChange, false); 89 window.addEventListener("vrdisplaypresentchange", onVrPresentChange, false);
81 window.addEventListener('vrdisplayactivate', onVrRequestPresent, false); 90 window.addEventListener('vrdisplayactivate', onVrRequestPresent, false);
82 window.requestAnimationFrame(onAnimationFrame); 91 window.requestAnimationFrame(onAnimationFrame);
83 webglCanvas.onclick = onVrRequestPresent; 92 webglCanvas.onclick = onVrRequestPresent;
84 onResize(); 93 onResize();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698