2015-06-21 18:33:46 +03:00
|
|
|
/*
|
2024-01-02 00:15:26 +03:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2022-11-27 07:43:38 +03:00
|
|
|
#include <SDL3/SDL.h>
|
2022-12-15 07:58:20 +03:00
|
|
|
#include <SDL3/SDL_main.h>
|
2022-11-27 07:43:38 +03:00
|
|
|
#include <SDL3/SDL_test.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
#include "testautomation_suites.h"
|
|
|
|
|
|
|
|
static SDLTest_CommonState *state;
|
|
|
|
|
2023-03-08 18:41:36 +03:00
|
|
|
/* All test suites */
|
|
|
|
static SDLTest_TestSuiteReference *testSuites[] = {
|
|
|
|
&audioTestSuite,
|
|
|
|
&clipboardTestSuite,
|
|
|
|
&eventsTestSuite,
|
|
|
|
&guidTestSuite,
|
|
|
|
&hintsTestSuite,
|
2023-03-19 09:13:46 +03:00
|
|
|
&intrinsicsTestSuite,
|
2023-03-08 18:41:36 +03:00
|
|
|
&joystickTestSuite,
|
|
|
|
&keyboardTestSuite,
|
|
|
|
&mainTestSuite,
|
|
|
|
&mathTestSuite,
|
|
|
|
&mouseTestSuite,
|
API for pressure-sensitive pens + XInput2/Wayland
This patch adds an API for querying pressure-
sensitive pens, cf. SDL_pen.h:
- Enumerate all pens
- Get pen capabilities, names, GUIDs
- Distinguishes pens and erasers
- Distinguish attached and detached pens
- Pressure and tilt support
- Rotation, distance, throttle wheel support
(throttle wheel untested)
- Pen type and meta-information reporting
(partially tested)
Pen event reporting:
- Three new event structures: PenTip, PenMotion, and
PenButton
- Report location with sub-pixel precision
- Include axis and button status, is-eraser flag
Internal pen tracker, intended to be independent
of platform APIs, cf. SDL_pen_c.h:
- Track known pens
- Handle pen hotplugging
Automatic test:
- testautomation_pen.c
Other features:
- XInput2 implementation, incl. hotplugging
- Wayland implementation, incl. hotplugging
- Backward compatibility: pen events default to
emulating pens with mouse ID SDL_PEN_MOUSEID
- Can be toggled via SDL_HINT_PEN_NOT_MOUSE
- Test/demo program (testpen)
- Wacom pen feature identification by pen ID
Acknowledgements:
- Ping Cheng (Wacom) provided extensive feedback
on Wacom pen features and detection so that
hopefully untested Wacom devices have a
realistic chance of working out of the box.
2023-08-27 09:20:29 +03:00
|
|
|
&penTestSuite,
|
2023-03-08 18:41:36 +03:00
|
|
|
&pixelsTestSuite,
|
|
|
|
&platformTestSuite,
|
2023-10-10 22:38:22 +03:00
|
|
|
&propertiesTestSuite,
|
2023-03-08 18:41:36 +03:00
|
|
|
&rectTestSuite,
|
|
|
|
&renderTestSuite,
|
|
|
|
&rwopsTestSuite,
|
|
|
|
&sdltestTestSuite,
|
|
|
|
&stdlibTestSuite,
|
|
|
|
&surfaceTestSuite,
|
|
|
|
&timerTestSuite,
|
|
|
|
&videoTestSuite,
|
2023-10-13 19:43:18 +03:00
|
|
|
&subsystemsTestSuite, /* run last, not interfere with other test enviroment */
|
2023-03-08 18:41:36 +03:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
|
|
|
static void
|
|
|
|
quit(int rc)
|
|
|
|
{
|
|
|
|
SDLTest_CommonQuit(state);
|
2023-04-12 12:07:28 +03:00
|
|
|
/* Let 'main()' return normally */
|
|
|
|
if (rc != 0) {
|
|
|
|
exit(rc);
|
|
|
|
}
|
2015-06-21 18:33:46 +03:00
|
|
|
}
|
|
|
|
|
2022-11-30 23:51:59 +03:00
|
|
|
int main(int argc, char *argv[])
|
2015-06-21 18:33:46 +03:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
int testIterations = 1;
|
|
|
|
Uint64 userExecKey = 0;
|
|
|
|
char *userRunSeed = NULL;
|
|
|
|
char *filter = NULL;
|
|
|
|
int i, done;
|
|
|
|
SDL_Event event;
|
2023-01-16 12:50:52 +03:00
|
|
|
int list = 0;
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
/* Initialize test framework */
|
2023-03-27 11:20:34 +03:00
|
|
|
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
2023-11-10 00:29:15 +03:00
|
|
|
if (!state) {
|
2015-06-21 18:33:46 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-03-20 23:43:24 +03:00
|
|
|
/* No need of windows (or update testautomation_mouse.c:mouse_getMouseFocus() */
|
|
|
|
state->num_windows = 0;
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
/* Parse commandline */
|
|
|
|
for (i = 1; i < argc;) {
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
|
|
if (consumed == 0) {
|
|
|
|
consumed = -1;
|
|
|
|
if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
|
|
|
|
if (argv[i + 1]) {
|
|
|
|
testIterations = SDL_atoi(argv[i + 1]);
|
2022-11-27 19:38:43 +03:00
|
|
|
if (testIterations < 1) {
|
|
|
|
testIterations = 1;
|
|
|
|
}
|
2015-06-21 18:33:46 +03:00
|
|
|
consumed = 2;
|
|
|
|
}
|
2022-11-27 19:38:43 +03:00
|
|
|
} else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
|
2015-06-21 18:33:46 +03:00
|
|
|
if (argv[i + 1]) {
|
2022-12-02 00:07:03 +03:00
|
|
|
(void)SDL_sscanf(argv[i + 1], "%" SDL_PRIu64, &userExecKey);
|
2015-06-21 18:33:46 +03:00
|
|
|
consumed = 2;
|
|
|
|
}
|
2022-11-27 19:38:43 +03:00
|
|
|
} else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
|
2015-06-21 18:33:46 +03:00
|
|
|
if (argv[i + 1]) {
|
|
|
|
userRunSeed = SDL_strdup(argv[i + 1]);
|
|
|
|
consumed = 2;
|
|
|
|
}
|
2022-11-27 19:38:43 +03:00
|
|
|
} else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
|
2015-06-21 18:33:46 +03:00
|
|
|
if (argv[i + 1]) {
|
|
|
|
filter = SDL_strdup(argv[i + 1]);
|
|
|
|
consumed = 2;
|
|
|
|
}
|
2023-01-16 12:50:52 +03:00
|
|
|
} else if (SDL_strcasecmp(argv[i], "--list") == 0) {
|
|
|
|
consumed = 1;
|
|
|
|
list = 1;
|
2015-06-21 18:33:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consumed < 0) {
|
2023-01-16 12:50:52 +03:00
|
|
|
static const char *options[] = { "[--iterations #]", "[--execKey #]", "[--seed string]", "[--filter suite_name|test_name]", "[--list]", NULL };
|
2019-05-29 00:39:13 +03:00
|
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
2015-06-21 18:33:46 +03:00
|
|
|
quit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
i += consumed;
|
|
|
|
}
|
|
|
|
|
2023-01-16 12:50:52 +03:00
|
|
|
/* List all suites. */
|
|
|
|
if (list) {
|
|
|
|
int suiteCounter;
|
|
|
|
for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) {
|
|
|
|
int testCounter;
|
|
|
|
SDLTest_TestSuiteReference *testSuite = testSuites[suiteCounter];
|
|
|
|
SDL_Log("Test suite: %s", testSuite->name);
|
|
|
|
for (testCounter = 0; testSuite->testCases[testCounter]; ++testCounter) {
|
|
|
|
const SDLTest_TestCaseReference *testCase = testSuite->testCases[testCounter];
|
|
|
|
SDL_Log(" test: %s", testCase->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
/* Initialize common state */
|
|
|
|
if (!SDLTest_CommonInit(state)) {
|
|
|
|
quit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the windows, initialize the renderers */
|
|
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
|
|
SDL_Renderer *renderer = state->renderers[i];
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
|
|
|
SDL_RenderClear(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call Harness */
|
2022-06-18 16:52:46 +03:00
|
|
|
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, filter, testIterations);
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
/* Empty event queue */
|
|
|
|
done = 0;
|
2022-11-30 23:51:59 +03:00
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
|
|
SDLTest_CommonEvent(state, &event, &done);
|
|
|
|
}
|
|
|
|
SDL_Delay(10);
|
2015-06-21 18:33:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up */
|
|
|
|
SDL_free(userRunSeed);
|
|
|
|
SDL_free(filter);
|
|
|
|
|
|
|
|
/* Shutdown everything */
|
2023-04-14 13:25:01 +03:00
|
|
|
quit(0);
|
2022-11-27 19:38:43 +03:00
|
|
|
return result;
|
2015-06-21 18:33:46 +03:00
|
|
|
}
|