[c] Added callback recursion issue to test suite

This commit is contained in:
badlogic 2016-11-29 18:45:36 +01:00
parent 6fe1e8fa68
commit 873ed16a53
2 changed files with 42 additions and 0 deletions

View File

@ -179,4 +179,44 @@ void MemoryTestFixture::reproduceIssue_777()
DisposeAll(skeleton, state, stateData, skeletonData, atlas); DisposeAll(skeleton, state, stateData, skeletonData, atlas);
} }
spSkeleton* skeleton = nullptr;
static void spineAnimStateHandler(spAnimationState* state, int type, spTrackEntry* entry, spEvent* event)
{
if (type == SP_ANIMATION_COMPLETE)
{
spAnimationState_setAnimationByName(state, 0, "walk", false);
spAnimationState_update(state, 0);
spAnimationState_apply(state, skeleton);
}
}
void MemoryTestFixture::reproduceIssue_Loop()
{
spAtlas* atlas = nullptr;
spSkeletonData* skeletonData = nullptr;
spAnimationStateData* stateData = nullptr;
spAnimationState* state = nullptr;
//////////////////////////////////////////////////////////////////////////
// Initialize Animations
LoadSpineboyExample(atlas, skeletonData, stateData, skeleton, state);
///////////////////////////////////////////////////////////////////////////
if (state)
state->listener = (spAnimationStateListener)&spineAnimStateHandler;
spAnimationState_setAnimationByName(state, 0, "walk", false);
// run normal update
for (int i = 0; i < 50; ++i) {
const float timeSlice = 1.0f / 60.0f;
spSkeleton_update(skeleton, timeSlice);
spAnimationState_update(state, timeSlice);
spAnimationState_apply(state, skeleton);
}
DisposeAll(skeleton, state, stateData, skeletonData, atlas);
}

View File

@ -17,6 +17,7 @@ public:
// Comment out here to disable individual test cases // Comment out here to disable individual test cases
TEST_CASE(reproduceIssue_776); TEST_CASE(reproduceIssue_776);
TEST_CASE(reproduceIssue_777); TEST_CASE(reproduceIssue_777);
TEST_CASE(reproduceIssue_Loop);
initialize(); initialize();
} }
@ -29,6 +30,7 @@ public:
public: public:
void reproduceIssue_776(); void reproduceIssue_776();
void reproduceIssue_777(); void reproduceIssue_777();
void reproduceIssue_Loop(); // http://esotericsoftware.com/forum/spine-c-3-5-animation-jerking-7451
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// test fixture setup // test fixture setup