More tests converted to fuc2.
This commit is contained in:
parent
b8b42d5681
commit
903cf00661
10 changed files with 671 additions and 556 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fuc2/testing.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <string>
|
||||
#include "gui/event_router.hpp"
|
||||
|
|
@ -7,51 +7,61 @@ using namespace fmt;
|
|||
using namespace gui;
|
||||
using enum gui::routing::Event;
|
||||
using enum gui::routing::State;
|
||||
using namespace fuc2;
|
||||
|
||||
using EventScript = std::vector<routing::Event>;
|
||||
namespace event_router_tests {
|
||||
using EventScript = std::vector<routing::Event>;
|
||||
|
||||
void run_script(routing::Router& router, routing::State expected, EventScript script) {
|
||||
for(auto ev : script) {
|
||||
router.event(ev);
|
||||
void run_script(routing::Router& router, routing::State expected, EventScript script) {
|
||||
for(auto ev : script) {
|
||||
router.event(ev);
|
||||
}
|
||||
|
||||
CHECK(router.in_state(expected));
|
||||
}
|
||||
|
||||
REQUIRE(router.in_state(expected));
|
||||
}
|
||||
|
||||
TEST_CASE("basic router operations test", "[event_router]") {
|
||||
routing::Router router;
|
||||
|
||||
// start goes to idle
|
||||
run_script(router, IDLE, {
|
||||
STARTED
|
||||
});
|
||||
|
||||
// simulate drag and drop
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_MOVE,
|
||||
MOUSE_UP,
|
||||
KEY_PRESS
|
||||
});
|
||||
|
||||
// moving the mouse outside dnd
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_MOVE,
|
||||
KEY_PRESS,
|
||||
MOUSE_MOVE
|
||||
});
|
||||
|
||||
// regular mouse click
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_UP
|
||||
});
|
||||
|
||||
// possible bad key press in a move?
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_MOVE,
|
||||
KEY_PRESS,
|
||||
MOUSE_UP,
|
||||
});
|
||||
void test_basic_router_operations_test() {
|
||||
routing::Router router;
|
||||
|
||||
// start goes to idle
|
||||
run_script(router, IDLE, {
|
||||
STARTED
|
||||
});
|
||||
|
||||
// simulate drag and drop
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_MOVE,
|
||||
MOUSE_UP,
|
||||
KEY_PRESS
|
||||
});
|
||||
|
||||
// moving the mouse outside dnd
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_MOVE,
|
||||
KEY_PRESS,
|
||||
MOUSE_MOVE
|
||||
});
|
||||
|
||||
// regular mouse click
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_UP
|
||||
});
|
||||
|
||||
// possible bad key press in a move?
|
||||
run_script(router, IDLE, {
|
||||
MOUSE_DOWN,
|
||||
MOUSE_MOVE,
|
||||
KEY_PRESS,
|
||||
MOUSE_UP,
|
||||
});
|
||||
}
|
||||
|
||||
fuc2::Set TESTS{
|
||||
.name="event_router",
|
||||
.tests={
|
||||
TEST(test_basic_router_operations_test),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue