Skip to content

Commit 069eb01

Browse files
committed
tests: port failing SDL subsystem test from pysdl2 to testautomation
1 parent 7d8a6f1 commit 069eb01

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

test/testautomation_subsystems.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,42 @@ static int subsystems_dependRefCountWithExtraInit(void)
208208
return TEST_COMPLETED;
209209
}
210210

211+
212+
/**
213+
* \brief Inits and Quits timers subsystem, which cannot be explicitly initialized in SDL3
214+
*
215+
* \sa SDL_InitSubSystem
216+
* \sa SDL_QuitSubSystem
217+
*
218+
*/
219+
static int subsystems_timersSubsystem(void)
220+
{
221+
int result;
222+
/* Ensure that we start with reset subsystems. */
223+
SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0,
224+
"Check result from SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)");
225+
226+
SDLTest_AssertPass("About to call SDL_WasInit(0)");
227+
result = SDL_WasInit(0);
228+
SDLTest_AssertCheck(result == 0, "SDL_WasInit(0) should return 0, actual 0x%x", result);
229+
230+
SDLTest_AssertPass("About to call SDL_InitSubSystem(SDL_INIT_TIMER)");
231+
result = SDL_InitSubSystem(SDL_INIT_TIMER);
232+
SDLTest_AssertCheck(result == 0, "Must return 0, actually %d", result);
233+
SDLTest_AssertPass("About to call SDL_WasInit(SDL_INIT_TIMER)");
234+
result = SDL_WasInit(SDL_INIT_TIMER);
235+
SDLTest_AssertCheck(result == SDL_INIT_TIMER, "Must return SDL_INIT_TIMER (=%d), actually %d", SDL_INIT_TIMER, result);
236+
SDLTest_AssertPass("About to call SDL_WasInit(0)");
237+
result = SDL_WasInit(0);
238+
SDLTest_AssertCheck(result == SDL_INIT_TIMER, "SDL_WasInit(0) should return SDL_INIT_TIMER, actual 0x%x", result);
239+
240+
SDLTest_AssertPass("About to call SDL_QuitSubSystem(SDL_INIT_TIMER)");
241+
SDL_QuitSubSystem(SDL_INIT_TIMER);
242+
SDLTest_AssertPass("SDL_QuitSubSystem finished");
243+
244+
return TEST_COMPLETED;
245+
}
246+
211247
/* ================= Test References ================== */
212248

213249
/* Subsystems test cases */
@@ -227,9 +263,13 @@ static const SDLTest_TestCaseReference subsystemsTest4 = {
227263
(SDLTest_TestCaseFp)subsystems_dependRefCountWithExtraInit, "subsystems_dependRefCountWithExtraInit", "Check reference count of subsystem dependencies.", TEST_ENABLED
228264
};
229265

266+
static const SDLTest_TestCaseReference subsystemsTest5 = {
267+
(SDLTest_TestCaseFp)subsystems_timersSubsystem, "subsystems_timersSubsystem", "Check timer subsystem, removed in SDL3.", TEST_ENABLED
268+
};
269+
230270
/* Sequence of Events test cases */
231271
static const SDLTest_TestCaseReference *subsystemsTests[] = {
232-
&subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, NULL
272+
&subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, &subsystemsTest5, NULL
233273
};
234274

235275
/* Events test suite (global) */

0 commit comments

Comments
 (0)