Commit fea2b7b9 authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Add browser test for WMR voice input

Update the test API with a new controller role kControllerRoleVoice
which allows simulating voice input when using the mock WMR wrappers.
The test is just simulating a voice select and makes sure the event is
registered by the JS.

Bug: 990892
Change-Id: I78d1f765780b42eb571fe290f6d61f664e3298f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769050
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690070}
parent 6320d946
......@@ -17,6 +17,8 @@ device_test::mojom::ControllerRole DeviceToMojoControllerRole(
return device_test::mojom::ControllerRole::kControllerRoleRight;
case device::kControllerRoleLeft:
return device_test::mojom::ControllerRole::kControllerRoleLeft;
case device::kControllerRoleVoice:
return device_test::mojom::ControllerRole::kControllerRoleVoice;
}
}
......
......@@ -166,7 +166,9 @@ class WebXrControllerInputMock : public MockXRDeviceHookBase {
UpdateControllerAndWait(index, controller_data);
}
unsigned int CreateAndConnectMinimalGamepad() {
unsigned int CreateAndConnectMinimalGamepad(
device::ControllerRole role =
device::ControllerRole::kControllerRoleRight) {
// Create a controller that only supports select via a trigger, i.e. it has
// just enough data to be considered a gamepad.
uint64_t supported_buttons =
......@@ -176,9 +178,7 @@ class WebXrControllerInputMock : public MockXRDeviceHookBase {
{device::XrButtonId::kAxisTrigger, device::XrAxisType::kTrigger},
};
return CreateAndConnectController(
device::ControllerRole::kControllerRoleRight, axis_types,
supported_buttons);
return CreateAndConnectController(role, axis_types, supported_buttons);
}
unsigned int CreateAndConnectController(
......@@ -222,6 +222,13 @@ class WebXrControllerInputMock : public MockXRDeviceHookBase {
UpdateControllerAndWait(controller_index, controller_data);
}
// A controller is necessary to simulate voice input because of how the test
// API works.
unsigned int CreateVoiceController() {
return CreateAndConnectMinimalGamepad(
device::ControllerRole::kControllerRoleVoice);
}
private:
// kAxisTrackpad is the first entry in XrButtonId that maps to an axis and the
// subsequent entries are also for input axes.
......@@ -416,7 +423,7 @@ IN_PROC_BROWSER_TEST_F(WebXrVrOpenVrBrowserTest, TestInputProfilesChange) {
// and that if whether or not an input source has a gamepad changes that the
// input source change event is fired and a new input source is created.
// OpenVR-only since WMR doesn't support the notion of an incomplete gamepad
// except if using voice input, which is currently not supported in tests.
// except if using voice input.
IN_PROC_BROWSER_TEST_F(WebXrVrOpenVrBrowserTest, TestInputGamepadSameObject) {
WebXrControllerInputMock my_mock;
......@@ -928,6 +935,26 @@ IN_PROC_MULTI_CLASS_BROWSER_TEST_F2(WebXrVrOpenVrBrowserTest,
t->EndTest();
}
// Test that voice input is registered via WebXR's input method. WMR only since
// it's the only platform we are testing that supports select via voice.
IN_PROC_BROWSER_TEST_F(WebXrVrWmrBrowserTest, TestVoiceSelectRegistered) {
WebXrControllerInputMock my_mock;
unsigned int index = my_mock.CreateVoiceController();
// Load the test page and enter presentation.
LoadUrlAndAwaitInitialization(GetFileUrlForHtmlTestFile("test_webxr_input"));
EnterSessionWithUserGestureOrFail();
RunJavaScriptOrFail("stepSetupListeners(1)");
// Simulate the user saying "select" and make sure the select events are
// registered for it. Must wait for JS to receive the "select" event.
my_mock.PressReleasePrimaryTrigger(index);
WaitOnJavaScriptStep();
EndTest();
}
// TODO(crbug.com/986637) - Enable for OpenXR
// Test that controller input is registered via WebXR's input method.
// Equivalent to
......
......@@ -17,6 +17,8 @@ ControllerRole MojoToDeviceControllerRole(
return device::kControllerRoleLeft;
case device_test::mojom::ControllerRole::kControllerRoleRight:
return device::kControllerRoleRight;
case device_test::mojom::ControllerRole::kControllerRoleVoice:
return device::kControllerRoleVoice;
}
return device::kControllerRoleInvalid;
}
......
......@@ -63,9 +63,10 @@ enum TrackedDeviceClass {
};
enum ControllerRole {
kControllerRoleInvalid,
kControllerRoleInvalid, // Test hook should ignore this controller.
kControllerRoleLeft,
kControllerRoleRight
kControllerRoleRight,
kControllerRoleVoice // Simulates voice input such as saying "select" in WMR.
};
struct ControllerFrameData {
......
......@@ -105,9 +105,10 @@ enum TrackedDeviceClass {
};
enum ControllerRole {
kControllerRoleInvalid,
kControllerRoleInvalid, // Test hook should ignore this controller.
kControllerRoleLeft,
kControllerRoleRight
kControllerRoleRight,
kControllerRoleVoice // Simulates voice input such as saying "select" in WMR.
};
struct ControllerFrameData {
......
......@@ -26,8 +26,19 @@ uint32_t MockWMRInputSource::Id() const {
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourceKind
MockWMRInputSource::Kind() const {
switch (data_.role) {
case ControllerRole::kControllerRoleLeft:
case ControllerRole::kControllerRoleRight:
return ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourceKind_Controller;
case ControllerRole::kControllerRoleVoice:
return ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourceKind_Voice;
case ControllerRole::kControllerRoleInvalid:
NOTREACHED();
return ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourceKind_Controller;
}
}
bool MockWMRInputSource::IsPointingSupported() const {
......
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