From f30a182de2e5a610ee396875846bbae87cbb6f9d Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Mon, 20 Mar 2023 12:34:36 +0100
Subject: [PATCH] Fix video_getSetWindowGrab(): need to raise the window, and
wait for focus gained
---
test/testautomation_video.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/test/testautomation_video.c b/test/testautomation_video.c
index 8d16bddaad72..776047c1846f 100644
--- a/test/testautomation_video.c
+++ b/test/testautomation_video.c
@@ -501,6 +501,7 @@ static int video_getSetWindowGrab(void *arg)
const char *title = "video_getSetWindowGrab Test Window";
SDL_Window *window;
SDL_bool originalMouseState, originalKeyboardState;
+ SDL_bool hasFocusGained = SDL_FALSE;
/* Call against new test window */
window = createVideoSuiteTestWindow(title);
@@ -508,6 +509,23 @@ static int video_getSetWindowGrab(void *arg)
return TEST_ABORTED;
}
+ /* Need to raise the window to have and SDL_EVENT_WINDOW_FOCUS_GAINED,
+ * so that the window gets the flags SDL_WINDOW_INPUT_FOCUS,
+ * so that it can be "grabbed" */
+ SDL_RaiseWindow(window);
+
+ {
+ SDL_Event evt;
+ SDL_zero(evt);
+ while (SDL_PollEvent(&evt)) {
+ if (evt.type == SDL_EVENT_WINDOW_FOCUS_GAINED) {
+ hasFocusGained = SDL_TRUE;
+ }
+ }
+ }
+
+ SDLTest_AssertCheck(hasFocusGained == SDL_TRUE, "Expectded window with focus");
+
/* Get state */
originalMouseState = SDL_GetWindowMouseGrab(window);
SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");