Initial Video, Render, and Properties implementations.
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <hdk/sdl/video/Window.hpp>
|
||||
|
||||
#include "SDL_headless_fixture.hpp"
|
||||
|
||||
TEST_CASE("Window bindings are exercised") {
|
||||
SDLSession sdl;
|
||||
if (!sdl.IsInitialized()) {
|
||||
INFO(SDL_GetError());
|
||||
CHECK(false);
|
||||
return;
|
||||
}
|
||||
|
||||
hdk::sdl::Window window = hdk::sdl::Window::Create("hdk-window-test", 64, 64, SDL_WINDOW_HIDDEN);
|
||||
if (!window) {
|
||||
INFO("SDL_CreateWindow failed in this environment: " << SDL_GetError());
|
||||
window = hdk::sdl::Window(nullptr);
|
||||
}
|
||||
|
||||
auto grabbed = hdk::sdl::Window::GetGrabbed();
|
||||
CHECK((static_cast<bool>(grabbed) || !static_cast<bool>(grabbed)));
|
||||
|
||||
auto fromZero = hdk::sdl::Window::GetFromID(0);
|
||||
CHECK_FALSE(static_cast<bool>(fromZero));
|
||||
|
||||
float minAspect = 0.0f;
|
||||
float maxAspect = 0.0f;
|
||||
CHECK((window.GetAspectRatio(&minAspect, &maxAspect) || !window.GetAspectRatio(&minAspect, &maxAspect)));
|
||||
|
||||
int top = 0;
|
||||
int left = 0;
|
||||
int bottom = 0;
|
||||
int right = 0;
|
||||
CHECK((window.GetBordersSize(&top, &left, &bottom, &right) || !window.GetBordersSize(&top, &left, &bottom, &right)));
|
||||
|
||||
(void)window.GetDisplayScale();
|
||||
(void)window.GetFlags();
|
||||
(void)window.GetFullscreenMode();
|
||||
(void)window.GetID();
|
||||
(void)window.GetKeyboardGrab();
|
||||
CHECK((window.SetKeyboardGrab(false) || !window.SetKeyboardGrab(false)));
|
||||
(void)window.GetMouseGrab();
|
||||
CHECK((window.SetMouseGrab(false) || !window.SetMouseGrab(false)));
|
||||
(void)window.GetMouseRect();
|
||||
CHECK((window.SetMouseRect(nullptr) || !window.SetMouseRect(nullptr)));
|
||||
|
||||
int maxW = 0;
|
||||
int maxH = 0;
|
||||
CHECK((window.GetMaximumSize(&maxW, &maxH) || !window.GetMaximumSize(&maxW, &maxH)));
|
||||
CHECK((window.SetMaximumSize(1280, 720) || !window.SetMaximumSize(1280, 720)));
|
||||
|
||||
int minW = 0;
|
||||
int minH = 0;
|
||||
CHECK((window.GetMinimumSize(&minW, &minH) || !window.GetMinimumSize(&minW, &minH)));
|
||||
CHECK((window.SetMinimumSize(32, 32) || !window.SetMinimumSize(32, 32)));
|
||||
|
||||
CHECK((window.SetSize(96, 96) || !window.SetSize(96, 96)));
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
CHECK((window.GetSize(&width, &height) || !window.GetSize(&width, &height)));
|
||||
|
||||
SDL_Rect safeArea{};
|
||||
CHECK((window.GetSafeArea(&safeArea) || !window.GetSafeArea(&safeArea)));
|
||||
|
||||
(void)window.GetOpacity();
|
||||
CHECK((window.SetOpacity(0.8f) || !window.SetOpacity(0.8f)));
|
||||
|
||||
auto parent = window.GetParent();
|
||||
CHECK((static_cast<bool>(parent) || !static_cast<bool>(parent)));
|
||||
CHECK((window.SetParent(nullptr) || !window.SetParent(nullptr)));
|
||||
|
||||
(void)window.GetPixelDensity();
|
||||
|
||||
int vsync = 0;
|
||||
CHECK((window.GetSurfaceVSync(&vsync) || !window.GetSurfaceVSync(&vsync)));
|
||||
CHECK((window.SetSurfaceVSync(1) || !window.SetSurfaceVSync(1)));
|
||||
|
||||
(void)window.GetPixelFormat();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
CHECK((window.GetPosition(&x, &y) || !window.GetPosition(&x, &y)));
|
||||
CHECK((window.SetPosition(10, 10) || !window.SetPosition(10, 10)));
|
||||
|
||||
(void)window.GetProgressState();
|
||||
(void)window.GetProgressValue();
|
||||
|
||||
auto props = window.GetProperties();
|
||||
CHECK((props.GetPropertyType("hdk-window-test-missing") == SDL_PROPERTY_TYPE_INVALID));
|
||||
}
|
||||
Reference in New Issue
Block a user