diff --git a/src/Magnum/SceneGraph/Test/AnimableTest.cpp b/src/Magnum/SceneGraph/Test/AnimableTest.cpp index 248dded00..61ad2a061 100644 --- a/src/Magnum/SceneGraph/Test/AnimableTest.cpp +++ b/src/Magnum/SceneGraph/Test/AnimableTest.cpp @@ -42,6 +42,8 @@ struct AnimableTest: TestSuite::Tester { void stop(); void pause(); + void deleteWhileRunning(); + void debug(); }; @@ -55,6 +57,8 @@ AnimableTest::AnimableTest() { &AnimableTest::stop, &AnimableTest::pause, + &AnimableTest::deleteWhileRunning, + &AnimableTest::debug}); } @@ -351,6 +355,28 @@ void AnimableTest::pause() { CORRADE_COMPARE(animable.time, 2.0f); } +void AnimableTest::deleteWhileRunning() { + Object3D object; + AnimableGroup3D group; + CORRADE_COMPARE(group.runningCount(), 0); + + { + OneShotAnimable animable(object, &group); + + /* Eat up some absolute time */ + group.step(1.0f, 0.5f); + group.step(1.5f, 0.5f); + CORRADE_COMPARE(group.runningCount(), 1); + + CORRADE_COMPARE(animable.state(), AnimationState::Running); + CORRADE_COMPARE(animable.time, 0.5f); + } + + /* Animable got deleted, stepping further should not crash and burn (tm) */ + group.step(1.5f, 0.5f); + CORRADE_COMPARE(group.runningCount(), 0); +} + void AnimableTest::debug() { std::ostringstream o; Debug(&o) << AnimationState::Running << AnimationState(0xbe);