xrCamera_resolution.https.html (2924B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="../resources/webxr_util.js"></script> 5 <script src="../resources/webxr_test_asserts.js"></script> 6 <script src="../resources/webxr_test_constants.js"></script> 7 <script src="../resources/webxr_test_constants_fake_world.js"></script> 8 9 <script> 10 11 const fakeDeviceInitParams = { 12 supportedModes: ["immersive-ar"], 13 views: VALID_VIEWS, 14 supportedFeatures: ALL_FEATURES, 15 }; 16 17 const test_camera_present = (session, fakeDeviceController, t) => { 18 return session.requestReferenceSpace('viewer').then(viewerRefSpace => { 19 return new Promise((resolve, reject) => { 20 const requestAnimationFrameCallbackWithCamera = (time, frame) => { 21 const viewerPose = frame.getViewerPose(viewerRefSpace); 22 23 t.step(() => { 24 let foundCamera = false; 25 26 assert_not_equals(viewerPose, null, "Viewer pose should not be null!"); 27 assert_equals(viewerPose.views.length, VALID_VIEWS.length, "View lengths should match!"); 28 29 for (const view of viewerPose.views) { 30 if (view.camera) { 31 assert_equals(view.camera.width, 333, "Width doesn't match expectations!"); 32 assert_equals(view.camera.height, 444, "Height doesn't match expectations!"); 33 34 foundCamera = true; 35 } 36 } 37 38 assert_true(foundCamera, "There should be at least one camera! Didn't find any.") 39 }); 40 41 resolve(); 42 }; 43 44 const requestAnimationFrameCallbackNoCamera = (time, frame) => { 45 46 const viewerPose = frame.getViewerPose(viewerRefSpace); 47 t.step(() => { 48 assert_not_equals(viewerPose, null, "Viewer pose should not be null!"); 49 assert_equals(viewerPose.views.length, VALID_VIEWS.length, "View lengths should match!"); 50 51 for (const view of viewerPose.views) { 52 assert_equals(view.camera, null, "Camera should be null!"); 53 } 54 }); 55 56 const views_with_camera = VALID_VIEWS.map((element, index) => { 57 return { 58 ...element, 59 resolution: { width: 111 * (index+1), height: 222 * (index+1)}, 60 cameraImageInit: { width: 333, height: 444 }, 61 }; 62 }); 63 fakeDeviceController.setViews(views_with_camera); 64 65 // After this rAFcb, the test is supposed to continue w/ a callback that 66 // expects XRCamera to be present: 67 session.requestAnimationFrame(requestAnimationFrameCallbackWithCamera); 68 }; 69 70 // Kick off the test - start with rAFcb w/o an XRCamera: 71 session.requestAnimationFrame(requestAnimationFrameCallbackNoCamera); 72 }); 73 }); 74 }; 75 76 xr_session_promise_test("XRCamera object is present and carries expected dimensions", 77 test_camera_present, 78 fakeDeviceInitParams, 'immersive-ar', {'requiredFeatures': ['camera-access']}); 79 80 </script>