sdl2-compat: Sync automated video tests with SDL2, sdl3_include_wrapper.h with SDL3.

From 882cb7d8182e70d89b4d798475ea75f20d645f20 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 11 Oct 2023 11:51:28 +0300
Subject: [PATCH] Sync automated video tests with SDL2, sdl3_include_wrapper.h
 with SDL3.

---
 src/sdl3_include_wrapper.h  |  5 ++++
 test/testautomation_mouse.c | 50 +++++++++++++++++++++----------------
 test/testfilesystem_pre.c   | 32 ++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 22 deletions(-)
 create mode 100644 test/testfilesystem_pre.c

diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 8d973ec..ef62c04 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -932,6 +932,7 @@
 #define SDL_SetAudioStreamFrequencyRatio IGNORE_THIS_VERSION_OF_SDL_SetAudioStreamFrequencyRatio
 #define SDL_SetAudioPostmixCallback IGNORE_THIS_VERSION_OF_SDL_SetAudioPostmixCallback
 #define SDL_GetAudioStreamQueued IGNORE_THIS_VERSION_OF_SDL_GetAudioStreamQueued
+#define SDL_GetTextureDXGIResource IGNORE_THIS_VERSION_OF_SDL_GetTextureDXGIResource
 
 
 #define SDL_FUNCTION_POINTER_IS_VOID_POINTER 1
@@ -4577,6 +4578,10 @@
 #undef SDL_GetAudioStreamQueued
 #endif
 
+#ifdef SDL_GetTextureDXGIResource
+#undef SDL_GetTextureDXGIResource
+#endif
+
 /* undefine these macros too: */
 /* redefine as SDL3_xxx, if needed. */
 
diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c
index 22a4378..9fa7ef0 100644
--- a/test/testautomation_mouse.c
+++ b/test/testautomation_mouse.c
@@ -503,6 +503,7 @@ int mouse_getMouseFocus(void *arg)
     int x, y;
     SDL_Window *window;
     SDL_Window *focusWindow;
+    const SDL_bool video_driver_is_wayland = !SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland");
 
     /* Get focus - focus non-deterministic */
     focusWindow = SDL_GetMouseFocus();
@@ -514,28 +515,33 @@ int mouse_getMouseFocus(void *arg)
         return TEST_ABORTED;
     }
 
-    /* Mouse to random position inside window */
-    x = SDLTest_RandomIntegerInRange(1, w - 1);
-    y = SDLTest_RandomIntegerInRange(1, h - 1);
-    SDL_WarpMouseInWindow(window, x, y);
-    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
-
-    /* Pump events to update focus state */
-    SDL_Delay(100);
-    SDL_PumpEvents();
-    SDLTest_AssertPass("SDL_PumpEvents()");
-
-    /* Get focus with explicit window setup - focus deterministic */
-    focusWindow = SDL_GetMouseFocus();
-    SDLTest_AssertPass("SDL_GetMouseFocus()");
-    SDLTest_AssertCheck(focusWindow != NULL, "Check returned window value is not NULL");
-    SDLTest_AssertCheck(focusWindow == window, "Check returned window value is test window");
-
-    /* Mouse to random position outside window */
-    x = SDLTest_RandomIntegerInRange(-9, -1);
-    y = SDLTest_RandomIntegerInRange(-9, -1);
-    SDL_WarpMouseInWindow(window, x, y);
-    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
+    /* Wayland explicitly disallows warping the mouse pointer, so this test must be skipped. */
+    if (!video_driver_is_wayland) {
+        /* Mouse to random position inside window */
+        x = SDLTest_RandomIntegerInRange(1, w - 1);
+        y = SDLTest_RandomIntegerInRange(1, h - 1);
+        SDL_WarpMouseInWindow(window, x, y);
+        SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
+
+        /* Pump events to update focus state */
+        SDL_Delay(100);
+        SDL_PumpEvents();
+        SDLTest_AssertPass("SDL_PumpEvents()");
+
+        /* Get focus with explicit window setup - focus deterministic */
+        focusWindow = SDL_GetMouseFocus();
+        SDLTest_AssertPass("SDL_GetMouseFocus()");
+        SDLTest_AssertCheck(focusWindow != NULL, "Check returned window value is not NULL");
+        SDLTest_AssertCheck(focusWindow == window, "Check returned window value is test window");
+
+        /* Mouse to random position outside window */
+        x = SDLTest_RandomIntegerInRange(-9, -1);
+        y = SDLTest_RandomIntegerInRange(-9, -1);
+        SDL_WarpMouseInWindow(window, x, y);
+        SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
+    } else {
+        SDLTest_Log("Skipping mouse warp focus tests: Wayland does not support warping the mouse pointer");
+    }
 
     /* Clean up test window */
     _destroyMouseSuiteTestWindow(window);
diff --git a/test/testfilesystem_pre.c b/test/testfilesystem_pre.c
new file mode 100644
index 0000000..dba8b51
--- /dev/null
+++ b/test/testfilesystem_pre.c
@@ -0,0 +1,32 @@
+/*
+  Copyright (C) 1997-2023 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.
+*/
+/* Call SDL_GetPrefPath to warm the SHGetFolderPathW cache */
+
+/**
+ * We noticed frequent ci timeouts running testfilesystem on 32-bit Windows.
+ * Internally, this functions calls Shell32.SHGetFolderPathW.
+ */
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+    Uint64 start;
+    (void)argc;
+    (void)argv;
+    SDL_Init(0);
+    start = SDL_GetTicks();
+    SDL_GetPrefPath("libsdl", "test_filesystem");
+    SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", SDL_GetTicks() - start);
+    SDL_Quit();
+    return 0;
+}