sdl (master post 3.1 preview) Merge commit 'e4f454091a943345938608570b104400f62fd625'
This commit is contained in:
236
external/sdl/SDL/test/testautomation_pen.c
vendored
236
external/sdl/SDL/test/testautomation_pen.c
vendored
@@ -19,6 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef NO_BUILD_CONFIG
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
@@ -71,10 +72,10 @@
|
||||
#define SDL_SetMouseFocus SDL_Mock_SetMouseFocus
|
||||
|
||||
/* Mock mouse API */
|
||||
static int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, int relative, float x, float y);
|
||||
static int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y);
|
||||
static int SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button);
|
||||
static SDL_Mouse *SDL_GetMouse(void);
|
||||
static SDL_bool SDL_MousePositionInWindow(SDL_Window *window, SDL_MouseID mouseID, float x, float y);
|
||||
static SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y);
|
||||
static void SDL_SetMouseFocus(SDL_Window *window);
|
||||
|
||||
/* Import SUT code with macro-renamed function names */
|
||||
@@ -87,7 +88,7 @@ static void SDL_SetMouseFocus(SDL_Window *window);
|
||||
/* Mock implementations of Pen -> Mouse calls */
|
||||
/* Not thread-safe! */
|
||||
|
||||
static SDL_bool SDL_MousePositionInWindow(SDL_Window *window, SDL_MouseID mouseID, float x, float y)
|
||||
static SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y)
|
||||
{
|
||||
return SDL_TRUE;
|
||||
}
|
||||
@@ -97,7 +98,7 @@ static float _mouseemu_last_x = 0.0f;
|
||||
static float _mouseemu_last_y = 0.0f;
|
||||
static int _mouseemu_last_mouseid = 0;
|
||||
static int _mouseemu_last_button = 0;
|
||||
static int _mouseemu_last_relative = 0;
|
||||
static SDL_bool _mouseemu_last_relative = SDL_FALSE;
|
||||
static int _mouseemu_last_focus = -1;
|
||||
|
||||
static int SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
|
||||
@@ -110,7 +111,7 @@ static int SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, int relative, float x, float y)
|
||||
static int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y)
|
||||
{
|
||||
if (mouseID == SDL_PEN_MOUSEID) {
|
||||
_mouseemu_last_event = SDL_EVENT_MOUSE_MOTION;
|
||||
@@ -126,9 +127,6 @@ static SDL_Mouse *SDL_GetMouse(void)
|
||||
{
|
||||
static SDL_Mouse dummy_mouse;
|
||||
|
||||
dummy_mouse.focus = NULL;
|
||||
dummy_mouse.mouseID = 0;
|
||||
|
||||
return &dummy_mouse;
|
||||
}
|
||||
|
||||
@@ -255,7 +253,7 @@ static void _pen_trackGCSweep(pen_testdata *tracker)
|
||||
/* Finds a number of unused pen IDs (does not allocate them). Also initialises GUIDs. */
|
||||
static void _pen_unusedIDs(pen_testdata *tracker, int count)
|
||||
{
|
||||
static int guidmod = 0; /* Ensure uniqueness as long as we use no more than 256 test pens */
|
||||
static Uint8 guidmod = 0; /* Ensure uniqueness as long as we use no more than 256 test pens */
|
||||
Uint32 synthetic_penid = 1000u;
|
||||
int index = 0;
|
||||
|
||||
@@ -270,7 +268,7 @@ static void _pen_unusedIDs(pen_testdata *tracker, int count)
|
||||
}
|
||||
tracker->ids[index] = synthetic_penid;
|
||||
for (k = 0; k < 15; ++k) {
|
||||
tracker->guids[index].data[k] = (16 * k) + index;
|
||||
tracker->guids[index].data[k] = (Uint8)((16 * k) + index);
|
||||
}
|
||||
tracker->guids[index].data[15] = ++guidmod;
|
||||
|
||||
@@ -454,7 +452,7 @@ static simulated_pen_action _simpen_event(int type, int pen_index, int index, fl
|
||||
|
||||
/* Sanity check-- turned out to be necessary */
|
||||
if ((type == SIMPEN_ACTION_PRESS || type == SIMPEN_ACTION_RELEASE) && index == 0) {
|
||||
SDL_Log("Error: SIMPEN_EVENT_BUTTON must have button > 0 (first button has number 1!), in line %d!", line_nr);
|
||||
SDL_Log("Error: SIMPEN_EVENT_BUTTON must have button > 0 (first button has number 1!), in line %d!", line_nr);
|
||||
exit(1);
|
||||
}
|
||||
return action;
|
||||
@@ -480,7 +478,7 @@ static simulated_pen_action _simpen_event(int type, int pen_index, int index, fl
|
||||
#define SIMPEN_EVENT_BUTTON(pen_index, push, button) \
|
||||
STEP _simpen_event((push) ? SIMPEN_ACTION_PRESS : SIMPEN_ACTION_RELEASE, (pen_index), (button), 0.0f, __LINE__)
|
||||
|
||||
#define SIMPEN_EVENT_TIP(pen_index, touch, tip) \
|
||||
#define SIMPEN_EVENT_TIP(pen_index, touch, tip) \
|
||||
STEP _simpen_event((touch) ? SIMPEN_ACTION_DOWN : SIMPEN_ACTION_UP, (pen_index), tip, 0.0f, __LINE__)
|
||||
|
||||
#define SIMPEN_SET_ERASER(pen_index, eraser_mode) \
|
||||
@@ -573,7 +571,7 @@ _pen_simulate(simulated_pen_action *steps, int *step_counter, SDL_Pen *simulated
|
||||
case SIMPEN_ACTION_PRESS:
|
||||
mask = (1 << (step.index - 1));
|
||||
simpen->last.buttons |= mask;
|
||||
SDLTest_AssertCheck(SDL_SendPenButton(0, simpen->header.id, SDL_PRESSED, step.index),
|
||||
SDLTest_AssertCheck(SDL_SendPenButton(0, simpen->header.id, SDL_PRESSED, (Uint8)step.index),
|
||||
"SIMPEN_ACTION_PRESS [pen %d]: button %d (mask %x)", step.pen_index, step.index, mask);
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
@@ -581,7 +579,7 @@ _pen_simulate(simulated_pen_action *steps, int *step_counter, SDL_Pen *simulated
|
||||
case SIMPEN_ACTION_RELEASE:
|
||||
mask = ~(1 << (step.index - 1));
|
||||
simpen->last.buttons &= mask;
|
||||
SDLTest_AssertCheck(SDL_SendPenButton(0, simpen->header.id, SDL_RELEASED, step.index),
|
||||
SDLTest_AssertCheck(SDL_SendPenButton(0, simpen->header.id, SDL_RELEASED, (Uint8)step.index),
|
||||
"SIMPEN_ACTION_RELEASE [pen %d]: button %d (mask %x)", step.pen_index, step.index, mask);
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
@@ -601,22 +599,22 @@ _pen_simulate(simulated_pen_action *steps, int *step_counter, SDL_Pen *simulated
|
||||
break;
|
||||
|
||||
case SIMPEN_ACTION_ERASER_MODE: {
|
||||
Uint32 pmask;
|
||||
SDL_Pen *pen = SDL_PenModifyBegin(simpen->header.id);
|
||||
Uint32 pmask;
|
||||
SDL_Pen *pen = SDL_PenModifyBegin(simpen->header.id);
|
||||
|
||||
if (step.index) {
|
||||
pmask = SDL_PEN_ERASER_MASK;
|
||||
} else {
|
||||
pmask = SDL_PEN_INK_MASK;
|
||||
}
|
||||
if (step.index) {
|
||||
pmask = SDL_PEN_ERASER_MASK;
|
||||
} else {
|
||||
pmask = SDL_PEN_INK_MASK;
|
||||
}
|
||||
|
||||
SDL_PenModifyAddCapabilities(pen, pmask);
|
||||
SDL_PenModifyEnd(pen, SDL_TRUE);
|
||||
SDL_PenModifyAddCapabilities(pen, pmask);
|
||||
SDL_PenModifyEnd(pen, SDL_TRUE);
|
||||
|
||||
simpen->header.flags &= ~(SDL_PEN_INK_MASK | SDL_PEN_ERASER_MASK);
|
||||
simpen->header.flags |= pmask;
|
||||
break;
|
||||
}
|
||||
simpen->header.flags &= ~(SDL_PEN_INK_MASK | SDL_PEN_ERASER_MASK);
|
||||
simpen->header.flags |= pmask;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
SDLTest_AssertCheck(0,
|
||||
@@ -1046,40 +1044,40 @@ pen_buttonReporting(void *arg)
|
||||
|
||||
for (pen_nr = 0; pen_nr < 2; ++pen_nr) {
|
||||
float *expected_axes = axes + pen_nr;
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
Uint16 pen_state = 0x0000 | SDL_PEN_DOWN_MASK;
|
||||
Uint8 tip = SDL_PEN_TIP_INK;
|
||||
Uint8 tip = SDL_PEN_TIP_INK;
|
||||
|
||||
if (pen_nr == 1) {
|
||||
pen_state |= SDL_PEN_ERASER_MASK;
|
||||
tip = SDL_PEN_TIP_ERASER;
|
||||
tip = SDL_PEN_TIP_ERASER;
|
||||
}
|
||||
|
||||
SDL_SendPenTipEvent(0, ptest.ids[pen_nr], SDL_PRESSED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[pen_nr], SDL_PRESSED);
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_DOWN) {
|
||||
SDLTest_AssertCheck(event.ptip.which == ptest.ids[pen_nr],
|
||||
"Received SDL_EVENT_PEN_DOWN from correct pen");
|
||||
SDLTest_AssertCheck(event.ptip.tip == (pen_nr == 0)? SDL_PEN_TIP_INK : SDL_PEN_TIP_ERASER,
|
||||
"Received SDL_EVENT_PEN_DOWN for correct tip");
|
||||
SDLTest_AssertCheck(event.ptip.state == SDL_PRESSED,
|
||||
"Received SDL_EVENT_PEN_DOWN but and marked SDL_PRESSED");
|
||||
SDLTest_AssertCheck(event.ptip.tip == tip,
|
||||
"Received tip %x but expected %x", event.ptip.tip, tip);
|
||||
SDLTest_AssertCheck(event.ptip.pen_state == pen_state,
|
||||
"Received SDL_EVENT_PEN_DOWN, and state %04x == %04x (expected)",
|
||||
event.pbutton.pen_state, pen_state);
|
||||
SDLTest_AssertCheck((event.ptip.x == expected_x[pen_nr]) && (event.ptip.y == expected_y[pen_nr]),
|
||||
"Received SDL_EVENT_PEN_DOWN event at correct coordinates: (%f, %f) vs (%f, %f) (expected)",
|
||||
event.pbutton.x, event.pbutton.y, expected_x[pen_nr], expected_y[pen_nr]);
|
||||
SDLTest_AssertCheck(0 == SDL_memcmp(expected_axes, event.pbutton.axes, sizeof(float) * SDL_PEN_NUM_AXES),
|
||||
"Received SDL_EVENT_PEN_DOWN event with correct axis values");
|
||||
found_event = SDL_TRUE;
|
||||
}
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_DOWN) {
|
||||
SDLTest_AssertCheck(event.ptip.which == ptest.ids[pen_nr],
|
||||
"Received SDL_EVENT_PEN_DOWN from correct pen");
|
||||
SDLTest_AssertCheck(event.ptip.tip == (pen_nr == 0)? SDL_PEN_TIP_INK : SDL_PEN_TIP_ERASER,
|
||||
"Received SDL_EVENT_PEN_DOWN for correct tip");
|
||||
SDLTest_AssertCheck(event.ptip.state == SDL_PRESSED,
|
||||
"Received SDL_EVENT_PEN_DOWN but and marked SDL_PRESSED");
|
||||
SDLTest_AssertCheck(event.ptip.tip == tip,
|
||||
"Received tip %x but expected %x", event.ptip.tip, tip);
|
||||
SDLTest_AssertCheck(event.ptip.pen_state == pen_state,
|
||||
"Received SDL_EVENT_PEN_DOWN, and state %04x == %04x (expected)",
|
||||
event.pbutton.pen_state, pen_state);
|
||||
SDLTest_AssertCheck((event.ptip.x == expected_x[pen_nr]) && (event.ptip.y == expected_y[pen_nr]),
|
||||
"Received SDL_EVENT_PEN_DOWN event at correct coordinates: (%f, %f) vs (%f, %f) (expected)",
|
||||
event.pbutton.x, event.pbutton.y, expected_x[pen_nr], expected_y[pen_nr]);
|
||||
SDLTest_AssertCheck(0 == SDL_memcmp(expected_axes, event.pbutton.axes, sizeof(float) * SDL_PEN_NUM_AXES),
|
||||
"Received SDL_EVENT_PEN_DOWN event with correct axis values");
|
||||
found_event = SDL_TRUE;
|
||||
}
|
||||
SDLTest_AssertCheck(found_event,
|
||||
"Received the expected SDL_EVENT_PEN_DOWN event");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDLTest_AssertPass("Pen and eraser set up for button testing");
|
||||
@@ -1096,7 +1094,7 @@ pen_buttonReporting(void *arg)
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
pen_state |= (1 << (button_nr - 1));
|
||||
|
||||
SDL_SendPenButton(0, ptest.ids[pen_nr], SDL_PRESSED, button_nr);
|
||||
SDL_SendPenButton(0, ptest.ids[pen_nr], SDL_PRESSED, (Uint8)button_nr);
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_BUTTON_DOWN) {
|
||||
SDLTest_AssertCheck(event.pbutton.which == ptest.ids[pen_nr],
|
||||
@@ -1143,7 +1141,7 @@ pen_buttonReporting(void *arg)
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
pen_state &= ~(1 << (button_nr - 1));
|
||||
|
||||
SDL_SendPenButton(0, ptest.ids[pen_nr], SDL_RELEASED, button_nr);
|
||||
SDL_SendPenButton(0, ptest.ids[pen_nr], SDL_RELEASED, (Uint8)button_nr);
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_BUTTON_UP) {
|
||||
SDLTest_AssertCheck(event.pbutton.which == ptest.ids[pen_nr],
|
||||
@@ -1173,40 +1171,40 @@ pen_buttonReporting(void *arg)
|
||||
|
||||
for (pen_nr = 0; pen_nr < 2; ++pen_nr) {
|
||||
float *expected_axes = axes + pen_nr;
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
SDL_bool found_event = SDL_FALSE;
|
||||
Uint16 pen_state = 0x0000;
|
||||
Uint8 tip = SDL_PEN_TIP_INK;
|
||||
Uint8 tip = SDL_PEN_TIP_INK;
|
||||
|
||||
if (pen_nr == 1) {
|
||||
pen_state |= SDL_PEN_ERASER_MASK;
|
||||
tip = SDL_PEN_TIP_ERASER;
|
||||
tip = SDL_PEN_TIP_ERASER;
|
||||
}
|
||||
|
||||
SDL_SendPenTipEvent(0, ptest.ids[pen_nr], SDL_RELEASED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[pen_nr], SDL_RELEASED);
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_UP) {
|
||||
SDLTest_AssertCheck(event.ptip.which == ptest.ids[pen_nr],
|
||||
"Received SDL_EVENT_PEN_UP from correct pen");
|
||||
SDLTest_AssertCheck(event.ptip.tip == (pen_nr == 0)? SDL_PEN_TIP_INK : SDL_PEN_TIP_ERASER,
|
||||
"Received SDL_EVENT_PEN_UP for correct tip");
|
||||
SDLTest_AssertCheck(event.ptip.state == SDL_RELEASED,
|
||||
"Received SDL_EVENT_PEN_UP but and marked SDL_RELEASED");
|
||||
SDLTest_AssertCheck(event.ptip.tip == tip,
|
||||
"Received tip %x but expected %x", event.ptip.tip, tip);
|
||||
SDLTest_AssertCheck((event.ptip.pen_state & 0xff00) == (pen_state & 0xff00),
|
||||
"Received SDL_EVENT_PEN_UP, and state %04x == %04x (expected)",
|
||||
event.pbutton.pen_state, pen_state);
|
||||
SDLTest_AssertCheck((event.ptip.x == expected_x[pen_nr]) && (event.ptip.y == expected_y[pen_nr]),
|
||||
"Received SDL_EVENT_PEN_UP event at correct coordinates: (%f, %f) vs (%f, %f) (expected)",
|
||||
event.pbutton.x, event.pbutton.y, expected_x[pen_nr], expected_y[pen_nr]);
|
||||
SDLTest_AssertCheck(0 == SDL_memcmp(expected_axes, event.pbutton.axes, sizeof(float) * SDL_PEN_NUM_AXES),
|
||||
"Received SDL_EVENT_PEN_UP event with correct axis values");
|
||||
found_event = SDL_TRUE;
|
||||
}
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_PEN_UP) {
|
||||
SDLTest_AssertCheck(event.ptip.which == ptest.ids[pen_nr],
|
||||
"Received SDL_EVENT_PEN_UP from correct pen");
|
||||
SDLTest_AssertCheck(event.ptip.tip == (pen_nr == 0)? SDL_PEN_TIP_INK : SDL_PEN_TIP_ERASER,
|
||||
"Received SDL_EVENT_PEN_UP for correct tip");
|
||||
SDLTest_AssertCheck(event.ptip.state == SDL_RELEASED,
|
||||
"Received SDL_EVENT_PEN_UP but and marked SDL_RELEASED");
|
||||
SDLTest_AssertCheck(event.ptip.tip == tip,
|
||||
"Received tip %x but expected %x", event.ptip.tip, tip);
|
||||
SDLTest_AssertCheck((event.ptip.pen_state & 0xff00) == (pen_state & 0xff00),
|
||||
"Received SDL_EVENT_PEN_UP, and state %04x == %04x (expected)",
|
||||
event.pbutton.pen_state, pen_state);
|
||||
SDLTest_AssertCheck((event.ptip.x == expected_x[pen_nr]) && (event.ptip.y == expected_y[pen_nr]),
|
||||
"Received SDL_EVENT_PEN_UP event at correct coordinates: (%f, %f) vs (%f, %f) (expected)",
|
||||
event.pbutton.x, event.pbutton.y, expected_x[pen_nr], expected_y[pen_nr]);
|
||||
SDLTest_AssertCheck(0 == SDL_memcmp(expected_axes, event.pbutton.axes, sizeof(float) * SDL_PEN_NUM_AXES),
|
||||
"Received SDL_EVENT_PEN_UP event with correct axis values");
|
||||
found_event = SDL_TRUE;
|
||||
}
|
||||
SDLTest_AssertCheck(found_event,
|
||||
"Received the expected SDL_EVENT_PEN_UP event");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
@@ -1342,10 +1340,10 @@ pen_movementAndAxes(void *arg)
|
||||
|
||||
_pen_simulate_init(&ptest, simulated_pens, 2);
|
||||
/* Simulate pen movements */
|
||||
while ((last_action = _pen_simulate(steps, &sim_pc, &simulated_pens[0], 2))) {
|
||||
while ((last_action = _pen_simulate(steps, &sim_pc, &simulated_pens[0], 2)) != 0) {
|
||||
int attempts = 0;
|
||||
SDL_Pen *simpen = &simulated_pens[last_action->pen_index];
|
||||
SDL_PenID reported_which = -1;
|
||||
SDL_PenID reported_which = 0;
|
||||
float reported_x = -1.0f, reported_y = -1.0f;
|
||||
float *reported_axes = NULL;
|
||||
Uint32 reported_pen_state = 0;
|
||||
@@ -1360,8 +1358,8 @@ pen_movementAndAxes(void *arg)
|
||||
return TEST_ABORTED;
|
||||
}
|
||||
} while (event.type != SDL_EVENT_PEN_DOWN
|
||||
&& event.type != SDL_EVENT_PEN_UP
|
||||
&& event.type != SDL_EVENT_PEN_MOTION
|
||||
&& event.type != SDL_EVENT_PEN_UP
|
||||
&& event.type != SDL_EVENT_PEN_MOTION
|
||||
&& event.type != SDL_EVENT_PEN_BUTTON_UP
|
||||
&& event.type != SDL_EVENT_PEN_BUTTON_DOWN); /* skip boring events */
|
||||
|
||||
@@ -1383,7 +1381,7 @@ pen_movementAndAxes(void *arg)
|
||||
case SIMPEN_ACTION_PRESS:
|
||||
SDLTest_AssertCheck(event.type == SDL_EVENT_PEN_BUTTON_DOWN, "Expected PENBUTTONDOWN event (but got 0x%lx)", (unsigned long) event.type);
|
||||
SDLTest_AssertCheck(event.pbutton.state == SDL_PRESSED, "Expected PRESSED button");
|
||||
/* Fall through */
|
||||
SDL_FALLTHROUGH;
|
||||
case SIMPEN_ACTION_RELEASE:
|
||||
if (last_action->type == SIMPEN_ACTION_RELEASE) {
|
||||
SDLTest_AssertCheck(event.type == SDL_EVENT_PEN_BUTTON_UP, "Expected PENBUTTONUP event (but got 0x%lx)", (unsigned long) event.type);
|
||||
@@ -1401,7 +1399,7 @@ pen_movementAndAxes(void *arg)
|
||||
case SIMPEN_ACTION_DOWN:
|
||||
SDLTest_AssertCheck(event.type == SDL_EVENT_PEN_DOWN, "Expected PENBUTTONDOWN event (but got 0x%lx)", (unsigned long) event.type);
|
||||
SDLTest_AssertCheck(event.ptip.state == SDL_PRESSED, "Expected PRESSED button");
|
||||
/* Fall through */
|
||||
SDL_FALLTHROUGH;
|
||||
case SIMPEN_ACTION_UP:
|
||||
if (last_action->type == SIMPEN_ACTION_UP) {
|
||||
SDLTest_AssertCheck(event.type == SDL_EVENT_PEN_UP, "Expected PENBUTTONUP event (but got 0x%lx)", (unsigned long) event.type);
|
||||
@@ -1417,7 +1415,7 @@ pen_movementAndAxes(void *arg)
|
||||
break;
|
||||
|
||||
case SIMPEN_ACTION_ERASER_MODE:
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
SDLTest_AssertCheck(0, "Error in pen simulator: unexpected action %d", last_action->type);
|
||||
@@ -1728,7 +1726,7 @@ pen_mouseEmulation(void *arg)
|
||||
_penmouse_expect_button(SDL_PRESSED, 1);
|
||||
|
||||
for (i = 1; i <= 3; ++i) {
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, (Uint8)i);
|
||||
_penmouse_expect_button(SDL_PRESSED, i + 1);
|
||||
}
|
||||
SDLTest_AssertPass("Button press mouse emulation");
|
||||
@@ -1738,7 +1736,7 @@ pen_mouseEmulation(void *arg)
|
||||
_penmouse_expect_button(SDL_RELEASED, 1);
|
||||
|
||||
for (i = 1; i <= 3; ++i) {
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, (Uint8)i);
|
||||
_penmouse_expect_button(SDL_RELEASED, i + 1);
|
||||
}
|
||||
SDLTest_AssertPass("Button release mouse emulation");
|
||||
@@ -1800,10 +1798,10 @@ pen_mouseEmulationDelayed(void *arg)
|
||||
|
||||
/* Test button press reporting */
|
||||
for (i = 1; i <= 2; ++i) {
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button press suppressed: %d", _mouseemu_last_event);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button release suppressed: %d", _mouseemu_last_event);
|
||||
}
|
||||
@@ -1816,16 +1814,16 @@ pen_mouseEmulationDelayed(void *arg)
|
||||
|
||||
/* Test button press reporting, releasing extra button AFTER lifting pen */
|
||||
for (i = 1; i <= 2; ++i) {
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button press suppressed (A.1): %d", _mouseemu_last_event);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_PRESSED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_PRESSED);
|
||||
_penmouse_expect_button(SDL_PRESSED, i + 1);
|
||||
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_RELEASED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_RELEASED);
|
||||
_penmouse_expect_button(SDL_RELEASED, i + 1);
|
||||
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button press suppressed (A.2): %d", _mouseemu_last_event);
|
||||
}
|
||||
@@ -1833,16 +1831,16 @@ pen_mouseEmulationDelayed(void *arg)
|
||||
|
||||
/* Test button press reporting, releasing extra button BEFORE lifting pen */
|
||||
for (i = 1; i <= 2; ++i) {
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_PRESSED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button press suppressed (B.1): %d", _mouseemu_last_event);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_PRESSED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_PRESSED);
|
||||
_penmouse_expect_button(SDL_PRESSED, i + 1);
|
||||
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, i);
|
||||
SDL_SendPenButton(0, ptest.ids[0], SDL_RELEASED, (Uint8)i);
|
||||
SDLTest_AssertCheck(0 == _mouseemu_last_event,
|
||||
"Non-touching button press suppressed (B.2): %d", _mouseemu_last_event);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_RELEASED);
|
||||
SDL_SendPenTipEvent(0, ptest.ids[0], SDL_RELEASED);
|
||||
_penmouse_expect_button(SDL_RELEASED, i + 1);
|
||||
}
|
||||
SDLTest_AssertPass("Delayed button press mouse emulation, touching and then releasing button");
|
||||
@@ -1860,11 +1858,11 @@ pen_mouseEmulationDelayed(void *arg)
|
||||
static int
|
||||
pen_memoryLayout(void *arg)
|
||||
{
|
||||
#define LAYOUT_COMPATIBLE(field) \
|
||||
#define LAYOUT_COMPATIBLE(field) \
|
||||
SDLTest_AssertCheck(offsetof(SDL_PenTipEvent, field) == offsetof(SDL_PenMotionEvent, field), \
|
||||
"Memory layout SDL_PenTipEvent and SDL_PenMotionEvent compatibility: '" #field "'"); \
|
||||
"Memory layout SDL_PenTipEvent and SDL_PenMotionEvent compatibility: '" #field "'"); \
|
||||
SDLTest_AssertCheck(offsetof(SDL_PenTipEvent, field) == offsetof(SDL_PenButtonEvent, field), \
|
||||
"Memory layout SDL_PenTipEvent and SDL_PenBUttonEvent compatibility: '" #field "'");
|
||||
"Memory layout SDL_PenTipEvent and SDL_PenBUttonEvent compatibility: '" #field "'");
|
||||
|
||||
LAYOUT_COMPATIBLE(which);
|
||||
LAYOUT_COMPATIBLE(x);
|
||||
@@ -1874,9 +1872,21 @@ pen_memoryLayout(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test Setup and Teardown ================== */
|
||||
|
||||
static void
|
||||
pen_test_setup(void *arg) {
|
||||
SDL_PenInit();
|
||||
}
|
||||
|
||||
static void
|
||||
pen_test_teardown(void *arg) {
|
||||
SDL_PenQuit();
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Mouse test cases */
|
||||
/* Pen test cases */
|
||||
static const SDLTest_TestCaseReference penTest1 = { (SDLTest_TestCaseFp)pen_iteration, "pen_iteration", "Iterate over all pens with SDL_PenIDForIndex", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference penTest2 = { (SDLTest_TestCaseFp)pen_hotplugging, "pen_hotplugging", "Hotplug pens and validate their status, including SDL_PenConnected", TEST_ENABLED };
|
||||
@@ -1895,11 +1905,29 @@ static const SDLTest_TestCaseReference penTest8 = { (SDLTest_TestCaseFp)pen_mous
|
||||
|
||||
static const SDLTest_TestCaseReference penTest9 = { (SDLTest_TestCaseFp)pen_memoryLayout, "pen_memoryLayout", "Check that all pen events have compatible layout (required by SDL_pen.c)", TEST_ENABLED };
|
||||
|
||||
/* Sequence of Mouse test cases */
|
||||
/* Sequence of Pen test cases */
|
||||
static const SDLTest_TestCaseReference *penTests[] = {
|
||||
&penTest1, &penTest2, &penTest3, &penTest4, &penTest5, &penTest6, &penTest7, &penTest8, &penTest9, NULL
|
||||
};
|
||||
|
||||
/* Pen test suite (global) */
|
||||
SDLTest_TestSuiteReference penTestSuite = {
|
||||
"Pen",
|
||||
(SDLTest_TestCaseSetUpFp)pen_test_setup,
|
||||
penTests,
|
||||
(SDLTest_TestCaseTearDownFp)pen_test_teardown
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
/* Sequence of Mouse test cases */
|
||||
static const SDLTest_TestCaseReference *penTests[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Mouse test suite (global) */
|
||||
SDLTest_TestSuiteReference penTestSuite = {
|
||||
"Pen",
|
||||
@@ -1907,3 +1935,5 @@ SDLTest_TestSuiteReference penTestSuite = {
|
||||
penTests,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user