mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Add first portion of live window tests
This commit is contained in:
parent
7176ecd1d0
commit
4c2180e260
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,6 +39,7 @@ libSDL2pp.so.*
|
||||
tests/*.exe
|
||||
tests/live_mixer
|
||||
tests/live_rendering
|
||||
tests/live_window
|
||||
tests/test_error
|
||||
tests/test_optional
|
||||
tests/test_pointrect
|
||||
|
@ -10,6 +10,7 @@ SET(CLI_TESTS
|
||||
# live tests require X11 display and/or audio output
|
||||
SET(LIVE_TESTS
|
||||
live_rendering
|
||||
live_window
|
||||
)
|
||||
|
||||
IF(SDL2PP_WITH_MIXER)
|
||||
|
68
tests/live_window.cc
Normal file
68
tests/live_window.cc
Normal file
@ -0,0 +1,68 @@
|
||||
#include <vector>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2pp/SDL2pp.hh>
|
||||
|
||||
#include "testing.h"
|
||||
|
||||
using namespace SDL2pp;
|
||||
|
||||
static void ProcessEvents() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_TEST(int, char*[])
|
||||
SDL sdl(SDL_INIT_VIDEO);
|
||||
Window window("libSDL2pp test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 240, 0);
|
||||
|
||||
ProcessEvents();
|
||||
|
||||
{
|
||||
// Size
|
||||
EXPECT_EQUAL(window.GetSize(), Point(320, 240));
|
||||
EXPECT_EQUAL(window.GetWidth(), 320);
|
||||
EXPECT_EQUAL(window.GetHeight(), 240);
|
||||
|
||||
window.SetSize(400, 300);
|
||||
|
||||
EXPECT_EQUAL(window.GetSize(), Point(400, 300));
|
||||
EXPECT_EQUAL(window.GetWidth(), 400);
|
||||
EXPECT_EQUAL(window.GetHeight(), 300);
|
||||
}
|
||||
|
||||
{
|
||||
// Title
|
||||
EXPECT_EQUAL(window.GetTitle(), "libSDL2pp test");
|
||||
|
||||
window.SetTitle("libSDL2pp window test");
|
||||
|
||||
EXPECT_EQUAL(window.GetTitle(), "libSDL2pp window test");
|
||||
}
|
||||
|
||||
{
|
||||
// Drawable size
|
||||
EXPECT_EQUAL(window.GetDrawableSize(), Point(window.GetDrawableWidth(), window.GetDrawableHeight()));
|
||||
|
||||
// Drawable may be larget than window size, see SDL docs
|
||||
// Should we compare with multiplies of window size?
|
||||
EXPECT_TRUE(window.GetDrawableWidth() >= window.GetWidth());
|
||||
EXPECT_TRUE(window.GetDrawableHeight() >= window.GetHeight());
|
||||
EXPECT_TRUE(window.GetDrawableWidth() > window.GetDrawableHeight());
|
||||
}
|
||||
|
||||
{
|
||||
// Position
|
||||
Point old_pos = window.GetPosition();
|
||||
|
||||
window.SetPosition(old_pos + Point(2, 1));
|
||||
|
||||
EXPECT_EQUAL(window.GetPosition(), old_pos + Point(2, 1));
|
||||
|
||||
window.SetPosition(old_pos.x + 4, old_pos.y + 2);
|
||||
|
||||
EXPECT_EQUAL(window.GetPosition(), old_pos + Point(4, 2));
|
||||
}
|
||||
|
||||
END_TEST()
|
Loading…
x
Reference in New Issue
Block a user