END_TEST;
}
-int UtcDaliAnimationEmptyAnimator(void)
+int UtcDaliAnimationEmptyAnimatorAndLoopCount(void)
{
// Clear and play the empty animation, and get the state values.
TestApplication application;
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
application.SendNotification();
application.Render(1500 /* 150% of loop. */);
- application.SendNotification(); // Notification trigger.
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
application.SendNotification();
application.Render(1400 /* 290% of loop. */);
- application.SendNotification(); // Notification trigger.
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 2, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 3, TEST_LOCATION);
- // Check wether empty animation also call finished signal.
+ tet_printf("Check wether empty animation also call finished signal.\n");
finishCheck.CheckSignalReceived();
finishCheck.Reset();
animation.Play();
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
- //DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION); ///< TODO : We'd better change the policy of GetCurrentLoop result
application.SendNotification();
+ application.Render(0 /* 0% of loop. */);
+
+ // LoopCount beome 0 again.
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
application.Render(1500 /* 150% of loop. */);
- application.SendNotification(); // Notification trigger.
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+ animation.Pause();
+
+ application.SendNotification();
+ application.Render(2500 /* 150% of loop. (Since it is paused) */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PAUSED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000 /* 250% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 2, TEST_LOCATION);
+
animation.Clear();
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(500 + 100 /* 300% of loop + 10% over the loop. */);
+ application.SendNotification(); // Notification trigger.
+
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+ tet_printf("Check animation completed signal not recieved even if animation finished normally at this loop.\n");
+ finishCheck.CheckSignalNotReceived();
+
application.SendNotification();
- application.Render(1000);
- application.Render(1000);
+ application.Render(1100);
+ application.Render(1100);
application.Render(1100 /* Over the loop count */);
application.SendNotification(); // Notification trigger.
- // Check animation completed signal not recieved even of
+ tet_printf("Check animation completed signal not recieved even if animation finished normally.\n");
+ finishCheck.CheckSignalNotReceived();
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1500 /* 150% of loop. */);
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 1, TEST_LOCATION);
+
+ animation.Stop();
+ animation.Clear();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification(); // Notification trigger.
+
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
+
+ tet_printf("Check animation completed signal not recieved even if we call Stop forcibly.\n");
finishCheck.CheckSignalNotReceived();
- // Call clear again already cleared cases.
animation.Clear();
DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+
+ animation.Play();
+
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::PLAYING, TEST_LOCATION);
DALI_TEST_EQUALS(animation.GetCurrentLoop(), 0, TEST_LOCATION);
application.SendNotification();
- application.Render(1000);
- application.Render(1000);
+ application.Render(1100);
+ application.Render(1100);
application.Render(1100 /* Over the loop count */);
application.SendNotification(); // Notification trigger.
- // Check animation completed signal not recieved even of
- finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS(animation.GetState(), Dali::Animation::STOPPED, TEST_LOCATION);
+ DALI_TEST_EQUALS(animation.GetCurrentLoop(), 3, TEST_LOCATION);
+
+ tet_printf("Check animation completed signal recieved. (Since clear didn't disconnect complete signal)\n");
+ finishCheck.CheckSignalReceived();
+ finishCheck.Reset();
}
catch(...)
{
DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
+
+ // If we call Clear before, The animation didn't give any effort to actor now. Let we check it
+ if(functionToTest == TestFunction::CLEAR)
+ {
+ actor.SetProperty(Actor::Property::POSITION, originalPosition);
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), expectedValueTable[i].expectedGetPropertyValue, VECTOR3_EPSILON, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+
+ // Start the animation, which we already clear.
+ animation.Play();
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(halfAnimationDuration);
+
+ DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(), originalPosition, VECTOR3_EPSILON, TEST_LOCATION);
+ }
}
}
} // unnamed namespace
int32_t Animation::GetCurrentLoop()
{
- return mCurrentLoop;
+ int32_t loopCount = 0;
+ if(mAnimation) // always exists in practice
+ {
+ loopCount = mAnimation->GetCurrentLoop();
+ }
+
+ return loopCount;
}
bool Animation::IsLooping() const
void Animation::Play()
{
+ mPlayCalled = true;
+
// Update the current playlist
mPlaylist.OnPlay(*this);
{
if(progress >= mPlayRange.x && progress <= mPlayRange.y)
{
+ mPlayCalled = true;
+
// Update the current playlist
mPlaylist.OnPlay(*this);
void Animation::PlayAfter(float delaySeconds)
{
+ mPlayCalled = true;
+
// The negative delay means play immediately.
delaySeconds = std::max(0.f, delaySeconds);
void Animation::Pause()
{
- mState = Dali::Animation::PAUSED;
+ if(mState != Dali::Animation::PAUSED)
+ {
+ mState = Dali::Animation::PAUSED;
- // mAnimation is being used in a separate thread; queue a Pause message
- PauseAnimationMessage(mEventThreadServices, *mAnimation);
+ // mAnimation is being used in a separate thread; queue a Pause message
+ PauseAnimationMessage(mEventThreadServices, *mAnimation);
- // Notify the objects with the _paused_, i.e. current values
- NotifyObjects(Notify::FORCE_CURRENT_VALUE);
+ // Notify the objects with the _paused_, i.e. current values
+ NotifyObjects(Notify::FORCE_CURRENT_VALUE);
+ }
}
Dali::Animation::State Animation::GetState() const
void Animation::Stop()
{
- mState = Dali::Animation::STOPPED;
+ if(mState != Dali::Animation::STOPPED)
+ {
+ mState = Dali::Animation::STOPPED;
- // mAnimation is being used in a separate thread; queue a Stop message
- StopAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
+ // mAnimation is being used in a separate thread; queue a Stop message
+ StopAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
- // Only notify the objects with the _stopped_, i.e. current values if the end action is set to BAKE
- if(mEndAction == EndAction::BAKE)
- {
- NotifyObjects(Notify::USE_CURRENT_VALUE);
+ // Only notify the objects with the _stopped_, i.e. current values if the end action is set to BAKE
+ if(mEndAction == EndAction::BAKE)
+ {
+ NotifyObjects(Notify::USE_CURRENT_VALUE);
+ }
}
}
{
DALI_ASSERT_DEBUG(mAnimation);
- // Recreate scene-object only if animation play now, or connector connected at least 1 times.
- if(mConnectors.Count() == 0u && mState == Dali::Animation::STOPPED)
+ if(mConnectors.Empty() && mState == Dali::Animation::STOPPED && !mPlayCalled)
{
// Animation is empty. Fast-out
return;
mConnectorTargetValues.clear();
mConnectorTargetValuesSortRequired = false;
- // Replace the old scene-object with a new one
- DestroySceneObject();
- CreateSceneObject();
+ // mAnimation is being used in a separate thread; queue a Clear message
+ ClearAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
// Reset the notification count and relative values, since the new scene-object has never been played
mNotificationCount = 0;
- mCurrentLoop = 0;
mState = Dali::Animation::STOPPED;
+ mPlayCalled = false;
// Update the current playlist
mPlaylist.OnClear(*this);
bool hasFinished(false);
const int32_t playedCount(mAnimation->GetPlayedCount());
- // If the play count has been incremented, then another notification is required
- mCurrentLoop = mAnimation->GetCurrentLoop();
-
if(playedCount > mNotificationCount)
{
// Note that only one signal is emitted, if the animation has been played repeatedly