Browse Source

Fix video_getSetWindowGrab(): need to raise the window, and wait for focus gained

Sylvain 2 years ago
parent
commit
f30a182de2
1 changed files with 18 additions and 0 deletions
  1. 18 0
      test/testautomation_video.c

+ 18 - 0
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()");