(Animation) Fix assert when animation is resumed using PlayAfter after all loops... 15/214815/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 26 Sep 2019 14:32:41 +0000 (15:32 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 26 Sep 2019 14:32:41 +0000 (15:32 +0100)
Change-Id: I7342b253e6c2508184b29dc02b4abcf482e1c168

automated-tests/src/dali/utc-Dali-Animation.cpp
dali/internal/update/animation/scene-graph-animation.cpp

index 41517d1..179ac9b 100644 (file)
@@ -13454,3 +13454,42 @@ int UtcDaliAnimationPausePropertyValue(void)
 
   END_TEST;
 }
+
+int UtcDaliAnimationPlayFromWithLoopCount(void)
+{
+  TestApplication application;
+
+  auto actor = Actor::New();
+  Stage::GetCurrent().Add( actor );
+
+  auto animation = Animation::New( 1.0f );
+  animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f );
+  animation.SetLoopCount( 2 );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render( 1001 );
+
+  // One loop completed
+
+  application.Render( 2005 );
+  application.SendNotification();
+
+  // 2 loops should have completed
+  DALI_TEST_EQUALS( animation.GetCurrentLoop(), 2u, TEST_LOCATION );
+
+  // Another render needs to occur after all the loops end
+  application.SendNotification();
+  application.Render( 1000 );
+
+  // Stop the animation and use PlayFrom, previously we got an Assert here
+  animation.Stop();
+  animation.PlayFrom( 0.5f );
+
+  application.SendNotification();
+  application.Render( 1000 );
+
+  DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION );
+
+  END_TEST;
+}
index ad3abd4..167dcaa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -176,6 +176,8 @@ void Animation::PlayFrom( float progress )
     mState = Playing;
 
     SetAnimatorsActive( true );
+
+    mCurrentLoop = 0;
   }
 }