blob: b2dcdf6a263ee8757a0d03cc73a84c5c215af26f [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module device_test.mojom;
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/transform.mojom";
struct Color {
uint8 r;
uint8 g;
uint8 b;
uint8 a;
enum Eye {
LEFT = 1,
struct SubmittedFrameData {
Color color;
Eye eye;
gfx.mojom.Rect viewport;
gfx.mojom.Size image_size;
struct PoseFrameData {
gfx.mojom.Transform? device_to_origin;
// Each component is the tangent of the up/down/left/right view frustum.
struct ProjectionRaw {
float left;
float right;
float top;
float bottom;
struct DeviceConfig {
float interpupillary_distance; // Distance between the eyes.
ProjectionRaw projection_left;
ProjectionRaw projection_right;
struct ControllerAxisData {
float x;
float y;
uint8 axis_type; // Corresponds to OpenVR's EVRControllerAxisType
enum TrackedDeviceClass {
enum ControllerRole {
kControllerRoleInvalid, // Test hook should ignore this controller.
kControllerRoleVoice // Simulates voice input such as saying "select" in WMR.
struct ControllerFrameData {
uint32 packet_number;
uint64 buttons_pressed;
uint64 buttons_touched;
uint64 supported_buttons;
array<ControllerAxisData, 5> axis_data;
PoseFrameData pose_data;
ControllerRole role = kControllerRoleInvalid;
bool is_valid;
// Event type is used by test to simulate runtime events.
enum EventType {
// EventData is used by test to pass all event related data.
struct EventData {
EventType type = kNoEvent;
// Tests may implement this, and register it to control behavior of devices for
// tests. The test interface lives in the browser process, and may be consumed
// by the device utility process.
// It is only implemented when running in browser tests.
interface XRTestHook {
// Notifies the test anytime the XR runtime receives a frame with the data
// that was submitted.
[Sync] OnFrameSubmitted(SubmittedFrameData frame_data) => ();
// Called by the XR runtime to retrieve the XR device's configuration set by
// the test.
[Sync] WaitGetDeviceConfig() => (DeviceConfig config);
// Called by the XR runtime to retrieve the XR device's pose while in a
// presenting/exclusive session.
[Sync] WaitGetPresentingPose() => (PoseFrameData data);
// Called by the XR runtime to retrieve the XR device's pose while in a
// magic window/non-exclusive session.
[Sync] WaitGetMagicWindowPose() => (PoseFrameData data);
// Called by the XR runtime to retrieve the ControllerRole of the device
// that the test has registered at the given index, i.e. which hand the
// controller is mapped to.
[Sync] WaitGetControllerRoleForTrackedDeviceIndex(uint32 index) =>
(ControllerRole role);
// Called by the XR runtime to retrieve the class of the device that the test
// has registered at the given index, e.g. whether it is a controller or
// headset.
[Sync] WaitGetTrackedDeviceClass(uint32 index) =>
(TrackedDeviceClass device_class);
// Called by the XR runtime anytime it updates its controller data to retrieve
// the controller data of the device that the test has registered at the
// given index, e.g. its current position and pressed buttons.
[Sync] WaitGetControllerData(uint32 index) => (ControllerFrameData data);
// Called by the OpenXR test to simulate runtime events.
[Sync] WaitGetEventData() => (EventData data);
// Interface exposed by IsolatedXRService to allow browser tests to hook VR APIs
// It is always hosted in the XRDevice process, but only has effects while
// running in browser tests with mock implementations of runtimes.
interface XRServiceTestHook {
[Sync] SetTestHook(pending_remote<XRTestHook>? hook) => ();
// Called by tests to trigger a termination of the Device Service Process
// To test that the product can properly handle the service either crashing
// or (more expectedly) being terminated by some other running process.
[Sync] TerminateDeviceServiceProcessForTesting() => ();