2022-07-25 14:36:05 +08:00
|
|
|
#include <SFML/Window/Window.hpp>
|
|
|
|
|
2023-03-10 08:38:14 +08:00
|
|
|
// Other 1st party headers
|
|
|
|
#include <SFML/Window/VideoMode.hpp>
|
|
|
|
|
2023-04-24 20:13:52 +08:00
|
|
|
#include <SFML/System/String.hpp>
|
|
|
|
|
2023-01-18 12:51:08 +08:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2023-03-10 08:38:14 +08:00
|
|
|
|
|
|
|
#include <WindowUtil.hpp>
|
2022-07-25 14:36:05 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2023-01-18 12:51:08 +08:00
|
|
|
TEST_CASE("[Window] sf::Window", runDisplayTests())
|
2023-03-10 08:38:14 +08:00
|
|
|
{
|
2023-01-18 12:51:08 +08:00
|
|
|
SECTION("Type traits")
|
|
|
|
{
|
2023-12-27 07:31:08 +08:00
|
|
|
STATIC_CHECK(std::has_virtual_destructor_v<sf::Window>);
|
2023-01-18 12:51:08 +08:00
|
|
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::Window>);
|
|
|
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::Window>);
|
2023-12-27 07:31:08 +08:00
|
|
|
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::Window>);
|
|
|
|
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Window>);
|
2023-01-18 12:51:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Construction")
|
2023-03-10 08:38:14 +08:00
|
|
|
{
|
2023-09-19 09:57:05 +08:00
|
|
|
SECTION("Default constructor")
|
|
|
|
{
|
|
|
|
const sf::Window window;
|
|
|
|
CHECK(!window.isOpen());
|
|
|
|
CHECK(window.getPosition() == sf::Vector2i());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u());
|
|
|
|
CHECK(!window.hasFocus());
|
|
|
|
CHECK(window.getNativeHandle() == sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().depthBits == 0);
|
|
|
|
CHECK(window.getSettings().stencilBits == 0);
|
|
|
|
CHECK(window.getSettings().antialiasingLevel == 0);
|
|
|
|
CHECK(window.getSettings().majorVersion == 1);
|
|
|
|
CHECK(window.getSettings().minorVersion == 1);
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
CHECK(!window.getSettings().sRgbCapable);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode and title constructor")
|
|
|
|
{
|
|
|
|
const sf::Window window(sf::VideoMode({360, 240}), "Window Tests");
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, and style constructor")
|
|
|
|
{
|
|
|
|
const sf::Window window(sf::VideoMode({360, 240}), "Window Tests", sf::Style::Resize);
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
2024-01-02 06:38:14 +08:00
|
|
|
SECTION("Mode, title, style, and state constructor")
|
2023-09-19 09:57:05 +08:00
|
|
|
{
|
2024-01-02 06:38:14 +08:00
|
|
|
const sf::Window window(sf::VideoMode({360, 240}), "Window Tests", sf::Style::Resize, sf::State::Windowed);
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, style, state, and context settings constructor")
|
|
|
|
{
|
|
|
|
const sf::Window window(sf::VideoMode({360, 240}),
|
|
|
|
"Window Tests",
|
|
|
|
sf::Style::Resize,
|
|
|
|
sf::State::Windowed,
|
2024-05-25 02:36:42 +08:00
|
|
|
sf::ContextSettings{/* depthBits*/ 1, /* stencilBits */ 1, /* antialiasingLevel */ 1});
|
2024-01-02 06:38:14 +08:00
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().depthBits >= 1);
|
|
|
|
CHECK(window.getSettings().stencilBits >= 1);
|
|
|
|
CHECK(window.getSettings().antialiasingLevel >= 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, and state")
|
|
|
|
{
|
|
|
|
const sf::Window window(sf::VideoMode({360, 240}), "Window Tests", sf::State::Windowed);
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, state, and context settings constructor")
|
|
|
|
{
|
|
|
|
const sf::Window window(sf::VideoMode({360, 240}),
|
|
|
|
"Window Tests",
|
|
|
|
sf::State::Windowed,
|
2024-05-25 02:36:42 +08:00
|
|
|
sf::ContextSettings{/* depthBits*/ 1, /* stencilBits */ 1, /* antialiasingLevel */ 1});
|
2023-09-19 09:57:05 +08:00
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(360, 240));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
2023-11-13 00:40:05 +08:00
|
|
|
CHECK(window.getSettings().depthBits >= 1);
|
|
|
|
CHECK(window.getSettings().stencilBits >= 1);
|
|
|
|
CHECK(window.getSettings().antialiasingLevel >= 1);
|
2023-09-19 09:57:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("create()")
|
|
|
|
{
|
|
|
|
sf::Window window;
|
|
|
|
|
|
|
|
SECTION("Mode and title")
|
|
|
|
{
|
|
|
|
window.create(sf::VideoMode({240, 360}), "Window Tests");
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(240, 360));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, and style")
|
|
|
|
{
|
|
|
|
window.create(sf::VideoMode({240, 360}), "Window Tests", sf::Style::Resize);
|
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(240, 360));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
|
|
|
CHECK(window.getSettings().attributeFlags == sf::ContextSettings::Default);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Mode, title, style, and context settings")
|
|
|
|
{
|
2024-01-02 06:38:14 +08:00
|
|
|
window.create(sf::VideoMode({240, 360}),
|
|
|
|
"Window Tests",
|
|
|
|
sf::Style::Resize,
|
|
|
|
sf::State::Windowed,
|
2024-05-25 02:36:42 +08:00
|
|
|
sf::ContextSettings{/* depthBits*/ 1, /* stencilBits */ 1, /* antialiasingLevel */ 1});
|
2023-09-19 09:57:05 +08:00
|
|
|
CHECK(window.isOpen());
|
|
|
|
CHECK(window.getSize() == sf::Vector2u(240, 360));
|
|
|
|
CHECK(window.getNativeHandle() != sf::WindowHandle());
|
2023-11-13 00:40:05 +08:00
|
|
|
CHECK(window.getSettings().depthBits >= 1);
|
|
|
|
CHECK(window.getSettings().stencilBits >= 1);
|
|
|
|
CHECK(window.getSettings().antialiasingLevel >= 1);
|
2023-09-19 09:57:05 +08:00
|
|
|
}
|
2023-03-10 08:38:14 +08:00
|
|
|
}
|
|
|
|
}
|