فهرست منبع

tests: port failing SDL subsystem test from pysdl2 to testautomation

Anonymous Maarten 6 ماه پیش
والد
کامیت
069eb012aa
1فایلهای تغییر یافته به همراه41 افزوده شده و 1 حذف شده
  1. 41 1
      test/testautomation_subsystems.c

+ 41 - 1
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) */