12to11/12to11-test.xml
hujianwei 686f71c3b4 Add seat testing mechanism and tests for seats
* 12to11-test.xml (test_manager): <error>: Add `invalid_button',
`value_exists', `bad_seat_version' and `invalid_valuator'.
(test_manager): <get_test_seat>: New request.
(test_XIButtonState, test_XIModifierState, test_XIValuatorState)
(test_seat_controller): New interfaces.
* Imakefile: (seat.o): Depend on test_seat.c.
* compositor.h: Update prototypes.
* run.c (XLRunCompositor): Get rid of stdbool constant.
* seat.c (HandleBind1): Move binding logic to this new function.
(HandleBind): Call HandleBind1.
(InitSeatCommon): Add list initialization to this function.
(MakeSeatForDevicePair): Call InitSeatCommon instead.
(HandleRawKey, UpdateModifiersForSeats, DispatchFocusIn)
(DispatchMotion, DispatchBarrierHit, DispatchGesturePinch)
(DispatchGestureSwipe): Do not update user time from send_event
events.  Include test_seat.c.
* test.c (GetTestSeat): New function.
(test_manager_impl): Add new proc function.
(XLLookUpTestSurface): New function.
* tests/Imakefile (OBJS8, SRCS8): New program.
(PROGRAMS): Add seat_test.
(seat_test): New function.
* tests/run_tests.sh (standard_tests): Add seat_test.
* tests/svnignore.txt: Add seat_test.
* tests/test_harness.c (report_test_internal_error,
test_init_seat): New functions.
* tests/test_harness.h (struct test_seat): New struct.
(struct test_display): New field `seat'.
2022-11-07 06:21:07 +00:00

