1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../resources/webxr_util.js"></script>
<script src="../resources/webxr_test_constants.js"></script>
<script src="../resources/webxr_test_constants_fake_depth.js"></script>
<script>
const depthConfigurationTestGenerator =
function (sessionOptions, shouldGrantSession, shouldDepthBeEnabled = true) {
return (t) => {
return navigator.xr.test.simulateDeviceConnection(IMMERSIVE_AR_DEVICE)
.then((controller) => new Promise((resolve, reject) => {
navigator.xr.test.simulateUserActivation(() => {
navigator.xr.requestSession('immersive-ar', sessionOptions)
.then((session) => {
return session.end().then(() => {
if (!shouldGrantSession) {
reject("Session granted when expected rejection.");
return;
}
t.step(() => {
let depthEnabled = session.enabledFeatures.includes('depth-sensing');
assert_true(depthEnabled == shouldDepthBeEnabled);
});
resolve();
});
})
.catch((err) => {
if (shouldGrantSession) {
reject("Session rejected with error: " + err);
return;
}
resolve();
});
});
}));
};
};
// Valid configurations when depth is a required feature
xr_promise_test(
"depthSensing - Required - Fully populated grants session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: DEPTH_CONFIG_ALL_USAGES,
dataFormatPreference: DEPTH_CONFIG_ALL_FORMATS
},
}, /*shouldGrantSession=*/true));
xr_promise_test(
"depthSensing - Required - Empty usage grants session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: [],
dataFormatPreference: DEPTH_CONFIG_ALL_FORMATS
},
}, /*shouldGrantSession=*/true));
xr_promise_test(
"depthSensing - Required - Empty format grants session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: DEPTH_CONFIG_ALL_USAGES,
dataFormatPreference: [],
},
}, /*shouldGrantSession=*/true));
xr_promise_test(
"depthSensing - Required - Empty usage and format grants session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: [],
dataFormatPreference: [],
},
}, /*shouldGrantSession=*/true));
// Invalid configurations when depth is a required feature
xr_promise_test(
"depthSensing - Required - Missing usage rejects session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
dataFormatPreference: [],
},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Required - Missing format rejects session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: [],
},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Required - Missing usage and format rejects session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
depthSensing: {},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Required - Missing configuration rejects session",
depthConfigurationTestGenerator({
'requiredFeatures': ['depth-sensing'],
}, /*shouldGrantSession=*/false));
// Invalid configurations when depth is an optional feature
xr_promise_test(
"depthSensing - Optional - Missing usage optional still rejects session",
depthConfigurationTestGenerator({
'optionalFeatures': ['depth-sensing'],
depthSensing: {
dataFormatPreference: [],
},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Optional - Missing format optional still rejects session",
depthConfigurationTestGenerator({
'optionalFeatures': ['depth-sensing'],
depthSensing: {
usagePreference: [],
},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Optional - Missing usage and format optional still rejects session",
depthConfigurationTestGenerator({
'optionalFeatures': ['depth-sensing'],
depthSensing: {},
}, /*shouldGrantSession=*/false));
xr_promise_test(
"depthSensing - Optional - Missing configuration optional grants session without depth",
depthConfigurationTestGenerator({
'optionalFeatures': ['depth-sensing'],
}, /*shouldGrantSession=*/true,
/*shouldDepthBeEnabled=*/false));
</script>
|