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

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

Issue 2883273006: Better generalize VR test framework (Closed)
Patch Set: Address nits 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
« no previous file with comments | « chrome/test/data/android/webvr_instrumentation/resources/webvr_boilerplate.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var testPassed = false; 5 var testPassed = false;
6 var resultString = ""; 6 var resultString = "";
7 var asyncCounter = 0;
8 var javascriptDone = false; 7 var javascriptDone = false;
9 var vrDisplayPromiseDone = false; 8 var initializationSteps = {load: false};
10 9
11 function finishJavaScriptStep() { 10 function finishJavaScriptStep() {
12 javascriptDone = true; 11 javascriptDone = true;
13 } 12 }
14 13
14 // Used to check when JavaScript is in an acceptable state to start testing
15 // after a page load, as Chrome thinking that the page has finished loading
16 // is not always sufficient. By default waits until the load event is fired.
17 function isInitializationComplete() {
18 for (var step in initializationSteps) {
19 if (!initializationSteps[step]) {
20 return false;
21 }
22 }
23 return true;
24 }
25
26 window.addEventListener("load",
27 () => {initializationSteps["load"] = true;}, false);
28
15 function checkResultsForFailures(tests, harness_status) { 29 function checkResultsForFailures(tests, harness_status) {
16 testPassed = true; 30 testPassed = true;
17 if (harness_status["status"] != 0) { 31 if (harness_status["status"] != 0) {
18 testPassed = false; 32 testPassed = false;
19 resultString += "Harness failed due to " + 33 resultString += "Harness failed due to " +
20 (harness_status["status"] == 1 ? "error" : "timeout") 34 (harness_status["status"] == 1 ? "error" : "timeout")
21 + ". "; 35 + ". ";
22 } 36 }
23 for (var test in tests) { 37 for (var test in tests) {
24 let passed = (tests[test]["status"] == 0); 38 let passed = (tests[test]["status"] == 0);
25 if (!passed) { 39 if (!passed) {
26 testPassed = false; 40 testPassed = false;
27 resultString += "FAIL "; 41 resultString += "FAIL ";
28 } else { 42 } else {
29 resultString += "PASS "; 43 resultString += "PASS ";
30 } 44 }
31 resultString += tests[test]["name"] + 45 resultString += tests[test]["name"] +
32 (passed ? "" : (": " + tests[test]["message"])) + 46 (passed ? "" : (": " + tests[test]["message"])) +
33 ". "; 47 ". ";
34 } 48 }
35 } 49 }
36 50
37 add_completion_callback( (tests, harness_status) => { 51 // Only interact with testharness.js if it was actually included on the page
38 checkResultsForFailures(tests, harness_status); 52 // before this file
39 console.debug("Test result: " + (testPassed ? "Pass" : "Fail")); 53 if (typeof add_completion_callback !== "undefined") {
40 console.debug("Test result string: " + resultString); 54 add_completion_callback( (tests, harness_status) => {
41 finishJavaScriptStep(); 55 checkResultsForFailures(tests, harness_status);
42 }); 56 console.debug("Test result: " + (testPassed ? "Pass" : "Fail"));
57 console.debug("Test result string: " + resultString);
58 finishJavaScriptStep();
59 });
60 }
OLDNEW
« no previous file with comments | « chrome/test/data/android/webvr_instrumentation/resources/webvr_boilerplate.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698