DALI_TEST_CHECK(animation.GetAnimationId() == previousId);
END_TEST;
+}
+
+int UtcDaliAnimationFinishedNotEmittedAfterClear(void)
+{
+ tet_infoline("UtcDaliAnimationFinishedNotEmittedAfterClear");
+
+ TestApplication application;
+
+ auto actor = Actor::New();
+ actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
+ application.GetScene().Add(actor);
+
+ auto animation = Animation::New(1.0f);
+ const float origY = actor.GetProperty(Actor::Property::POSITION_Y).Get<float>();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(150.0f, origY, 0.0f), TimePeriod(1.0f));
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(500);
+ // Animation finished.
+ application.Render(501);
+
+ uint32_t animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ finishCheck.CheckSignalNotReceived();
+
+ // Send clear.
+ animation.Clear();
+
+ application.SendNotification();
+
+ // Finished signal not emitted.
+ finishCheck.CheckSignalNotReceived();
+
+ END_TEST;
+}
+
+int UtcDaliAnimationReferenceCountCheck01(void)
+{
+ tet_infoline("UtcDaliAnimationReferenceCountCheck01");
+
+ TestApplication application;
+
+ auto actor = Actor::New();
+ actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
+ application.GetScene().Add(actor);
+
+ auto animation = Animation::New(1.0f);
+ const float origY = actor.GetProperty(Actor::Property::POSITION_Y).Get<float>();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(150.0f, origY, 0.0f), TimePeriod(1.0f));
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(500);
+
+ uint32_t animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ animation.Reset(); // Remove reference count.
+
+ // Still reference count is 1 since it is animated now.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Animation finished.
+ application.Render(501);
+
+ // Still reference count is 1 since it is animated now.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Send finished signal, and then dereferenced
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationReferenceCountCheck02(void)
+{
+ tet_infoline("UtcDaliAnimationReferenceCountCheck02");
+
+ TestApplication application;
+
+ auto actor = Actor::New();
+ actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
+ application.GetScene().Add(actor);
+
+ auto animation = Animation::New(1.0f);
+ const float origY = actor.GetProperty(Actor::Property::POSITION_Y).Get<float>();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(150.0f, origY, 0.0f), TimePeriod(1.0f));
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(500);
+
+ uint32_t animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Send stop.
+ animation.Stop();
+ animation.Reset(); // Remove reference count.
+
+ // Still reference count is 1 since it is animated now.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Animation not finished. But we send Stop(). So finished callback should be emitted.
+ application.SendNotification();
+ application.Render(1);
+
+ // Still reference count is 1 since it is animated now.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Send finished signal, and then dereferenced
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationReferenceCountCheck03(void)
+{
+ tet_infoline("UtcDaliAnimationReferenceCountCheck03");
+
+ TestApplication application;
+
+ auto actor = Actor::New();
+ actor.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
+ application.GetScene().Add(actor);
+
+ auto animation = Animation::New(1.0f);
+ const float origY = actor.GetProperty(Actor::Property::POSITION_Y).Get<float>();
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(150.0f, origY, 0.0f), TimePeriod(1.0f));
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(500);
+
+ uint32_t animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 1, TEST_LOCATION);
+
+ // Send stop and clear.
+ animation.Stop();
+ animation.Clear();
+ animation.Reset(); // Remove reference count.
+
+ // Now reference count is 0 since we dont need to keep it's reference anymore.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 0, TEST_LOCATION);
+
+ // Animation not finished. But we send Clear(). So finished callback should not be emitted.
+ application.SendNotification();
+ application.Render(1);
+
+ // Still reference count is 1 since it is animated now.
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 0, TEST_LOCATION);
+
+ // Finished signal not emitted, and then dereferenced
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ animationCount = Dali::DevelAnimation::GetAnimationCount();
+ DALI_TEST_EQUALS(animationCount, 0, TEST_LOCATION);
+
+ END_TEST;
}
\ No newline at end of file
void AnimationPlaylist::OnPlay(Animation& animation)
{
Dali::Animation handle = Dali::Animation(&animation);
- auto iter = mPlaylist.lower_bound(handle);
- if(iter != mPlaylist.end() && (*iter).first == handle)
- {
- // Just increase reference count.
- ++(iter->second);
- }
- else
- {
- mPlaylist.insert(iter, {handle, 1u});
- }
+ mPlaylist.insert(handle);
}
-void AnimationPlaylist::OnClear(Animation& animation)
+void AnimationPlaylist::OnClear(Animation& animation, bool ignoreRequired)
{
Dali::Animation handle = Dali::Animation(&animation);
auto iter = mPlaylist.find(handle);
// Animation might be removed when NotifyCompleted called.
if(DALI_LIKELY(iter != mPlaylist.end()))
{
- // Just decrease reference count. But if reference count is zero, remove it.
- if(--(iter->second) == 0u)
- {
- mPlaylist.erase(iter);
- }
+ mPlaylist.erase(iter);
}
+
+ if(ignoreRequired)
+ {
+ mIgnoredAnimations.insert(animation.GetAnimationId());
+ }
+}
+
+void AnimationPlaylist::EventLoopFinished()
+{
+ mIgnoredAnimations.clear();
}
void AnimationPlaylist::NotifyProgressReached(NotifierInterface::NotifyId notifyId)
{
Dali::Animation handle; // Will own handle until all emits have been done.
- auto* animation = GetEventObject(notifyId);
- if(DALI_LIKELY(animation))
+ if(DALI_LIKELY(mIgnoredAnimations.find(notifyId) == mIgnoredAnimations.end()))
{
- // Check if this animation hold inputed scenegraph animation.
- DALI_ASSERT_DEBUG(animation->GetSceneObject()->GetNotifyId() == notifyId);
+ auto* animation = GetEventObject(notifyId);
+ if(DALI_LIKELY(animation))
+ {
+ // Check if this animation hold inputed scenegraph animation.
+ DALI_ASSERT_DEBUG(animation->GetSceneObject()->GetNotifyId() == notifyId);
- handle = Dali::Animation(animation);
- animation->EmitSignalProgressReached();
+ handle = Dali::Animation(animation);
+ animation->EmitSignalProgressReached();
+ }
}
}
#endif
DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_ANIMATION_FINISHED", [&](std::ostringstream& oss) {
- oss << "[n:" << notifierIdList.Count() << "]";
+ oss << "[n:" << notifierIdList.Count() << ", i:" << mIgnoredAnimations.size() << "]";
});
for(const auto& notifierId : notifierIdList)
{
- auto* animation = GetEventObject(notifierId);
- if(DALI_LIKELY(animation))
+ if(DALI_LIKELY(mIgnoredAnimations.find(notifierId) == mIgnoredAnimations.end()))
{
- // Check if this animation hold inputed scenegraph animation.
- DALI_ASSERT_DEBUG(animation->GetSceneObject()->GetNotifyId() == notifierId);
-
- // Update loop count. And check whether animation was finished or not.
- if(animation->HasFinished())
+ auto* animation = GetEventObject(notifierId);
+ if(DALI_LIKELY(animation))
{
- finishedAnimations.push_back(Dali::Animation(animation));
-
- // The animation may be present in mPlaylist - remove if necessary
- // Note that the animation "Finish" signal is emitted after Stop() has been called
- OnClear(*animation);
+ // Check if this animation hold inputed scenegraph animation.
+ DALI_ASSERT_DEBUG(animation->GetSceneObject()->GetNotifyId() == notifierId);
+
+ // Update loop count. And check whether animation was finished or not.
+ if(animation->HasFinished())
+ {
+ finishedAnimations.push_back(Dali::Animation(animation));
+
+ // The animation may be present in mPlaylist - remove if necessary
+ // Note that the animation "Finish" signal is emitted after Stop() has been called
+ OnClear(*animation, false);
+ }
}
}
}