| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/mojo-helpers.js"></script> | |
| 5 <script src="resources/fake-vr-displays.js"></script> | |
| 6 <script src="resources/mock-vr-service.js"></script> | |
| 7 <script src="resources/test-constants.js"></script> | |
| 8 <script> | |
| 9 let fakeDisplays = fakeVRDisplays(); | |
| 10 | |
| 11 vr_test( (t, mock_service) => { | |
| 12 return navigator.getVRDisplays().then( (displays) => { | |
| 13 var display = displays[0]; | |
| 14 var expected_pose = VALID_POSE; | |
| 15 var fd = new VRFrameData(); | |
| 16 var old_fd = null; | |
| 17 mock_service.mockVRDisplays_[0].setPose(expected_pose); | |
| 18 var counter = 0; | |
| 19 | |
| 20 function onFrame() { | |
| 21 display.requestAnimationFrame(onFrame); | |
| 22 t.step( () => { | |
| 23 assert_true(display.getFrameData(fd)); | |
| 24 }, "getFrameData successfully updated object"); | |
| 25 t.step( () => { | |
| 26 for (let field in expected_pose) { | |
| 27 assert_equals(fd.pose[field].length, expected_pose[field].length); | |
| 28 for (let i = 0; i < expected_pose[field].length; i++) { | |
| 29 assert_approx_equals(fd.pose[field][i], expected_pose[field][i], | |
| 30 FLOAT_EPSILON); | |
| 31 } | |
| 32 } | |
| 33 }, "pose matches expectation"); | |
| 34 if (counter == 0) { | |
| 35 old_fd = fd; | |
| 36 t.step( () => { | |
| 37 // Timestamp should start at 0 for first frame | |
| 38 assert_approx_equals(fd.timestamp, 0.0, FLOAT_EPSILON); | |
| 39 }, "First framedata matches expectation"); | |
| 40 } else { | |
| 41 // Only the timestamp should change since everything else is static | |
| 42 t.step( () => { | |
| 43 assert_approx_equals(fd.timestamp, 1000.0 / 60.0, FLOAT_EPSILON); | |
| 44 for (let i = 0; i < 16; i++) { | |
| 45 assert_approx_equals(fd.leftProjectionMatrix[i], | |
| 46 old_fd.leftProjectionMatrix[i], FLOAT_EPSILON); | |
| 47 assert_approx_equals(fd.leftViewMatrix[i], | |
| 48 old_fd.leftViewMatrix[i], FLOAT_EPSILON); | |
| 49 assert_approx_equals(fd.rightProjectionMatrix[i], | |
| 50 old_fd.rightProjectionMatrix[i], FLOAT_EPSILON); | |
| 51 assert_approx_equals(fd.rightViewMatrix[i], | |
| 52 old_fd.rightViewMatrix[i], FLOAT_EPSILON); | |
| 53 } | |
| 54 }, "Second framedata matches expectation"); | |
| 55 t.done(); | |
| 56 } | |
| 57 counter++; | |
| 58 } | |
| 59 | |
| 60 display.requestAnimationFrame(onFrame); | |
| 61 }, (err) => { | |
| 62 t.step( () => { | |
| 63 assert_unreached("getVRDisplays rejected"); | |
| 64 }); | |
| 65 }); | |
| 66 }, [fakeDisplays["Pixel"]], | |
| 67 "getFrameData only updates expected fields on rAF"); | |
| 68 | |
| 69 </script> | |
| OLD | NEW |