sdl2-compat: tests: port failing SDL subsystem test from pysdl2 to testautomation

From 2526bc79800da68b457c2c027023ff17b04c5920 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 15 Mar 2025 02:04:04 +0100
Subject: [PATCH] tests: port failing SDL subsystem test from pysdl2 to
 testautomation

---
 test/testautomation_subsystems.c | 42 +++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/test/testautomation_subsystems.c b/test/testautomation_subsystems.c
index 73eaca2f..dc08f1d3 100644
--- a/test/testautomation_subsystems.c
+++ b/test/testautomation_subsystems.c
@@ -208,6 +208,42 @@ static int subsystems_dependRefCountWithExtraInit(void)
     return TEST_COMPLETED;
 }
 
+
+/**
+ * \brief Inits and Quits timers subsystem, which cannot be explicitly initialized in SDL3
+ *
+ * \sa SDL_InitSubSystem
+ * \sa SDL_QuitSubSystem
+ *
+ */
+static int subsystems_timersSubsystem(void)
+{
+    int result;
+    /* Ensure that we start with reset subsystems. */
+    SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0,
+                        "Check result from SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)");
+
+    SDLTest_AssertPass("About to call SDL_WasInit(0)");
+    result = SDL_WasInit(0);
+    SDLTest_AssertCheck(result == 0, "SDL_WasInit(0) should return 0, actual 0x%x", result);
+
+    SDLTest_AssertPass("About to call SDL_InitSubSystem(SDL_INIT_TIMER)");
+    result = SDL_InitSubSystem(SDL_INIT_TIMER);
+    SDLTest_AssertCheck(result == 0, "Must return 0, actually %d", result);
+    SDLTest_AssertPass("About to call SDL_WasInit(SDL_INIT_TIMER)");
+    result = SDL_WasInit(SDL_INIT_TIMER);
+    SDLTest_AssertCheck(result == SDL_INIT_TIMER, "Must return SDL_INIT_TIMER (=%d), actually %d", SDL_INIT_TIMER, result);
+    SDLTest_AssertPass("About to call SDL_WasInit(0)");
+    result = SDL_WasInit(0);
+    SDLTest_AssertCheck(result == SDL_INIT_TIMER, "SDL_WasInit(0) should return SDL_INIT_TIMER, actual 0x%x", result);
+
+    SDLTest_AssertPass("About to call SDL_QuitSubSystem(SDL_INIT_TIMER)");
+    SDL_QuitSubSystem(SDL_INIT_TIMER);
+    SDLTest_AssertPass("SDL_QuitSubSystem finished");
+
+    return TEST_COMPLETED;
+}
+
 /* ================= Test References ================== */
 
 /* Subsystems test cases */
@@ -227,9 +263,13 @@ static const SDLTest_TestCaseReference subsystemsTest4 = {
     (SDLTest_TestCaseFp)subsystems_dependRefCountWithExtraInit, "subsystems_dependRefCountWithExtraInit", "Check reference count of subsystem dependencies.", TEST_ENABLED
 };
 
+static const SDLTest_TestCaseReference subsystemsTest5 = {
+    (SDLTest_TestCaseFp)subsystems_timersSubsystem, "subsystems_timersSubsystem", "Check timer subsystem, removed in SDL3.", TEST_ENABLED
+};
+
 /* Sequence of Events test cases */
 static const SDLTest_TestCaseReference *subsystemsTests[] = {
-    &subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, NULL
+    &subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, &subsystemsTest5, NULL
 };
 
 /* Events test suite (global) */