2022-07-25 00:36:05 -06:00
|
|
|
#include <SFML/Window/Cursor.hpp>
|
|
|
|
|
2024-08-20 15:30:38 -06:00
|
|
|
// Other 1st party headers
|
|
|
|
#include <SFML/System/Exception.hpp>
|
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2023-02-11 18:58:49 -07:00
|
|
|
|
|
|
|
#include <WindowUtil.hpp>
|
|
|
|
#include <array>
|
2022-07-25 00:36:05 -06:00
|
|
|
#include <type_traits>
|
|
|
|
|
2023-09-04 19:21:42 -06:00
|
|
|
TEST_CASE("[Window] sf::Cursor", runDisplayTests())
|
2023-02-11 18:58:49 -07:00
|
|
|
{
|
2023-01-17 21:51:08 -07:00
|
|
|
SECTION("Type traits")
|
|
|
|
{
|
2024-05-20 19:04:40 -06:00
|
|
|
STATIC_CHECK(!std::is_default_constructible_v<sf::Cursor>);
|
2023-01-17 21:51:08 -07:00
|
|
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::Cursor>);
|
|
|
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::Cursor>);
|
|
|
|
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::Cursor>);
|
|
|
|
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Cursor>);
|
|
|
|
}
|
|
|
|
|
2024-07-06 04:24:00 +02:00
|
|
|
SECTION("Constructor")
|
|
|
|
{
|
|
|
|
SECTION("Pixels")
|
|
|
|
{
|
|
|
|
static constexpr std::array<std::uint8_t, 4> pixels{};
|
|
|
|
|
2024-08-20 15:30:38 -06:00
|
|
|
CHECK_THROWS_AS(sf::Cursor(nullptr, {}, {}), sf::Exception);
|
|
|
|
CHECK_THROWS_AS(sf::Cursor(pixels.data(), {0, 1}, {}), sf::Exception);
|
|
|
|
CHECK_THROWS_AS(sf::Cursor(pixels.data(), {1, 0}, {}), sf::Exception);
|
2024-07-06 04:24:00 +02:00
|
|
|
CHECK_NOTHROW(sf::Cursor(pixels.data(), {1, 1}, {}));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("System")
|
|
|
|
{
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::Hand));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeHorizontal));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeVertical));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeLeft));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeRight));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeTop));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeBottom));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeTopLeft));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeTopRight));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeBottomLeft));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::SizeBottomRight));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::Cross));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::Help));
|
|
|
|
CHECK_NOTHROW(sf::Cursor(sf::Cursor::Type::NotAllowed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
SECTION("loadFromPixels()")
|
2023-02-11 18:58:49 -07:00
|
|
|
{
|
2024-05-20 19:04:40 -06:00
|
|
|
static constexpr std::array<std::uint8_t, 4> pixels{};
|
2023-02-11 18:58:49 -07:00
|
|
|
|
2024-07-06 03:38:32 +02:00
|
|
|
CHECK(!sf::Cursor::createFromPixels(nullptr, {}, {}));
|
|
|
|
CHECK(!sf::Cursor::createFromPixels(pixels.data(), {0, 1}, {}));
|
|
|
|
CHECK(!sf::Cursor::createFromPixels(pixels.data(), {1, 0}, {}));
|
|
|
|
CHECK(sf::Cursor::createFromPixels(pixels.data(), {1, 1}, {}));
|
2023-02-11 18:58:49 -07:00
|
|
|
}
|
|
|
|
|
2023-01-17 21:51:08 -07:00
|
|
|
SECTION("loadFromSystem()")
|
2023-02-11 18:58:49 -07:00
|
|
|
{
|
2024-07-06 03:38:32 +02:00
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::Hand));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeHorizontal));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeVertical));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeLeft));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeRight));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeTop));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeBottom));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeTopLeft));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeTopRight));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeBottomLeft));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::SizeBottomRight));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::Cross));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::Help));
|
|
|
|
CHECK(sf::Cursor::createFromSystem(sf::Cursor::Type::NotAllowed));
|
2023-02-11 18:58:49 -07:00
|
|
|
}
|
|
|
|
}
|