2019-12-01 19:56:35 +01:00
|
|
|
#include "../src/internal.hpp"
|
|
|
|
#include "../src/vkvm.hpp"
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
|
|
|
TEST_CASE("Event") {
|
|
|
|
vkvm::initialize(0);
|
|
|
|
|
|
|
|
SECTION("Register") {
|
|
|
|
bool mouseMove = false;
|
2019-12-05 09:49:54 +01:00
|
|
|
bool keyup = false;
|
|
|
|
bool keyup2 = false;
|
2019-12-01 19:56:35 +01:00
|
|
|
vkvm::registerEvent(vkvm::MouseMove, [&]() {
|
|
|
|
mouseMove = true;
|
|
|
|
});
|
2019-12-05 09:49:54 +01:00
|
|
|
vkvm::registerEvent(vkvm::KeyUp, [&]() {
|
|
|
|
keyup = true;
|
2019-12-01 19:56:35 +01:00
|
|
|
});
|
2019-12-05 09:49:54 +01:00
|
|
|
vkvm::registerEvent(vkvm::KeyUp, [&]() {
|
|
|
|
keyup2 = true;
|
2019-12-01 19:56:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
REQUIRE_FALSE(mouseMove);
|
|
|
|
vkvm::callEvent(vkvm::MouseMove);
|
|
|
|
REQUIRE(mouseMove);
|
|
|
|
|
2019-12-05 09:49:54 +01:00
|
|
|
REQUIRE_FALSE(keyup);
|
|
|
|
REQUIRE_FALSE(keyup2);
|
|
|
|
vkvm::callEvent(vkvm::KeyUp);
|
|
|
|
REQUIRE(keyup);
|
|
|
|
REQUIRE(keyup2);
|
2019-12-01 19:56:35 +01:00
|
|
|
}
|
|
|
|
}
|