1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
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>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_test.h>
#include "testautomation_suites.h"
static SDLTest_CommonState *state;
static SDLTest_TestSuiteRunner *runner;
/* All test suites */
static SDLTest_TestSuiteReference *testSuites[] = {
&audioTestSuite,
&clipboardTestSuite,
&eventsTestSuite,
&guidTestSuite,
&hintsTestSuite,
&intrinsicsTestSuite,
&joystickTestSuite,
&keyboardTestSuite,
&logTestSuite,
&mainTestSuite,
&mathTestSuite,
&mouseTestSuite,
&pixelsTestSuite,
&platformTestSuite,
&propertiesTestSuite,
&rectTestSuite,
&renderTestSuite,
&iostrmTestSuite,
&sdltestTestSuite,
&stdlibTestSuite,
&surfaceTestSuite,
&timeTestSuite,
&timerTestSuite,
&videoTestSuite,
&blitTestSuite,
&subsystemsTestSuite, /* run last, not interfere with other test environment */
NULL
};
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
{
SDLTest_DestroyTestSuiteRunner(runner);
SDLTest_CommonQuit(state);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);
}
}
int main(int argc, char *argv[])
{
int result;
int i, done;
SDL_Event event;
int list = 0;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
if (!state) {
return 1;
}
/* No need of windows (or update testautomation_mouse.c:mouse_getMouseFocus() */
state->num_windows = 0;
runner = SDLTest_CreateTestSuiteRunner(state, testSuites);
/* Parse commandline */
for (i = 1; i < argc;) {
int consumed;
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
consumed = -1;
if (SDL_strcasecmp(argv[i], "--list") == 0) {
consumed = 1;
list = 1;
}
}
if (consumed < 0) {
static const char *options[] = {
"[--list]",
NULL };
SDLTest_CommonLogUsage(state, argv[0], options);
quit(1);
}
i += consumed;
}
/* 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%s", testCase->name, testCase->enabled ? "" : " (disabled)");
}
}
return 0;
}
/* 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 */
result = SDLTest_ExecuteTestSuiteRunner(runner);
/* Empty event queue */
done = 0;
for (i = 0; i < 100; i++) {
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
}
SDL_Delay(10);
}
/* Shutdown everything */
quit(0);
return result;
}
|