2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include "dali-scene3d/public-api/loader/animation-definition.h"
22 #include <dali-test-suite-utils.h>
25 using namespace Dali::Scene3D::Loader;
27 int UtcDaliAnimationDefinitionStopForModification(void)
30 auto anim = Animation::New(15.f);
33 auto oldEndAction = AnimationDefinition::StopForModification(anim);
34 DALI_TEST_EQUAL(anim.GetState(), Animation::STOPPED);
35 DALI_TEST_EQUAL(oldEndAction, Animation::BAKE);
36 DALI_TEST_EQUAL(anim.GetEndAction(), Animation::DISCARD);
41 int UtcDaliAnimationDefinitionReAnimate(void)
44 auto actor = Actor::New();
45 actor.SetProperty(Actor::Property::NAME, "ChristopherPlummer");
47 auto getActor = [&actor](const Dali::Scene3D::Loader::AnimatedProperty& property) {
48 return actor.FindChildByName(property.mNodeName);
51 for (bool b: { false, true })
53 AnimationDefinition animDef;
54 animDef.mName = "WalkRight";
55 animDef.mDuration = 10.f;
56 animDef.mLoopCount = 2;
57 animDef.mEndAction = Animation::BAKE_FINAL;
58 animDef.mSpeedFactor = .7f;
59 animDef.mProperties.push_back(AnimatedProperty{
64 std::unique_ptr<AnimatedProperty::Value>{ new AnimatedProperty::Value{
65 Property::Value{ Vector3::XAXIS * 100.f },
68 AlphaFunction::EASE_OUT,
69 TimePeriod(animDef.mDuration)
72 auto anim = animDef.ReAnimate(getActor);
73 DALI_TEST_EQUAL(anim.GetDuration(), animDef.mDuration);
74 DALI_TEST_EQUAL(anim.GetEndAction(), animDef.mEndAction);
75 DALI_TEST_EQUAL(anim.GetSpeedFactor(), animDef.mSpeedFactor);
76 DALI_TEST_EQUAL(anim.GetLoopCount(), animDef.mLoopCount);
82 int UtcDaliAnimationDefinitionReAnimateKeyFrames(void)
85 auto actor = Actor::New();
86 actor.SetProperty(Actor::Property::NAME, "ChristopherPlummer");
88 auto getActor = [&actor](const Dali::Scene3D::Loader::AnimatedProperty& property) {
89 return actor.FindChildByName(property.mNodeName);
92 KeyFrames kf = KeyFrames::New();
93 kf.Add(0.f, Vector3::ZERO);
94 kf.Add(1.f, Vector3::XAXIS * 100.f);
96 AnimationDefinition animDef;
97 animDef.mName = "WalkRight";
98 animDef.mDuration = 10.f;
99 animDef.mLoopCount = 2;
100 animDef.mEndAction = Animation::BAKE_FINAL;
101 animDef.mSpeedFactor = .7f;
102 animDef.mProperties.push_back(AnimatedProperty{
104 "ChristopherPlummer",
108 AlphaFunction::EASE_OUT,
109 TimePeriod(animDef.mDuration)
112 auto anim = animDef.ReAnimate(getActor);
113 DALI_TEST_EQUAL(anim.GetDuration(), animDef.mDuration);
114 DALI_TEST_EQUAL(anim.GetEndAction(), animDef.mEndAction);
115 DALI_TEST_EQUAL(anim.GetSpeedFactor(), animDef.mSpeedFactor);
116 DALI_TEST_EQUAL(anim.GetLoopCount(), animDef.mLoopCount);