424 lines
15 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<protocol name="test">
<copyright>
Copyright (C) 2022 various contributors.
This file is part of 12to11.
12to11 is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
12to11 is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with 12to11. If not, see https://www.gnu.org/licenses/.
</copyright>
<interface name="test_manager" version="1">
<description summary="test interface">
This protocol is used by the 12to11 protocol translator to
support various tests. The test_manager global allows creating
a surface whose bounds and contents can be inspected, and
connecting to the X server used by the compositor.
Upon binding to the test_manager, a display_string event is sent
containing the name of the X display.
</description>
<enum name="error">
<entry name="role_present" value="1"
summary="given wl_surface has/had another role"/>
<entry name="scale_lock_exists" value="2"
summary="another client has already locked the scale"/>
<entry name="invalid_scale" value="3"
summary="the specified scale is invalid"/>
<entry name="invalid_button" value="4"
summary="the specified button is invalid"/>
<entry name="value_exists" value="5"
summary="the specified valuator is already included"/>
<entry name="bad_seat_version" value="6"
summary="an invalid version was specified"/>
<entry name="invalid_valuator" value="7"
summary="the specified valuator is invalid"/>
</enum>
<request name="get_test_surface">
<description summary="obtain test surface role">
Get a test_surface object for a particular surface. If a role
was already attached to this surface, or a role of a different
type was previously attached, post a role_present error.
Create the window immediately after get_test_surface is
called; the window is mapped once a commit request with a
non-nil buffer is made. The window is created as an
override-redirect child of the root window, at 0, 0.
Once the window associated with the test_surface object is
mapped, send a mapped event.
</description>
<arg name="id" type="new_id" interface="test_surface"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="get_scale_lock">
<description summary="obtain scale lock">
Create a new test_scale_lock object. As long as this object
exists, set the global output scale to the scale specified in
this request (or in a subsequent test_scale_lock.set_scale
request.)
If a test_scale_lock object already exists, generate a
scale_lock_exists error.
If the scale is invalid (by being less than 0), post an
invalid_scale error.
</description>
<arg name="id" type="new_id" interface="test_scale_lock"/>
<arg name="global_scale" type="uint"/>
</request>
<request name="get_test_seat">
<description summary="obtain test seat">
Create a new seat controller object and its associated seat.
The seat will not correspond to any real input device, but
will allow artificial events to be constructed and processed.
A test_seat_controller.bind_seat request can be used to bind
to the given seat.
</description>
<arg name="id" type="new_id" interface="test_seat_controller"/>
</request>
<event name="display_string">
<description summary="X server name">
The display_string event sends the name of the X display to
clients. It is sent immediately after binding to the
test_manager object.
</description>
<arg name="name" type="string"/>
</event>
</interface>
<interface name="test_surface" version="1">
<description summary="test surface">
This role provides a test surface. Various buffers and
subsurfaces can be attached, and the resulting display contents
validated.
When a buffer is commited to a test surface, the frame callback
is run after any window configuration or resize has completed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy role">
Destroy the test_surface role. Subsequently, get_test_surface
can be called again with its surface.
</description>
</request>
<event name="mapped">
<description summary="role initialized">
The map event is sent once the window is mapped and its
contents can be retrieved. The two arguments are the XID of
the window and the name of the display it is on.
If the surface is mapped, then unmapped (by having a nil
buffer attached) and then mapped again, without waiting for
the first mapped event, the delivery of subsequent mapped
events becomes undefined.
</description>
<arg name="xid" type="uint"/>
<arg name="display_string" type="string"/>
</event>
</interface>
<interface name="test_scale_lock" version="1">
<description summary="test scale lock">
A scale lock resource represents the "lock" a client holds on
the global output scale. While it still exists, the scale for
every output will be whatever was specified when the lock was
created or by the last set_scale request.
</description>
<request name="destroy" type="destructor">
<description summary="destroy scale lock">
Destroy the specified scale lock, restore the actual scale of
each output, and let clients call get_scale_lock again.
</description>
</request>
<request name="set_scale">
<description summary="set the global output scale">
Set the scale of each output to the specified scale, and
resize all surfaces accordingly. If the scale is invalid,
post an invalid_scale error.
</description>
<arg name="scale" type="uint"/>
</request>
</interface>
<interface name="test_XIButtonState" version="1">
<description summary="XInput 2 button state">
The button state associated with an event.
</description>
<request name="destroy" type="destructor">
<description summary="destroy this resource">
Destroy the given resource.
</description>
</request>
<request name="add_button">
<description summary="add button">
Add the button with the given number to the button state. If
button is 0 or more than 8, raise an invalid_button error.
</description>
<arg name="button" type="uint"/>
</request>
<request name="remove_button">
<description summary="remove button">
Remove the button with the given number from the button state.
If button is 0 or more than 8, raise an invalid_button error.
If the button was not previously added to the button state, do
nothing.
</description>
<arg name="button" type="uint"/>
</request>
</interface>
<interface name="test_XIModifierState" version="1">
<description summary="XInput 2 modifier state">
The modifier state associated with an event.
</description>
<request name="destroy" type="destructor">
<description summary="destroy this resource">
Destroy the given resource.
</description>
</request>
<request name="set_values">
<description summary="set modifiers">
Set the modifiers in this modifier state.
</description>
<arg name="base" type="int"/>
<arg name="latched" type="int"/>
<arg name="locked" type="int"/>
<arg name="effective" type="int"/>
</request>
</interface>
<interface name="test_XIValuatorState" version="1">
<description summary="XInput 2 valuator state">
The valuator state associated with an event.
</description>
<request name="destroy" type="destructor">
<description summary="destroy this resource">
Destroy the given resource.
</description>
</request>
<request name="add_valuator">
<description summary="add a valuator">
Add a valuator with the given value to the specified valuator
state. If the value already exists, post a value_exists
error. If the valuator is more than 65535 or 0, post an
invalid_valuator error.
</description>
<arg name="valuator" type="uint"/>
<arg name="value" type="fixed"/>
</request>
</interface>
<interface name="test_seat_controller" version="1">
<description summary="test seat">
This object extends a wl_seat created with the
test_manager.get_test_seat request with several requests to
dispatch generated events.
If the seat associated with the test controller is destroyed by
the time a request is made with the test controller, the latter
request is simply ignored.
</description>
<request name="destroy" type="destructor">
<description summary="destroy test seat controller">
Destroy the test seat controller resource.
</description>
</request>
<request name="bind_seat">
<description summary="bind to the seat">
Create a wl_seat resource for this seat controller's
associated seat, with the specified version. If the version
is unsupported, raise a bad_seat_version error.
</description>
<arg name="version" type="uint"/>
<arg name="id" type="new_id" interface="wl_seat"/>
</request>
<request name="get_XIModifierState">
<description summary="obtain a test_XIModifierState">
Create a test_XIModifierState resource with all fields set to
0.
</description>
<arg name="id" type="new_id" interface="test_XIModifierState"/>
</request>
<request name="get_XIButtonState">
<description summary="obtain a test_XIButtonState">
Create a test_XIButtonState resource containing no buttons.
</description>
<arg name="id" type="new_id" interface="test_XIButtonState"/>
</request>
<request name="get_XIValuatorState">
<description summary="obtain a test_XIValuatorState">
Create a test_XIValuatorState resource containing no
valuators.
</description>
<arg name="id" type="new_id" interface="test_XIValuatorState"/>
</request>
<request name="dispatch_XI_Enter">
<description summary="dispatch entry event">
Dispatch an XI_Enter event to the seat. If buttons (or any
following field) is null, use a value comprised of 0s instead.
</description>
<arg name="time" type="uint"/>
<arg name="sourceid" type="int"/>
<arg name="detail" type="int"/>
<arg name="root" type="uint"/>
<arg name="event" type="uint"/>
<arg name="child" type="uint"/>
<arg name="root_x" type="fixed"/>
<arg name="root_y" type="fixed"/>
<arg name="event_x" type="fixed"/>
<arg name="event_y" type="fixed"/>
<arg name="mode" type="int"/>
<arg name="focus" type="int"/>
<arg name="same_screen" type="int"/>
<arg name="buttons" type="object" interface="test_XIButtonState"
allow-null="true"/>
<arg name="mods" type="object" interface="test_XIModifierState"
allow-null="true"/>
<arg name="group" type="object" interface="test_XIModifierState"
allow-null="true"/>
</request>
<request name="dispatch_XI_Leave">
<description summary="dispatch leave event">
Dispatch an XI_Leave event to the seat. If buttons (or any
following field) is null, use a value comprised of 0s instead.
</description>
<arg name="time" type="uint"/>
<arg name="sourceid" type="int"/>
<arg name="detail" type="int"/>
<arg name="root" type="uint"/>
<arg name="event" type="uint"/>
<arg name="child" type="uint"/>
<arg name="root_x" type="fixed"/>
<arg name="root_y" type="fixed"/>
<arg name="event_x" type="fixed"/>
<arg name="event_y" type="fixed"/>
<arg name="mode" type="int"/>
<arg name="focus" type="int"/>
<arg name="same_screen" type="int"/>
<arg name="buttons" type="object" interface="test_XIButtonState"
allow-null="true"/>
<arg name="mods" type="object" interface="test_XIModifierState"
allow-null="true"/>
<arg name="group" type="object" interface="test_XIModifierState"
allow-null="true"/>
</request>
<request name="dispatch_XI_Motion">
<description summary="dispatch motion event">
Dispatch an XI_Motion device event to the seat.
</description>
<arg name="time" type="uint"/>
<arg name="sourceid" type="int"/>
<arg name="detail" type="int"/>
<arg name="root" type="uint"/>
<arg name="event" type="uint"/>
<arg name="child" type="uint"/>
<arg name="root_x" type="fixed"/>
<arg name="root_y" type="fixed"/>
<arg name="event_x" type="fixed"/>
<arg name="event_y" type="fixed"/>
<arg name="flags" type="int"/>
<arg name="buttons" type="object" interface="test_XIButtonState"
allow-null="true"/>
<arg name="valuators" type="object" interface="test_XIValuatorState"
allow-null="true"/>
<arg name="mods" type="object" interface="test_XIModifierState"
allow-null="true"/>
<arg name="group" type="object" interface="test_XIModifierState"
allow-null="true"/>
</request>
<request name="dispatch_XI_ButtonPress">
<description summary="dispatch button press event">
Dispatch an XI_ButtonPress device event to the seat.
</description>
<arg name="time" type="uint"/>
<arg name="sourceid" type="int"/>
<arg name="detail" type="int"/>
<arg name="root" type="uint"/>
<arg name="event" type="uint"/>
<arg name="child" type="uint"/>
<arg name="root_x" type="fixed"/>
<arg name="root_y" type="fixed"/>
<arg name="event_x" type="fixed"/>
<arg name="event_y" type="fixed"/>
<arg name="flags" type="int"/>
<arg name="buttons" type="object" interface="test_XIButtonState"
allow-null="true"/>
<arg name="valuators" type="object" interface="test_XIValuatorState"
allow-null="true"/>
<arg name="mods" type="object" interface="test_XIModifierState"
allow-null="true"/>
<arg name="group" type="object" interface="test_XIModifierState"
allow-null="true"/>
</request>
<request name="dispatch_XI_ButtonRelease">
<description summary="dispatch button release event">
Dispatch an XI_ButtonRelease device event to the seat.
</description>
<arg name="time" type="uint"/>
<arg name="sourceid" type="int"/>
<arg name="detail" type="int"/>
<arg name="root" type="uint"/>
<arg name="event" type="uint"/>
<arg name="child" type="uint"/>
<arg name="root_x" type="fixed"/>
<arg name="root_y" type="fixed"/>
<arg name="event_x" type="fixed"/>
<arg name="event_y" type="fixed"/>
<arg name="flags" type="int"/>
<arg name="buttons" type="object" interface="test_XIButtonState"
allow-null="true"/>
<arg name="valuators" type="object" interface="test_XIValuatorState"
allow-null="true"/>
<arg name="mods" type="object" interface="test_XIModifierState"
allow-null="true"/>
<arg name="group" type="object" interface="test_XIModifierState"
allow-null="true"/>
</request>
</interface>
</protocol>