Skip to content

Commit

Permalink
Add tests for animating flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadden committed Sep 20, 2020
1 parent 4be79e7 commit 0e00f9a
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions unit_tests/flow/components.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <alia/flow/components.hpp>

#include <flow/testing.hpp>

TEST_CASE("animating components", "[flow][components]")
{
clear_log();

int iteration = -1;

component_container_ptr top(new component_container);
component_container_ptr left(new component_container);
component_container_ptr bottom(new component_container);
component_container_ptr right(new component_container);

alia::system sys;
initialize_system(sys, [&](context ctx) {
scoped_component_container scoped_top(ctx, &top);
if (iteration == 0)
mark_animating_component(ctx);
{
scoped_component_container scoped_left(ctx, &left);
if (iteration == 1)
mark_animating_component(ctx);
{
scoped_component_container scoped_bottom(ctx, &bottom);
if (iteration == 2)
mark_animating_component(ctx);
}
}
{
scoped_component_container scoped_right(ctx, &right);
if (iteration == 3)
mark_animating_component(ctx);
}
});

refresh_system(sys);
REQUIRE(!top->animating);
REQUIRE(!left->animating);
REQUIRE(!bottom->animating);
REQUIRE(!right->animating);

++iteration;
refresh_system(sys);
REQUIRE(top->animating);
REQUIRE(!left->animating);
REQUIRE(!bottom->animating);
REQUIRE(!right->animating);

++iteration;
refresh_system(sys);
REQUIRE(top->animating);
REQUIRE(left->animating);
REQUIRE(!bottom->animating);
REQUIRE(!right->animating);

++iteration;
refresh_system(sys);
REQUIRE(top->animating);
REQUIRE(left->animating);
REQUIRE(bottom->animating);
REQUIRE(!right->animating);

++iteration;
refresh_system(sys);
REQUIRE(top->animating);
REQUIRE(!left->animating);
REQUIRE(!bottom->animating);
REQUIRE(right->animating);
}

0 comments on commit 0e00f9a

Please sign in to comment.