[4.0] Bug fix at DevelAnimation::ProgressReashedSignal 31/159331/2
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 6 Nov 2017 07:10:35 +0000 (16:10 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Wed, 8 Nov 2017 08:11:57 +0000 (17:11 +0900)
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 <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Animation.cpp
dali/internal/update/animation/scene-graph-animation.cpp

index 26955d6..d4e6646 100644 (file)
@@ -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
+  const float durationSeconds(1.0f);
+  animation.SetDuration(durationSeconds);
+
+  // Set Looping Count
+  const 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
+  const 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<unsigned int>(durationSeconds * 1000.0f) + 10u);
+  application.SendNotification();
+  application.Render(0u);
+  application.SendNotification();
+
+  finishCheck.CheckSignalReceived();
+
+  END_TEST;
+}
+
 int UtcDaliAnimationProgressCallbackLongDurationP(void)
 {
   TestApplication application;
index 22483bf..260be92 100644 (file)
@@ -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
     }