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-scene-loader/public-api/animation-definition.h"
22 #include <dali-test-suite-utils.h>
25 using namespace Dali::SceneLoader;
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 std::string& name) {
48 return actor.FindChildByName(name);
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{
63 std::unique_ptr<AnimatedProperty::Value>{ new AnimatedProperty::Value{
64 Property::Value{ Vector3::XAXIS * 100.f },
67 AlphaFunction::EASE_OUT,
68 TimePeriod(animDef.mDuration)
71 auto anim = animDef.ReAnimate(getActor);
72 DALI_TEST_EQUAL(anim.GetDuration(), animDef.mDuration);
73 DALI_TEST_EQUAL(anim.GetEndAction(), animDef.mEndAction);
74 DALI_TEST_EQUAL(anim.GetSpeedFactor(), animDef.mSpeedFactor);
75 DALI_TEST_EQUAL(anim.GetLoopCount(), animDef.mLoopCount);
81 int UtcDaliAnimationDefinitionReAnimateKeyFrames(void)
84 auto actor = Actor::New();
85 actor.SetProperty(Actor::Property::NAME, "ChristopherPlummer");
87 auto getActor = [&actor](const std::string& name) {
88 return actor.FindChildByName(name);
91 KeyFrames kf = KeyFrames::New();
92 kf.Add(0.f, Vector3::ZERO);
93 kf.Add(1.f, Vector3::XAXIS * 100.f);
95 AnimationDefinition animDef;
96 animDef.mName = "WalkRight";
97 animDef.mDuration = 10.f;
98 animDef.mLoopCount = 2;
99 animDef.mEndAction = Animation::BAKE_FINAL;
100 animDef.mSpeedFactor = .7f;
101 animDef.mProperties.push_back(AnimatedProperty{
102 "ChristopherPlummer",
106 AlphaFunction::EASE_OUT,
107 TimePeriod(animDef.mDuration)
110 auto anim = animDef.ReAnimate(getActor);
111 DALI_TEST_EQUAL(anim.GetDuration(), animDef.mDuration);
112 DALI_TEST_EQUAL(anim.GetEndAction(), animDef.mEndAction);
113 DALI_TEST_EQUAL(anim.GetSpeedFactor(), animDef.mSpeedFactor);
114 DALI_TEST_EQUAL(anim.GetLoopCount(), animDef.mLoopCount);