From: Eunki Hong Date: Mon, 6 Nov 2017 07:10:35 +0000 (+0900) Subject: Bug fix at DevelAnimation::ProgressReashedSignal X-Git-Tag: dali_1.2.65~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F158971%2F1;hp=c5ef0c903b07c35aeecd129109b12f42bb9a96a6;p=platform%2Fcore%2Fuifw%2Fdali-core.git Bug fix at DevelAnimation::ProgressReashedSignal Fix one bug in this patch Progress reach signal required value were initialized when loop is done. But if mLoopCount == 0 (unlimited looping) then signal required value is not initialized. See UtcDaliAnimationProgressCallbackWithLoopingP() and UtcDaliAnimaionProgressCallbackWithLoopingP2(). P() use SetLoopCount and P2() use SetLooping(true). Previous version only pass P() and fail P2(). now both P() and P2() will pass Change-Id: Ie60ea087a00afb8a919cb935b083f207a1e34557 Signed-off-by: Eunki Hong --- diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 26955d6..cd87b7c 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -12430,6 +12430,187 @@ int UtcDaliAnimationProgressSignalWithPlayAfterP(void) END_TEST; } +int UtcDaliAnimationProgressCallbackWithLoopingP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0.0f); + + //Set duration + float durationSeconds(1.0f); + animation.SetDuration(durationSeconds); + + // Set Looping Count + int loopCount( 4 ); + animation.SetLoopCount( loopCount ); + + bool finishedSignalReceived(false); + bool progressSignalReceived(false); + + AnimationFinishCheck finishCheck(finishedSignalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + AnimationProgressCheck progressCheck(progressSignalReceived); + DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck); + application.SendNotification(); + + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + tet_infoline( "Animation Progress notification set to 50% with looping count 4" ); + DevelAnimation::SetProgressNotification( animation, 0.5f ); + + application.SendNotification(); + application.Render( ); + + progressCheck.CheckSignalNotReceived(); + + animation.Play(); + + for(int count = 0; count < loopCount; count++) + { + application.SendNotification(); + application.Render(0); // start animation + application.Render(durationSeconds*0.25*1000.0f ); // 25% progress + DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION ); + + tet_infoline( "Animation at 25%" ); + + progressCheck.CheckSignalNotReceived(); + + application.SendNotification(); + application.Render(durationSeconds*0.25*1000.0f ); // 50% progress + application.SendNotification(); + tet_infoline( "Animation at 50%" ); + DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION ); + + progressCheck.CheckSignalReceived(); + + tet_infoline( "Progress check reset" ); + progressCheck.Reset(); + + application.Render(durationSeconds*0.25*1000.0f ); // 75% progress + tet_infoline( "Animation at 75%" ); + application.SendNotification(); + + DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION ); + + progressCheck.CheckSignalNotReceived(); + + application.Render(durationSeconds*0.25*1000.0f ); // 100% progress + tet_infoline( "Animation at 100%" ); + application.SendNotification(); + + //Nothing check at 100% progress. cause It can be both 100% and 0%. + application.SendNotification(); + } + application.Render(10u); + application.SendNotification(); + application.Render(0u); + application.SendNotification(); + + finishCheck.CheckSignalReceived(); + + END_TEST; +} + +int UtcDaliAnimationProgressCallbackWithLoopingP2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + Animation animation = Animation::New(0.0f); + + //Set duration + float durationSeconds(1.0f); + animation.SetDuration(durationSeconds); + + // Set Looping Unlmited + animation.SetLooping( true ); + + bool finishedSignalReceived(false); + bool progressSignalReceived(false); + + AnimationFinishCheck finishCheck(finishedSignalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + AnimationProgressCheck progressCheck(progressSignalReceived); + DevelAnimation::ProgressReachedSignal( animation ).Connect( &application, progressCheck); + application.SendNotification(); + + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + + tet_infoline( "Animation Progress notification set to 50% with unlimited looping" ); + DevelAnimation::SetProgressNotification( animation, 0.5f ); + + application.SendNotification(); + application.Render( ); + + progressCheck.CheckSignalNotReceived(); + + animation.Play(); + + for(int count = 0; count < 4; count++) + { + application.SendNotification(); + application.Render(0); // start animation + application.Render(durationSeconds*0.25*1000.0f ); // 25% progress + DALI_TEST_EQUALS( 0.25f, animation.GetCurrentProgress(), TEST_LOCATION ); + + tet_infoline( "Animation at 25%" ); + + progressCheck.CheckSignalNotReceived(); + + application.SendNotification(); + application.Render(durationSeconds*0.25*1000.0f ); // 50% progress + application.SendNotification(); + tet_infoline( "Animation at 50%" ); + DALI_TEST_EQUALS( 0.5f, animation.GetCurrentProgress(), TEST_LOCATION ); + + progressCheck.CheckSignalReceived(); + + tet_infoline( "Progress check reset" ); + progressCheck.Reset(); + + application.Render(durationSeconds*0.25*1000.0f ); // 75% progress + tet_infoline( "Animation at 75%" ); + application.SendNotification(); + + DALI_TEST_EQUALS( 0.75f, animation.GetCurrentProgress(), TEST_LOCATION ); + + progressCheck.CheckSignalNotReceived(); + + application.Render(durationSeconds*0.25*1000.0f ); // 100% progress + tet_infoline( "Animation at 100%" ); + application.SendNotification(); + + //Nothing check at 100% progress. cause It can be both 100% and 0%. + finishCheck.CheckSignalNotReceived(); + application.SendNotification(); + } + finishCheck.CheckSignalNotReceived(); + + animation.SetLooping( false ); + application.Render(0u); + application.SendNotification(); + application.Render(static_cast(durationSeconds * 1000.0f) + 10u); + application.SendNotification(); + application.Render(0u); + application.SendNotification(); + + finishCheck.CheckSignalReceived(); + + END_TEST; +} + int UtcDaliAnimationProgressCallbackLongDurationP(void) { TestApplication application; diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index 22483bf..260be92 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -351,16 +351,7 @@ void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& loop Vector2 playRangeSeconds = mPlayRange * mDurationSeconds; - if( 0 == mLoopCount ) - { - // loop forever - WrapInPlayRange(mElapsedSeconds, playRangeSeconds); - - UpdateAnimators(bufferIndex, false, false ); - - // don't increment mPlayedCount as event loop tracks this to indicate animation finished (end of all loops) - } - else if( mCurrentLoop < mLoopCount - 1) // '-1' here so last loop iteration uses play once below + if( 0 == mLoopCount || mCurrentLoop < mLoopCount - 1) // '-1' here so last loop iteration uses play once below { // looping looped = (mState == Playing && @@ -373,7 +364,10 @@ void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& loop if(looped) { - ++mCurrentLoop; + if( mLoopCount != 0 ) + { + ++mCurrentLoop; + } mProgressReachedSignalRequired = mProgressMarker > 0.0f; // don't increment mPlayedCount until the finished final loop }