Commit 0080c863 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

WebXR: Move DOM Overlay test to external WPT

https://github.com/immersive-web/dom-overlays/issues/12

Bug: 991747
Change-Id: Iab360d76c947048bc6650674587f3bcc95a8d4cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036514Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738016}
parent dddcd182
...@@ -203,12 +203,13 @@ class MockRuntime { ...@@ -203,12 +203,13 @@ class MockRuntime {
// Mapping from string feature names to the corresponding mojo types. // Mapping from string feature names to the corresponding mojo types.
// This is exposed as a member for extensibility. // This is exposed as a member for extensibility.
static featureToMojoMap = { static featureToMojoMap = {
"viewer": device.mojom.XRSessionFeature.REF_SPACE_VIEWER, 'viewer': device.mojom.XRSessionFeature.REF_SPACE_VIEWER,
"local": device.mojom.XRSessionFeature.REF_SPACE_LOCAL, 'local': device.mojom.XRSessionFeature.REF_SPACE_LOCAL,
"local-floor": device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR, 'local-floor': device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,
"bounded-floor": device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR, 'bounded-floor': device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,
"unbounded": device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED, 'unbounded': device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED,
"hit-test": device.mojom.XRSessionFeature.HIT_TEST, 'hit-test': device.mojom.XRSessionFeature.HIT_TEST,
'dom-overlay': device.mojom.XRSessionFeature.DOM_OVERLAY,
}; };
static sessionModeToMojoMap = { static sessionModeToMojoMap = {
...@@ -1222,9 +1223,18 @@ class MockXRInputSource { ...@@ -1222,9 +1223,18 @@ class MockXRInputSource {
this.desc_dirty_ = false; this.desc_dirty_ = false;
} }
// Pointer data for DOM Overlay, set by setOverlayPointerPosition()
if (this.overlay_pointer_position_) {
input_state.overlayPointerPosition = this.overlay_pointer_position_;
}
return input_state; return input_state;
} }
setOverlayPointerPosition(x, y) {
this.overlay_pointer_position_ = {x: x, y: y};
}
getEmptyGamepad() { getEmptyGamepad() {
// Mojo complains if some of the properties on Gamepad are null, so set // Mojo complains if some of the properties on Gamepad are null, so set
// everything to reasonable defaults that tests can override. // everything to reasonable defaults that tests can override.
......
<!DOCTYPE html> <!DOCTYPE html>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>let additionalChromiumResources = ["../resources/xr-internal-device-mocking.js"];</script> <script src="../resources/webxr_util.js"></script>
<script src="/webxr/resources/webxr_util.js"></script> <script src="../resources/webxr_test_constants.js"></script>
<script src="/webxr/resources/webxr_test_constants.js"></script> <script src="../resources/webxr_test_asserts.js"></script>
<script src="/webxr/resources/webxr_test_asserts.js"></script>
<style type="text/css"> <style type="text/css">
div { div {
...@@ -25,19 +24,18 @@ ...@@ -25,19 +24,18 @@
</div> </div>
<script> <script>
// Because AR is not yet in the core webxr spec, this is an internal-chrome only test.
let fakeDeviceInitParams = { supportedModes: ["immersive-ar"], const fakeDeviceInitParams = {
views: VALID_VIEWS, supportedModes: ["immersive-ar"],
viewerOrigin: IDENTITY_TRANSFORM, views: VALID_VIEWS,
supportedFeatures: ALL_FEATURES.concat([ viewerOrigin: IDENTITY_TRANSFORM,
'dom-overlay'])}; supportedFeatures: ALL_FEATURES,
};
let watcherStep = new Event("watcherstep"); let watcherStep = new Event("watcherstep");
let watcherDone = new Event("watcherdone"); let watcherDone = new Event("watcherdone");
let testFunction = function(overlayElement, session, fakeDeviceController, t) { let testFunction = function(overlayElement, session, fakeDeviceController, t) {
console.log('session start');
assert_equals(session.mode, 'immersive-ar'); assert_equals(session.mode, 'immersive-ar');
assert_not_equals(session.environmentBlendMode, 'opaque'); assert_not_equals(session.environmentBlendMode, 'opaque');
...@@ -60,12 +58,7 @@ let testFunction = function(overlayElement, session, fakeDeviceController, t) { ...@@ -60,12 +58,7 @@ let testFunction = function(overlayElement, session, fakeDeviceController, t) {
let inner_b = document.getElementById('inner_b'); let inner_b = document.getElementById('inner_b');
assert_true(inner_b != null); assert_true(inner_b != null);
session.addEventListener('select', (ev) => {
console.log(ev.type, ev);
});
inner_a.addEventListener('beforexrselect', (ev) => { inner_a.addEventListener('beforexrselect', (ev) => {
console.log(ev.type, ev);
ev.preventDefault(); ev.preventDefault();
}); });
...@@ -83,34 +76,27 @@ let testFunction = function(overlayElement, session, fakeDeviceController, t) { ...@@ -83,34 +76,27 @@ let testFunction = function(overlayElement, session, fakeDeviceController, t) {
session.requestReferenceSpace('viewer').then(function(viewerSpace) { session.requestReferenceSpace('viewer').then(function(viewerSpace) {
// Press the primary input button and then release it a short time later. // Press the primary input button and then release it a short time later.
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 1 time=' + time);
input_source.setOverlayPointerPosition(inner_a.offsetLeft + 1, input_source.setOverlayPointerPosition(inner_a.offsetLeft + 1,
inner_a.offsetTop + 1); inner_a.offsetTop + 1);
input_source.startSelection(); input_source.startSelection();
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 2 time=' + time);
input_source.endSelection(); input_source.endSelection();
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 3 time=' + time);
// Need to process one more frame to allow select to propagate. // Need to process one more frame to allow select to propagate.
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 4 time=' + time);
session.dispatchEvent(watcherStep); session.dispatchEvent(watcherStep);
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 5 time=' + time);
input_source.setOverlayPointerPosition(inner_b.offsetLeft + 1, input_source.setOverlayPointerPosition(inner_b.offsetLeft + 1,
inner_b.offsetTop + 1); inner_b.offsetTop + 1);
input_source.startSelection(); input_source.startSelection();
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 6 time=' + time);
input_source.endSelection(); input_source.endSelection();
session.requestAnimationFrame((time, xrFrame) => { session.requestAnimationFrame((time, xrFrame) => {
console.log('frame 7 time=' + time);
// Need to process one more frame to allow select to propagate. // Need to process one more frame to allow select to propagate.
session.dispatchEvent(watcherDone); session.dispatchEvent(watcherDone);
}); });
......
...@@ -121,12 +121,13 @@ const NON_IMMERSIVE_VIEWS = [{ ...@@ -121,12 +121,13 @@ const NON_IMMERSIVE_VIEWS = [{
]; ];
const ALL_FEATURES = [ const ALL_FEATURES = [
"viewer", 'viewer',
"local", 'local',
"local-floor", 'local-floor',
"bounded-floor", 'bounded-floor',
"unbounded", 'unbounded',
"hit-test", 'hit-test',
'dom-overlay',
]; ];
const TRACKED_IMMERSIVE_DEVICE = { const TRACKED_IMMERSIVE_DEVICE = {
......
...@@ -60,10 +60,6 @@ MockRuntime.prototype._injectAdditionalFrameData = function(options, frameData) ...@@ -60,10 +60,6 @@ MockRuntime.prototype._injectAdditionalFrameData = function(options, frameData)
}; };
}; };
// Patch in experimental features.
MockRuntime.featureToMojoMap["dom-overlay"] =
device.mojom.XRSessionFeature.DOM_OVERLAY;
ChromeXRTest.prototype.getService = function() { ChromeXRTest.prototype.getService = function() {
return this.mockVRService_; return this.mockVRService_;
}; };
...@@ -80,22 +76,3 @@ MockVRService.prototype.getFramesThrottled = function() { ...@@ -80,22 +76,3 @@ MockVRService.prototype.getFramesThrottled = function() {
return this.frames_throttled_; return this.frames_throttled_;
}; };
MockXRInputSource.prototype.getInputSourceStateCommon =
MockXRInputSource.prototype.getInputSourceState;
MockXRInputSource.prototype.getInputSourceState = function() {
const input_state = this.getInputSourceStateCommon();
console.log('getInputSourceState this.overlay_pointer_position_=' + JSON.stringify(this.overlay_pointer_position_));
if (this.overlay_pointer_position_) {
input_state.overlayPointerPosition = this.overlay_pointer_position_;
}
console.log('input_state=' + JSON.stringify(input_state));
return input_state;
};
MockXRInputSource.prototype.setOverlayPointerPosition = function(x, y) {
this.overlay_pointer_position_ = { x: x, y: y };
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment