1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "adapter/aosp/entrance/java/jni/jni_environment.h"
19 #include "base/log/log.h"
20 #include "base/test/mock/mock_asset_manager.h"
21 #include "test/mock/base/mock_task_executor.h"
22 #include "core/animation/card_transition_controller.h"
23 #include "core/animation/friction_motion.h"
24 #include "core/animation/scroll_motion.h"
25 #include "core/animation/spring_motion.h"
26 #include "core/animation/test/mock/mock_animation.h"
27 #include "core/animation/test/mock/mock_animation_util.h"
28 #include "core/common/test/mock/mock_resource_register.h"
29 #include "core/components/test/json/json_frontend.h"
30 #include "core/pipeline/pipeline_context.h"
31 
32 using namespace testing;
33 using namespace testing::ext;
34 
35 namespace OHOS::Ace {
CardTransitionController(const WeakPtr<PipelineContext> & context)36 CardTransitionController::CardTransitionController(const WeakPtr<PipelineContext>& context) {}
37 
RegisterTransitionListener()38 void CardTransitionController::RegisterTransitionListener() {}
39 
GetCardRect(const ComposeId & composeId) const40 RRect CardTransitionController::GetCardRect(const ComposeId& composeId) const
41 {
42     return RRect();
43 }
44 
JniEnvironment()45 Platform::JniEnvironment::JniEnvironment() {}
46 
47 Platform::JniEnvironment::~JniEnvironment() = default;
48 
GetJniEnv(JNIEnv * jniEnv) const49 std::shared_ptr<JNIEnv> Platform::JniEnvironment::GetJniEnv(JNIEnv* jniEnv) const
50 {
51     return nullptr;
52 }
53 
GetInstance()54 Platform::JniEnvironment& Platform::JniEnvironment::GetInstance()
55 {
56     static Platform::JniEnvironment jniEnvironment;
57     return jniEnvironment;
58 }
59 
60 namespace {
61 
62 constexpr int32_t NANOSECOND_TO_MILLISECOND = 1000000;
63 constexpr int32_t PICTURE_ANIMATION_COUNT = 3;
64 constexpr int32_t FRAME_TIME_IN_MILLISECOND = 10;
65 constexpr int32_t ANIMATION_REPEAT_LOOP = 10;
66 constexpr uint32_t ANIMATION_DURATION_MULTIPLE = 3;
67 constexpr uint32_t PICTURE_ANIMATION_DURATION_MULTIPLE = 2;
68 constexpr uint32_t KEYFRAME_ANIMATION_DURATION_MULTIPLE = 2;
69 constexpr uint64_t NANO_FRAME_TIME = static_cast<const uint64_t>(1e9 / 60);
70 constexpr float CUBIC_ERROR_BOUND = 0.01f;
71 
72 } // namespace
73 
74 class AnimationFrameworkTest : public testing::Test {
75 public:
SetUpTestCase()76     static void SetUpTestCase()
77     {
78         GTEST_LOG_(INFO) << "AnimationFrameworkTest SetUpTestCase";
79     }
80 
TearDownTestCase()81     static void TearDownTestCase()
82     {
83         GTEST_LOG_(INFO) << "AnimationFrameworkTest TearDownTestCase";
84     }
85 
SetUp()86     void SetUp() override
87     {
88         std::unique_ptr<PlatformWindow> platformWindow = AnimationTestUtils::CreatePlatformWindow();
89         platformWindowRaw_ = reinterpret_cast<MockPlatformWindow*>(platformWindow.get());
90         auto window = AnimationTestUtils::CreateWindow(std::move(platformWindow));
91         auto taskExecutor = AceType::MakeRefPtr<MockTaskExecutor>();
92         auto assetManager = Referenced::MakeRefPtr<MockAssetManager>();
93         auto resRegister = Referenced::MakeRefPtr<MockResourceRegister>();
94         RefPtr<Frontend> frontend = Frontend::CreateDefault();
95         context_ = AceType::MakeRefPtr<PipelineContext>(
96             std::move(window), taskExecutor, assetManager, resRegister, frontend, 0);
97         context_->SetTimeProvider(
98             [this] { return this->platformWindowRaw_->GetCurrentTimestampNano() + NANOSECOND_TO_MILLISECOND * 10; });
99         flushEventMock_ = AceType::MakeRefPtr<MockAnimation>();
100 
101         context_->SetupRootElement();
102         context_->OnSurfaceChanged(100, 200);
103     }
104 
TearDown()105     void TearDown() override {}
106 
TriggerAndCheckBasicPropertyFirstFrame(AnimationOperation operation,float init) const107     void TriggerAndCheckBasicPropertyFirstFrame(AnimationOperation operation, float init) const
108     {
109         /**
110          * @tc.steps: step2. trigger one frame to make prepare animation work
111          */
112         platformWindowRaw_->TriggerOneFrame();
113         switch (operation) {
114             case AnimationOperation::PLAY:
115             case AnimationOperation::REVERSE: {
116                 EXPECT_EQ(init - 1, flushEventMock_->animationIntValue_);
117                 EXPECT_TRUE(flushEventMock_->animationStartStatus_);
118                 EXPECT_FALSE(flushEventMock_->animationStopStatus_);
119                 break;
120             }
121             case AnimationOperation::PAUSE: {
122                 EXPECT_TRUE(flushEventMock_->animationStartStatus_);
123                 EXPECT_TRUE(flushEventMock_->animationPauseStatus_);
124                 EXPECT_FALSE(flushEventMock_->animationStopStatus_);
125                 break;
126             }
127             case AnimationOperation::FINISH: {
128                 EXPECT_TRUE(flushEventMock_->animationStopStatus_);
129                 break;
130             }
131             case AnimationOperation::CANCEL: {
132                 EXPECT_FALSE(flushEventMock_->animationIdleStatus_);
133                 EXPECT_FALSE(flushEventMock_->animationStartStatus_);
134                 EXPECT_FALSE(flushEventMock_->animationPauseStatus_);
135                 EXPECT_FALSE(flushEventMock_->animationStopStatus_);
136                 break;
137             }
138             default:
139                 break;
140         }
141     }
142 
InitBasicAnimationDirectionPropertyTest(int32_t duration,int32_t iteration,AnimationDirection animationDirection,AnimationOperation operation,FillMode fillMode)143     void InitBasicAnimationDirectionPropertyTest(int32_t duration, int32_t iteration,
144         AnimationDirection animationDirection, AnimationOperation operation, FillMode fillMode)
145     {
146         /**
147          * @tc.steps: step1. init animation and simulation controller
148          */
149         float init = 0.0f;
150         float begin = 1.0f;
151         float end = 9.0f;
152 
153         platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * 10);
154         flushEventMock_->InitController(context_);
155         auto controller = flushEventMock_->GetAnimator();
156         // verify curve animation
157         flushEventMock_->animationInt_ =
158             AceType::MakeRefPtr<CurveAnimation<int>>(static_cast<int>(begin), static_cast<int>(end), Curves::LINEAR);
159 
160         // verify keyframe animation
161         auto keyframe1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
162         auto keyframe2 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
163         keyframe2->SetCurve(Curves::LINEAR);
164         flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
165         flushEventMock_->keyframeAnimation_->AddKeyframe(keyframe1);
166         flushEventMock_->keyframeAnimation_->AddKeyframe(keyframe2);
167 
168         flushEventMock_->animationInt_->SetInitValue(static_cast<int>(init));
169         flushEventMock_->keyframeAnimation_->SetInitValue(init);
170 
171         // set duration / fill-mode / animationDirection / reverse / repeatTimes
172         flushEventMock_->animationDuration_ = duration;
173         controller->SetFillMode(fillMode);
174         controller->SetAnimationDirection(animationDirection);
175         flushEventMock_->operation_ = operation;
176         flushEventMock_->iteration_ = iteration;
177 
178         flushEventMock_->animationIntValue_ = init - 1;
179         context_->AddPostFlushListener(flushEventMock_);
180         TriggerAndCheckBasicPropertyFirstFrame(operation, init);
181     }
182 
InitBasicPropertyTest(int32_t duration,int32_t iteration,AnimationOperation operation,FillMode fillMode,bool setInit)183     void InitBasicPropertyTest(
184         int32_t duration, int32_t iteration, AnimationOperation operation, FillMode fillMode, bool setInit)
185     {
186         /**
187          * @tc.steps: step1. init animation and animator
188          */
189         float init = 0.0f;
190         float begin = 1.0f;
191         float end = 9.0f;
192         platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * 10);
193         flushEventMock_->InitController(context_);
194         auto controller = flushEventMock_->GetAnimator();
195         // verify curve animation
196         flushEventMock_->animationInt_ =
197             AceType::MakeRefPtr<CurveAnimation<int>>(static_cast<int>(begin), static_cast<int>(end), Curves::LINEAR);
198 
199         // verify keyframe animation
200         auto keyframe1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
201         auto keyframe2 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
202         keyframe2->SetCurve(Curves::LINEAR);
203         flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
204         flushEventMock_->keyframeAnimation_->AddKeyframe(keyframe1);
205         flushEventMock_->keyframeAnimation_->AddKeyframe(keyframe2);
206 
207         if (setInit) {
208             flushEventMock_->animationInt_->SetInitValue(static_cast<int>(init));
209             flushEventMock_->keyframeAnimation_->SetInitValue(init);
210         }
211 
212         // set duration / fill-mode / reverse / repeatTimes / startDelay
213         flushEventMock_->animationDuration_ = duration;
214         controller->SetFillMode(fillMode);
215         flushEventMock_->operation_ = operation;
216         flushEventMock_->iteration_ = iteration;
217         if (iteration == 2) {
218             flushEventMock_->startDelay_ = 10;
219         }
220 
221         flushEventMock_->animationIntValue_ = init - 1;
222         context_->AddPostFlushListener(flushEventMock_);
223 
224         TriggerAndCheckBasicPropertyFirstFrame(operation, init);
225     }
226 
RunAndCheckBasicPropertyTestInterpolateValueReverse(float endValue)227     void RunAndCheckBasicPropertyTestInterpolateValueReverse(float endValue)
228     {
229         platformWindowRaw_->TriggerOneFrame();
230         EXPECT_EQ(5, flushEventMock_->animationIntValue_);
231         EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
232         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
233 
234         platformWindowRaw_->TriggerOneFrame();
235         EXPECT_EQ(static_cast<int32_t>(endValue), flushEventMock_->animationIntValue_);
236         EXPECT_NEAR(endValue, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
237         EXPECT_TRUE(flushEventMock_->animationStopStatus_);
238     }
239 
RunAndCheckBasicPropertyTestInterpolateValueForward(float endValue)240     void RunAndCheckBasicPropertyTestInterpolateValueForward(float endValue)
241     {
242         platformWindowRaw_->TriggerOneFrame();
243         EXPECT_EQ(5, flushEventMock_->animationIntValue_);
244         EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
245         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
246 
247         platformWindowRaw_->TriggerOneFrame();
248         EXPECT_EQ(static_cast<int32_t>(endValue), flushEventMock_->animationIntValue_);
249         EXPECT_NEAR(endValue, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
250         EXPECT_TRUE(flushEventMock_->animationStopStatus_);
251     }
252 
RunAndCheckBasicPropertyTestInterpolateValue(float endValue)253     void RunAndCheckBasicPropertyTestInterpolateValue(float endValue)
254     {
255         if (flushEventMock_->startDelay_ == 10) {
256             platformWindowRaw_->TriggerOneFrame();
257         }
258         // duration equals 0, stop immediately
259         if (flushEventMock_->animationDuration_ == 0) {
260             platformWindowRaw_->TriggerOneFrame();
261             EXPECT_EQ(static_cast<int32_t>(endValue), flushEventMock_->animationIntValue_);
262             EXPECT_NEAR(endValue, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
263             EXPECT_TRUE(flushEventMock_->animationStopStatus_);
264             return;
265         }
266 
267         switch (flushEventMock_->operation_) {
268             case AnimationOperation::REVERSE: {
269                 RunAndCheckBasicPropertyTestInterpolateValueReverse(endValue);
270                 break;
271             }
272             case AnimationOperation::PLAY: {
273                 RunAndCheckBasicPropertyTestInterpolateValueForward(endValue);
274                 break;
275             }
276             default:
277                 break;
278         }
279     }
280 
RunAndCheckBasicAnimationDirectionPropertyTestReverse()281     void RunAndCheckBasicAnimationDirectionPropertyTestReverse()
282     {
283         platformWindowRaw_->TriggerOneFrame();
284         EXPECT_EQ(5, flushEventMock_->animationIntValue_);
285         EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
286         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
287 
288         platformWindowRaw_->TriggerOneFrame();
289         EXPECT_EQ(1, flushEventMock_->animationIntValue_);
290         EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
291         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
292     }
293 
RunAndCheckBasicAnimationDirectionPropertyTestForward()294     void RunAndCheckBasicAnimationDirectionPropertyTestForward()
295     {
296         platformWindowRaw_->TriggerOneFrame();
297         EXPECT_EQ(5, flushEventMock_->animationIntValue_);
298         EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
299         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
300 
301         platformWindowRaw_->TriggerOneFrame();
302         EXPECT_EQ(9, flushEventMock_->animationIntValue_);
303         EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
304         EXPECT_FALSE(flushEventMock_->animationStopStatus_);
305     }
306 
RunAndCheckBasicAnimationDirectionPropertyTest(float endValue,int iteration)307     void RunAndCheckBasicAnimationDirectionPropertyTest(float endValue, int iteration)
308     {
309         if (iteration == 2) {
310             RunAndCheckBasicAnimationDirectionPropertyTestForward();
311 
312             /**
313              * @tc.steps1: repeat animation
314              * @tc.expected: check repeat animation value is correct
315              */
316             RunAndCheckBasicPropertyTestInterpolateValueReverse(endValue);
317         } else {
318             // iteration is 3
319             switch (flushEventMock_->operation_) {
320                 case AnimationOperation::REVERSE: {
321                     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
322 
323                     /**
324                      * @tc.steps1: repeat animation
325                      * @tc.expected: check repeat animation value is correct
326                      */
327                     RunAndCheckBasicAnimationDirectionPropertyTestForward();
328 
329                     /**
330                      * @tc.steps2: repeat animation
331                      * @tc.expected: check repeat animation value is correct
332                      */
333                     RunAndCheckBasicPropertyTestInterpolateValueReverse(endValue);
334                     break;
335                 }
336                 case AnimationOperation::PLAY: {
337                     RunAndCheckBasicAnimationDirectionPropertyTestForward();
338 
339                     /**
340                      * @tc.steps1: repeat animation
341                      * @tc.expected: check repeat animation value is correct
342                      */
343                     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
344 
345                     /**
346                      * @tc.steps2: repeat animation
347                      * @tc.expected: check repeat animation value is correct
348                      */
349                     RunAndCheckBasicPropertyTestInterpolateValueForward(endValue);
350                     break;
351                 }
352                 default:
353                     break;
354             }
355         }
356     }
357 
InitAnimationAndAnimator(int32_t frameTimeMs,int32_t iteration,int32_t startDelay)358     void InitAnimationAndAnimator(int32_t frameTimeMs, int32_t iteration, int32_t startDelay)
359     {
360         InitAnimationAndAnimator(frameTimeMs, iteration, startDelay, frameTimeMs * ANIMATION_DURATION_MULTIPLE);
361     }
362 
InitAnimationAndAnimator(int32_t frameTimeMs,int32_t iteration,int32_t startDelay,int32_t duration)363     void InitAnimationAndAnimator(int32_t frameTimeMs, int32_t iteration, int32_t startDelay, int32_t duration)
364     {
365         platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
366         flushEventMock_->InitController(context_);
367         flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
368         flushEventMock_->animationDuration_ = duration;
369         flushEventMock_->startDelay_ = startDelay;
370         flushEventMock_->iteration_ = iteration;
371         context_->AddPostFlushListener(flushEventMock_);
372     }
373 
374 protected:
375     RefPtr<PipelineContext> context_;
376     RefPtr<MockAnimation> flushEventMock_;
377     MockPlatformWindow* platformWindowRaw_ = nullptr;
378 };
379 
380 /**
381  * @tc.name: AnimationFrameworkTest001
382  * @tc.desc: Verify the common property animation process for type int
383  * @tc.type: FUNC
384  * @tc.require: AR000DAIGS
385  * @tc.author: zhouzebin
386  */
387 HWTEST_F(AnimationFrameworkTest, AnimationFrameworkTest001, TestSize.Level1)
388 {
389     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrameworkTest001 start";
390     /**
391      * @tc.steps: step1. init animation and animator
392      */
393     flushEventMock_->InitController(context_);
394     int32_t duration = 30;
395     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 6, Curves::LINEAR);
396     flushEventMock_->animationDuration_ = duration;
397     context_->AddPostFlushListener(flushEventMock_);
398 
399     /**
400      * @tc.steps: step2. trigger one frame to make prepare animation work
401      * @tc.expected: step2. postFlush has been called.
402      */
403     platformWindowRaw_->TriggerOneFrame();
404     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
405 
406     /**
407      * @tc.steps: step3. trigger 2 frames to let animation done
408      * @tc.expected: step3. check linear curve's value in every frame
409      */
410     platformWindowRaw_->TriggerOneFrame();
411     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
412 
413     platformWindowRaw_->TriggerOneFrame();
414     EXPECT_EQ(6, flushEventMock_->animationIntValue_);
415     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
416 }
417 
418 /**
419  * @tc.name: AnimationFrameworkTest002
420  * @tc.desc: Verify the common property animation process for type float
421  * @tc.type: FUNC
422  * @tc.require: AR000DAIGS
423  * @tc.author: zhouzebin
424  */
425 HWTEST_F(AnimationFrameworkTest, AnimationFrameworkTest002, TestSize.Level1)
426 {
427     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrameworkTest002 start";
428     /**
429      * @tc.steps: step1. init animation and animator
430      */
431     flushEventMock_->InitController(context_);
432     int32_t duration = 30;
433     // default curve is linear. test it with nullptr.
434     flushEventMock_->animationFloat_ = AceType::MakeRefPtr<CurveAnimation<float>>(1.0f, 6.0f, nullptr);
435     flushEventMock_->animationDuration_ = duration;
436     context_->AddPostFlushListener(flushEventMock_);
437 
438     /**
439      * @tc.steps: step2. trigger one frame to make prepare animation work
440      * @tc.expected: step2. postFlush has been called.
441      */
442     platformWindowRaw_->TriggerOneFrame();
443     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
444 
445     /**
446      * @tc.steps: step3. trigger 2 frames to let animation done
447      * @tc.expected: step3. check linear curve's value in every frame
448      */
449     platformWindowRaw_->TriggerOneFrame();
450     EXPECT_NEAR(5.164f, flushEventMock_->animationFloatValue_, CUBIC_ERROR_BOUND);
451 
452     platformWindowRaw_->TriggerOneFrame();
453     EXPECT_NEAR(6.0f, flushEventMock_->animationFloatValue_, CUBIC_ERROR_BOUND);
454     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
455 }
456 
457 /**
458  * @tc.name: AnimationFrameworkTest003
459  * @tc.desc: when destruct animator, stop it first.
460  * @tc.type: FUNC
461  * @tc.require: AR000DAIGS
462  * @tc.author: zhouzebin
463  */
464 HWTEST_F(AnimationFrameworkTest, AnimationFrameworkTest003, TestSize.Level1)
465 {
466     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrameworkTest003 start";
467     /**
468      * @tc.steps: step1. init animation and animator
469      */
470     flushEventMock_->InitController(context_);
471     int32_t duration = 30;
472     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 6, Curves::LINEAR);
473     int32_t previousValue = 0;
__anonf8f9cd0e0302(const int& value) 474     flushEventMock_->animationInt_->AddListener([&previousValue](const int& value) {
475         // check different value every callback.
476         EXPECT_NE(previousValue, value);
477         previousValue = value;
478     });
479     flushEventMock_->animationDuration_ = duration;
480     context_->AddPostFlushListener(flushEventMock_);
481 
482     /**
483      * @tc.steps: step2. trigger one frame to make prepare animation work
484      * @tc.expected: step2. postFlush has been called.
485      */
486     platformWindowRaw_->TriggerOneFrame();
487     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
488 
489     /**
490      * @tc.steps: step3. free the old controller and write data to the freed memory
491      * @tc.expected: step3. no fault happened, and no call back has been called.
492      */
493     // get the reference for controller and set the value after the controller is destructed.
494     Animator& controller = *flushEventMock_->GetAnimator();
495 
496     // replace controller with a new one. and the old controller's destructor will be called
497     flushEventMock_->InitController(context_);
498     // clear all callbacks in destructor
499     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
500 
501     // set the freed old controller's memory to test do not call back to old memory.
502     controller.SetDuration(0);
503     platformWindowRaw_->TriggerOneFrame();
504     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
505 }
506 
507 /**
508  * @tc.name: AnimationFrameworkTest004
509  * @tc.desc: use color curve animation
510  * @tc.type: FUNC
511  * @tc.require: AR000DAIGS
512  * @tc.author: zhouzebin
513  */
514 HWTEST_F(AnimationFrameworkTest, AnimationFrameworkTest004, TestSize.Level1)
515 {
516     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrameworkTest004 start";
517     /**
518      * @tc.steps: step1. init animation and animator
519      */
520     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
521     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
522     flushEventMock_->InitController(context_);
523     int32_t duration = 30;
524     flushEventMock_->animationColor_ =
525         AceType::MakeRefPtr<CurveAnimation<Color>>(Color::BLACK, Color::WHITE, Curves::LINEAR);
526     flushEventMock_->animationDuration_ = duration;
527     context_->AddPostFlushListener(flushEventMock_);
528 
529     /**
530      * @tc.steps: step2. trigger one frame to make prepare animation work
531      * @tc.expected: step2. postFlush has been called.
532      */
533     platformWindowRaw_->TriggerOneFrame();
534     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
535 
536     /**
537      * @tc.steps: step3. trigger frames to make it done.
538      * @tc.expected: step3. verify the first and last frame
539      */
540     platformWindowRaw_->TriggerOneFrame();
541     EXPECT_EQ(Color(0xff9A9A9A), flushEventMock_->animationColorValue_);
542     platformWindowRaw_->TriggerOneFrame();
543     platformWindowRaw_->TriggerOneFrame();
544     EXPECT_EQ(Color::WHITE, flushEventMock_->animationColorValue_);
545     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
546 }
547 
548 /**
549  * @tc.name: AnimationCurveTest001
550  * @tc.desc: Verify the linear Curve
551  * @tc.type: FUNC
552  * @tc.require: AR000DATTR
553  * @tc.author: jiachunhui
554  */
555 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest001, TestSize.Level1)
556 {
557     /**
558      * @tc.steps: step1. set the testValue of time to test LinearCurve.
559      */
560     float testValueFirst = 0.2f;
561     float testValueSecond = 0.5f;
562     float testValueThird = 0.8f;
563 
564     /**
565      * @tc.steps: step2. verify the result of LinearCurve.
566      * @tc.expected: step2. the result is right.
567      */
568     EXPECT_NEAR(testValueFirst, Curves::LINEAR->MoveInternal(testValueFirst), FLT_EPSILON);
569     EXPECT_NEAR(testValueSecond, Curves::LINEAR->MoveInternal(testValueSecond), FLT_EPSILON);
570     EXPECT_NEAR(testValueThird, Curves::LINEAR->MoveInternal(testValueThird), FLT_EPSILON);
571 }
572 
573 /**
574  * @tc.name: AnimationCurveTest002
575  * @tc.desc: Verify the Sine Curve
576  * @tc.type: FUNC
577  * @tc.require: AR000DATTR
578  * @tc.author: jiachunhui
579  */
580 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest002, TestSize.Level1)
581 {
582     /**
583      * @tc.steps: step1. set the testValue of time to test SineCurve.
584      */
585     float testValueFirst = 0.2f;
586     float testValueSecond = 0.5f;
587     float testValueThird = 0.8f;
588 
589     /**
590      * @tc.steps: step2. set the targetValue of time to test SineCurve.
591      */
592     float pi = 3.14f;
593     float targetValueFirst = std::sin(pi * testValueFirst / 2);
594     float targetValueSecond = std::sin(pi * testValueSecond / 2);
595     float targetValueThird = std::sin(pi * testValueThird / 2);
596 
597     /**
598      * @tc.steps: step3. verify the result of SineCurve.
599      * @tc.expected: step3. the result is right.
600      */
601     EXPECT_NEAR(targetValueFirst, Curves::SINE->MoveInternal(testValueFirst), FLT_EPSILON);
602     EXPECT_NEAR(targetValueSecond, Curves::SINE->MoveInternal(testValueSecond), FLT_EPSILON);
603     EXPECT_NEAR(targetValueThird, Curves::SINE->MoveInternal(testValueThird), FLT_EPSILON);
604 }
605 
606 /**
607  * @tc.name: AnimationCurveTest003
608  * @tc.desc: Verify the Cubic Curve
609  * @tc.type: FUNC
610  * @tc.require: AR000DATTR
611  * @tc.author: jiachunhui
612  */
613 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest003, TestSize.Level1)
614 {
615     /**
616      * @tc.steps: step1. set the testValue of time to test CubicCurve.
617      */
618     float testValueFirst = 0.2f;
619     float testValueSecond = 0.5f;
620     float testValueThird = 0.8f;
621 
622     /**
623      * @tc.steps: step2. set the targetValue and actualValue of time to test CubicCurve.
624      */
625     float targetValueFirst = 0.30836f;
626     float targetValueSecond = 0.68465f;
627     float targetValueThird = 0.93772f;
628 
629     float actualValueFirst = Curves::EASE_OUT->MoveInternal(testValueFirst);
630     float actualValueSecond = Curves::EASE_OUT->MoveInternal(testValueSecond);
631     float actualValueThird = Curves::EASE_OUT->MoveInternal(testValueThird);
632 
633     /**
634      * @tc.steps: step3. verify the result of CubicCurve.
635      * @tc.expected: step3. the result is right.
636      */
637     EXPECT_NEAR(targetValueFirst, actualValueFirst, CUBIC_ERROR_BOUND);
638     EXPECT_NEAR(targetValueSecond, actualValueSecond, CUBIC_ERROR_BOUND);
639     EXPECT_NEAR(targetValueThird, actualValueThird, CUBIC_ERROR_BOUND);
640 }
641 
642 /**
643  * @tc.name: AnimationCurveTest004
644  * @tc.desc: Verify the decelerate Curve
645  * @tc.type: FUNC
646  * @tc.require: AR000DQ1UQ
647  * @tc.author: jinwuwen
648  */
649 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest004, TestSize.Level1)
650 {
651     /**
652      * @tc.steps: step1. set the testValue of time to test decelerate Curve.
653      */
654     float testValueFirst = 0.2f;
655     float testValueSecond = 0.5f;
656     float testValueThird = 0.8f;
657 
658     /**
659      * @tc.steps: step2. set the targetValue of time to test decelerate Curve.
660      */
661     float targetValueFirst = 1.0 - std::pow(1.0 - testValueFirst, 2.0);
662     float targetValueSecond = 1.0 - std::pow(1.0 - testValueSecond, 2.0);
663     float targetValueThird = 1.0 - std::pow(1.0 - testValueThird, 2.0);
664 
665     /**
666      * @tc.steps: step3. verify the result of decelerate Curve.
667      * @tc.expected: step3. the result is right.
668      */
669     EXPECT_NEAR(targetValueFirst, Curves::DECELE->MoveInternal(testValueFirst), FLT_EPSILON);
670     EXPECT_NEAR(targetValueSecond, Curves::DECELE->MoveInternal(testValueSecond), FLT_EPSILON);
671     EXPECT_NEAR(targetValueThird, Curves::DECELE->MoveInternal(testValueThird), FLT_EPSILON);
672 }
673 
674 /**
675  * @tc.name: AnimationCurveTest005
676  * @tc.desc: Verify the Steps Curve with start position
677  * @tc.type: FUNC
678  * @tc.require: AR000DQ20F
679  * @tc.author: zhouzebin
680  */
681 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest005, TestSize.Level1)
682 {
683     int32_t steps = 4;
684     float stepValue = 1.0f / steps;
685     StepsCurve stepsCurveStart(steps, StepsCurvePosition::START);
686     /**
687      * @tc.steps: step1. set the testValue of time to test steps Curve.
688      */
689     float testValueFirst = 0.2f;
690     float testValueSecond = 0.5f;
691     float testValueThird = 0.8f;
692 
693     /**
694      * @tc.steps: step2. set the targetValue of time to test steps Curve.
695      */
696     float targetValueFirst = stepValue;
697     float targetValueSecond = stepValue * 3;
698     float targetValueThird = stepValue * 4;
699 
700     /**
701      * @tc.steps: step3. verify the result of steps Curve.
702      * @tc.expected: step3. the result is right.
703      */
704     EXPECT_NEAR(targetValueFirst, stepsCurveStart.MoveInternal(testValueFirst), FLT_EPSILON);
705     EXPECT_NEAR(targetValueSecond, stepsCurveStart.MoveInternal(testValueSecond), FLT_EPSILON);
706     EXPECT_NEAR(targetValueThird, stepsCurveStart.MoveInternal(testValueThird), FLT_EPSILON);
707 }
708 
709 /**
710  * @tc.name: AnimationDomCurveTest001
711  * @tc.desc: Verify the anticipate Curve
712  * @tc.type: FUNC
713  * @tc.require: AR000DSB24
714  * @tc.author: jiachunhui
715  */
716 HWTEST_F(AnimationFrameworkTest, AnimationDomCurveTest001, TestSize.Level1)
717 {
718     /**
719      * @tc.steps: step1. set the testValue of time to test anticipate Curve.
720      */
721     float testValueFirst = 0.2f;
722     float testValueSecond = 0.5f;
723     float testValueThird = 0.8f;
724 
725     /**
726      * @tc.steps: step2. set the targetValue of time to test anticipate Curve.
727      */
728     float targetValueFirst = -0.056f;
729     float targetValueSecond = -0.125f;
730     float targetValueThird = 0.256f;
731 
732     /**
733      * @tc.steps: step3. verify the result of anticipate Curve.
734      * @tc.expected: step3. the result is right.
735      */
736     EXPECT_NEAR(targetValueFirst, Curves::ANTICIPATE->MoveInternal(testValueFirst), FLT_EPSILON);
737     EXPECT_NEAR(targetValueSecond, Curves::ANTICIPATE->MoveInternal(testValueSecond), FLT_EPSILON);
738     EXPECT_NEAR(targetValueThird, Curves::ANTICIPATE->MoveInternal(testValueThird), FLT_EPSILON);
739 }
740 
741 /**
742  * @tc.name: AnimationCurveTest007
743  * @tc.desc: Verify the Steps Curve with end position
744  * @tc.type: FUNC
745  * @tc.require: AR000DQ20G
746  * @tc.author: zhouzebin
747  */
748 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest007, TestSize.Level1)
749 {
750     int32_t steps = 4;
751     float stepValue = 1.0f / steps;
752     StepsCurve stepsCurveEnd(steps, StepsCurvePosition::END);
753     /**
754      * @tc.steps: step1. set the testValue of time to test steps Curve.
755      */
756     float testValueFirst = 0.2f;
757     float testValueSecond = 0.5f;
758     float testValueThird = 0.8f;
759 
760     /**
761      * @tc.steps: step2. set the targetValue of time to test steps Curve.
762      */
763     float targetValueFirst = 0;
764     float targetValueSecond = stepValue * 2;
765     float targetValueThird = stepValue * 3;
766 
767     /**
768      * @tc.steps: step3. verify the result of steps Curve.
769      * @tc.expected: step3. the result is right.
770      */
771     EXPECT_NEAR(targetValueFirst, stepsCurveEnd.MoveInternal(testValueFirst), FLT_EPSILON);
772     EXPECT_NEAR(targetValueSecond, stepsCurveEnd.MoveInternal(testValueSecond), FLT_EPSILON);
773     EXPECT_NEAR(targetValueThird, stepsCurveEnd.MoveInternal(testValueThird), FLT_EPSILON);
774 }
775 
776 /**
777  * @tc.name: AnimationCurveTest008
778  * @tc.desc: Verify the Steps Curve with steps zero
779  * @tc.type: FUNC
780  * @tc.require: AR000DQ20I
781  * @tc.author: zhouzebin
782  */
783 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest008, TestSize.Level1)
784 {
785     StepsCurve stepsCurveStart(0);
786     /**
787      * @tc.steps: step1. set the testValue of time to test steps Curve.
788      */
789     float testValueFirst = 0.2f;
790     float testValueSecond = 0.8f;
791 
792     /**
793      * @tc.steps: step2. verify the result of steps Curve.
794      * @tc.expected: step2. the result is right.
795      */
796     EXPECT_NEAR(1.0f, stepsCurveStart.MoveInternal(testValueFirst), FLT_EPSILON);
797     EXPECT_NEAR(1.0f, stepsCurveStart.MoveInternal(testValueSecond), FLT_EPSILON);
798 }
799 
800 /**
801  * @tc.name: AnimationCurveTest009
802  * @tc.desc: Verify the Steps Curve with steps zero
803  * @tc.type: FUNC
804  * @tc.require: AR000DQ20I
805  * @tc.author: zhouzebin
806  */
807 HWTEST_F(AnimationFrameworkTest, AnimationCurveTest009, TestSize.Level1)
808 {
809     RefPtr<StepsCurve> stepsCurveStart = AceType::MakeRefPtr<StepsCurve>(2);
810     ComplementaryCurve complementaryCurve = ComplementaryCurve(stepsCurveStart);
811     /**
812      * @tc.steps: step1. set the testValue of time to test steps Curve.
813      */
814     float testValueFirst = 0.2f;
815     float testValueSecond = 0.8f;
816 
817     /**
818      * @tc.steps: step2. verify the result of steps Curve.
819      * @tc.expected: step2. the result is right.
820      */
821     EXPECT_NEAR(0.5f, complementaryCurve.MoveInternal(testValueFirst), FLT_EPSILON);
822     EXPECT_NEAR(0.0f, complementaryCurve.MoveInternal(testValueSecond), FLT_EPSILON);
823 }
824 
825 /**
826  * @tc.name: AnimationListenableTest001
827  * @tc.desc: Verify the whether listen the value of animation
828  * @tc.type: FUNC
829  * @tc.require: AR000DAIGT
830  * @tc.author: jiachunhui
831  */
832 HWTEST_F(AnimationFrameworkTest, AnimationListenableTest001, TestSize.Level1)
833 {
834     /**
835      * @tc.steps: step1. init animation and animator
836      */
837     flushEventMock_->InitController(context_);
838     int32_t duration = 15;
839     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 2, Curves::LINEAR);
840     flushEventMock_->animationDuration_ = duration;
841     context_->AddPostFlushListener(flushEventMock_);
842 
843     /**
844      * @tc.steps: step2. trigger one frame to make prepare animation work
845      */
846     platformWindowRaw_->TriggerOneFrame();
847 
848     /**
849      * @tc.steps: step3. trigger one frame to let animation done
850      * @tc.expected: step3. listen the LINEAR curve's value in every frame
851      */
852     platformWindowRaw_->TriggerOneFrame();
853     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
854 }
855 
856 /**
857  * @tc.name: AnimationListenableTest002
858  * @tc.desc: Verify the whether listen the status of animator
859  * @tc.type: FUNC
860  * @tc.require: AR000DAIGT
861  * @tc.author: jiachunhui
862  */
863 HWTEST_F(AnimationFrameworkTest, AnimationListenableTest002, TestSize.Level1)
864 {
865     /**
866      * @tc.steps: step1. init animation and animator
867      */
868     flushEventMock_->InitController(context_);
869     int32_t duration = 15;
870     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 2, Curves::LINEAR);
871     flushEventMock_->animationDuration_ = duration;
872     context_->AddPostFlushListener(flushEventMock_);
873 
874     /**
875      * @tc.steps: step2. trigger one frame to make prepare animation work
876      */
877     platformWindowRaw_->TriggerOneFrame();
878 
879     /**
880      * @tc.steps: step3. trigger 3 frames to let animation done
881      * @tc.expected: step3. listen the linear curve's value in every frame
882      */
883     platformWindowRaw_->TriggerOneFrame();
884     platformWindowRaw_->TriggerOneFrame();
885     EXPECT_TRUE(flushEventMock_->animationStartStatus_);
886     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
887     EXPECT_EQ(0, flushEventMock_->repeatDoneTimes_);
888     EXPECT_EQ(flushEventMock_->animationIntValue_, flushEventMock_->animationIntStopValue_);
889 }
890 
891 /**
892  * @tc.name: PictureAnimationTest001
893  * @tc.desc: Verify the picture animation process for type int
894  * @tc.type: FUNC
895  * @tc.require: AR000DBTQE
896  * @tc.author: zhouzebin
897  */
898 HWTEST_F(AnimationFrameworkTest, PictureAnimationTest001, TestSize.Level1)
899 {
900     GTEST_LOG_(INFO) << "AnimationFrameworkTest PictureAnimationTest001 start";
901     /**
902      * @tc.steps: step1. init animation and animator
903      */
904     uint32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
905     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
906     flushEventMock_->InitController(context_);
907     int32_t duration = frameTimeMs * PICTURE_ANIMATION_DURATION_MULTIPLE;
908     int32_t durationTotal = 0;
909     flushEventMock_->pictureInt_ = AceType::MakeRefPtr<PictureAnimation<int>>();
910     for (int32_t idx = 0; idx < PICTURE_ANIMATION_COUNT; idx++) {
911         flushEventMock_->pictureInt_->AddPicture(1.0f / PICTURE_ANIMATION_COUNT, idx + 10);
912         durationTotal += duration;
913     }
914     flushEventMock_->animationDuration_ = durationTotal;
915     context_->AddPostFlushListener(flushEventMock_);
916 
917     /**
918      * @tc.steps: step2. trigger one frame to make prepare animation work
919      * @tc.expected: step2. postFlush has been called.
920      */
921     platformWindowRaw_->TriggerOneFrame();
922     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
923 
924     /**
925      * @tc.steps: step3. trigger frames to see the begin and end for the first picture.
926      * @tc.expected: step3. check 1st picture's last time
927      */
928     platformWindowRaw_->TriggerOneFrame();
929     EXPECT_EQ(10, flushEventMock_->pictureIntValue_);
930     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * (frameTimeMs - 1), 1);
931     EXPECT_EQ(10, flushEventMock_->pictureIntValue_);
932 
933     /**
934      * @tc.steps: step4. trigger frames to see the begin and end for the 2nd picture
935      * @tc.expected: step4. check 2nd picture's last time
936      */
937     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND, 1);
938     EXPECT_EQ(11, flushEventMock_->pictureIntValue_);
939     platformWindowRaw_->TriggerOneFrame();
940     EXPECT_EQ(11, flushEventMock_->pictureIntValue_);
941     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * (frameTimeMs - 1), 1);
942     EXPECT_EQ(11, flushEventMock_->pictureIntValue_);
943 
944     /**
945      * @tc.steps: step5. trigger frames to see the last frame
946      * @tc.expected: step5. check the last picture's last time
947      */
948     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND, 1);
949     EXPECT_EQ(12, flushEventMock_->pictureIntValue_);
950     platformWindowRaw_->TriggerOneFrame();
951     EXPECT_EQ(12, flushEventMock_->pictureIntValue_);
952 
953     /**
954      * @tc.steps: step6. in no repeat case, stay in last picture
955      * @tc.expected: step6. check stay in last picture
956      */
957     platformWindowRaw_->TriggerOneFrame();
958     EXPECT_EQ(12, flushEventMock_->pictureIntValue_);
959 }
960 
961 /**
962  * @tc.name: PictureAnimationTest002
963  * @tc.desc: Verify the picture animation process for type string with repeat forever
964  * @tc.type: FUNC
965  * @tc.require: AR000DBTQE
966  * @tc.author: zhouzebin
967  */
968 HWTEST_F(AnimationFrameworkTest, PictureAnimationTest002, TestSize.Level1)
969 {
970     GTEST_LOG_(INFO) << "AnimationFrameworkTest PictureAnimationTest002 start";
971     /**
972      * @tc.steps: step1. init animation and animator
973      */
974     uint32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
975     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
976     flushEventMock_->InitController(context_);
977     int32_t duration = frameTimeMs * 1;
978     int32_t durationTotal = 0;
979     flushEventMock_->pictureString_ = AceType::MakeRefPtr<PictureAnimation<std::string>>();
980     for (int32_t idx = 0; idx < PICTURE_ANIMATION_COUNT; idx++) {
981         flushEventMock_->pictureString_->AddPicture(1.0f / (PICTURE_ANIMATION_COUNT + 1), std::to_string(idx));
982         durationTotal += duration;
983     }
984     flushEventMock_->pictureString_->AutoScale();
985     flushEventMock_->animationDuration_ = durationTotal;
986     flushEventMock_->iteration_ = ANIMATION_REPEAT_INFINITE;
987     context_->AddPostFlushListener(flushEventMock_);
988 
989     /**
990      * @tc.steps: step2. trigger one frame to make prepare animation work
991      * @tc.expected: step2. postFlush has been called.
992      */
993     platformWindowRaw_->TriggerOneFrame();
994     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
995 
996     /**
997      * @tc.steps: step3. check 1st loop. trigger frames to let animation done
998      * @tc.expected: step3. check all the frames in first loop
999      */
1000     platformWindowRaw_->TriggerOneFrame();
1001     EXPECT_EQ("1", flushEventMock_->pictureStringValue_);
1002 
1003     platformWindowRaw_->TriggerOneFrame();
1004     EXPECT_EQ("2", flushEventMock_->pictureStringValue_);
1005 
1006     /**
1007      * @tc.steps: step4. run 10 loops and check. trigger 3 frames to let animation done
1008      * @tc.expected: step4. check all the frames after 10 loops as the first loop
1009      */
1010     for (int32_t loop = 0; loop < ANIMATION_REPEAT_LOOP; loop++) {
1011         platformWindowRaw_->TriggerOneFrame();
1012         platformWindowRaw_->TriggerOneFrame();
1013         platformWindowRaw_->TriggerOneFrame();
1014     }
1015 
1016     platformWindowRaw_->TriggerOneFrame();
1017     EXPECT_EQ("0", flushEventMock_->pictureStringValue_);
1018 }
1019 
1020 /**
1021  * @tc.name: PictureAnimationTest003
1022  * @tc.desc: Verify the picture animation process for type int
1023  * @tc.type: FUNC
1024  * @tc.require: AR000DBTQE
1025  * @tc.author: zhouzebin
1026  */
1027 HWTEST_F(AnimationFrameworkTest, PictureAnimationTest003, TestSize.Level1)
1028 {
1029     GTEST_LOG_(INFO) << "AnimationFrameworkTest PictureAnimationTest003 start";
1030     /**
1031      * @tc.steps: step1. init picture animation
1032      */
1033     flushEventMock_->pictureString_ = AceType::MakeRefPtr<PictureAnimation<std::string>>();
1034 
1035     /**
1036      * @tc.steps: step2. verify adding picture with error duration
1037      * @tc.expected: step2. return false
1038      */
1039     EXPECT_FALSE(flushEventMock_->pictureString_->AddPicture(-1.0f, "invalid duration, negative"));
1040     EXPECT_FALSE(flushEventMock_->pictureString_->AddPicture(0.0f, "invalid duration, zero"));
1041     EXPECT_FALSE(flushEventMock_->pictureString_->AddPicture(2.0f, "invalid duration, not normalized"));
1042 
1043     /**
1044      * @tc.steps: step3. verify adding picture with valid edge
1045      * @tc.expected: step3. return true
1046      */
1047     EXPECT_TRUE(flushEventMock_->pictureString_->AddPicture(1.0f, "valid duration"));
1048 }
1049 
1050 /**
1051  * @tc.name: AnimationRepeatTest001
1052  * @tc.desc: test repeat animation for repeat 1 time
1053  * @tc.type: FUNC
1054  * @tc.require: AR000DAIGS
1055  * @tc.author: zhouzebin
1056  */
1057 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest001, TestSize.Level1)
1058 {
1059     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest001 start";
1060     /**
1061      * @tc.steps: step1. init animation and animator
1062      */
1063     uint32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1064     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1065     flushEventMock_->InitController(context_);
1066     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1067     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1068     flushEventMock_->animationDuration_ = duration;
1069     flushEventMock_->iteration_ = 2;
1070     context_->AddPostFlushListener(flushEventMock_);
1071 
1072     /**
1073      * @tc.steps: step2. trigger one frame to make prepare animation work
1074      * @tc.expected: step2. postFlush has been called.
1075      */
1076     platformWindowRaw_->TriggerOneFrame();
1077     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1078 
1079     /**
1080      * @tc.steps: step3. 1st round trigger 2 frames to let animation done
1081      * @tc.expected: step3. check linear curve's value in every frame
1082      */
1083     platformWindowRaw_->TriggerOneFrame();
1084     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1085 
1086     platformWindowRaw_->TriggerOneFrame();
1087     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1088 
1089     /**
1090      * @tc.steps: step4. 2nd round. trigger 3 frames to let animation done
1091      * @tc.expected: step4. check linear curve's value in every frame
1092      */
1093     platformWindowRaw_->TriggerOneFrame();
1094     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1095 
1096     platformWindowRaw_->TriggerOneFrame();
1097     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1098 
1099     platformWindowRaw_->TriggerOneFrame();
1100     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1101 
1102     /**
1103      * @tc.steps: step5. 3rd round. trigger 2 frames.
1104      * @tc.expected: step5. verify animation stopped
1105      */
1106     platformWindowRaw_->TriggerOneFrame();
1107     platformWindowRaw_->TriggerOneFrame();
1108     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1109     EXPECT_EQ(flushEventMock_->iteration_, flushEventMock_->repeatDoneTimes_ + 1);
1110 }
1111 
1112 /**
1113  * @tc.name: AnimationRepeatTest002
1114  * @tc.desc: test repeat animation for repeat forever
1115  * @tc.type: FUNC
1116  * @tc.require: AR000DAIGS
1117  * @tc.author: zhouzebin
1118  */
1119 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest002, TestSize.Level1)
1120 {
1121     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest002 start";
1122     /**
1123      * @tc.steps: step1. init animation and animator
1124      */
1125     uint32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1126     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1127     flushEventMock_->InitController(context_);
1128     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1129     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1130     flushEventMock_->animationDuration_ = duration;
1131     flushEventMock_->iteration_ = ANIMATION_REPEAT_INFINITE;
1132     context_->AddPostFlushListener(flushEventMock_);
1133     platformWindowRaw_->TriggerOneFrame();
1134 
1135     /**
1136      * @tc.steps: step2. go for 10 loops and check.
1137      * @tc.expected: step2. check values in every frame.
1138      */
1139     for (int32_t loop = 0; loop < ANIMATION_REPEAT_LOOP; loop++) {
1140         platformWindowRaw_->TriggerOneFrame();
1141         EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1142         platformWindowRaw_->TriggerOneFrame();
1143         EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1144         platformWindowRaw_->TriggerOneFrame();
1145         EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1146     }
1147     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
1148 }
1149 
1150 /**
1151  * @tc.name: AnimationRepeatTest003
1152  * @tc.desc: test repeat animation for skip multi frames
1153  * @tc.type: FUNC
1154  * @tc.require: AR000DAIGS
1155  * @tc.author: zhouzebin
1156  */
1157 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest003, TestSize.Level1)
1158 {
1159     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest003 start";
1160     /**
1161      * @tc.steps: step1. init animation and animator
1162      */
1163     uint32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1164     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1165     flushEventMock_->InitController(context_);
1166     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1167     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1168     flushEventMock_->animationDuration_ = duration;
1169     flushEventMock_->iteration_ = 3;
1170     context_->AddPostFlushListener(flushEventMock_);
1171 
1172     /**
1173      * @tc.steps: step2. trigger one frame to make prepare animation work
1174      * @tc.expected: step2. postFlush has been called.
1175      */
1176     platformWindowRaw_->TriggerOneFrame();
1177     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1178 
1179     /**
1180      * @tc.steps: step3. skip 2 loops and check
1181      * @tc.expected: step3. check the last loop
1182      */
1183     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * duration * 2, 3);
1184     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1185 
1186     platformWindowRaw_->TriggerOneFrame();
1187     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1188 
1189     platformWindowRaw_->TriggerOneFrame();
1190     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1191 
1192     /**
1193      * @tc.steps: step4. check loop ends
1194      * @tc.expected: step4. get the end value
1195      */
1196     platformWindowRaw_->TriggerOneFrame();
1197     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1198 }
1199 
1200 /**
1201  * @tc.name: AnimationRepeatTest004
1202  * @tc.desc: test repeat animation for skip all loops
1203  * @tc.type: FUNC
1204  * @tc.require: AR000DAIGS
1205  * @tc.author: zhouzebin
1206  */
1207 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest004, TestSize.Level1)
1208 {
1209     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest004 start";
1210     /**
1211      * @tc.steps: step1. init animation and animator
1212      */
1213     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1214     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1215     flushEventMock_->InitController(context_);
1216     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1217     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1218     flushEventMock_->animationDuration_ = duration;
1219     flushEventMock_->iteration_ = 3;
1220     context_->AddPostFlushListener(flushEventMock_);
1221 
1222     /**
1223      * @tc.steps: step2. trigger one frame to make prepare animation work
1224      * @tc.expected: step2. postFlush has been called.
1225      */
1226     platformWindowRaw_->TriggerOneFrame();
1227     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1228 
1229     /**
1230      * @tc.steps: step3. skip 2 loops and check
1231      * @tc.expected: step3. check animation stop
1232      */
1233     platformWindowRaw_->TriggerOneFrame();
1234     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * (static_cast<int>(duration)) * 4, 3);
1235 
1236     platformWindowRaw_->TriggerOneFrame();
1237     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1238     // skip all loops, only last loop trigger repeat callback
1239     EXPECT_EQ(0, flushEventMock_->repeatDoneTimes_);
1240 }
1241 
1242 /**
1243  * @tc.name: AnimationRepeatTest005
1244  * @tc.desc: test repeat animation for invalid repeat times
1245  * @tc.type: FUNC
1246  * @tc.require: AR000DAIGS
1247  * @tc.author: zhouzebin
1248  */
1249 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest005, TestSize.Level1)
1250 {
1251     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest005 start";
1252     /**
1253      * @tc.steps: step1. init animation and animator
1254      */
1255     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1256     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1257     flushEventMock_->InitController(context_);
1258     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1259     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1260     flushEventMock_->animationDuration_ = duration;
1261     flushEventMock_->iteration_ = -2;
1262     context_->AddPostFlushListener(flushEventMock_);
1263 
1264     /**
1265      * @tc.steps: step2. trigger one frame to make prepare animation work
1266      * @tc.expected: step2. postFlush has been called. repeat set failed.
1267      */
1268     platformWindowRaw_->TriggerOneFrame();
1269     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1270     EXPECT_FALSE(flushEventMock_->setRepeatSucc_);
1271 }
1272 
1273 /**
1274  * @tc.name: AnimationRepeatTest006
1275  * @tc.desc: test repeat animation for no repeat times with very large start delay and duration
1276  * @tc.type: FUNC
1277  * @tc.require: AR000DAIGS
1278  * @tc.author: zhouzebin
1279  */
1280 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest006, TestSize.Level1)
1281 {
1282     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest006 start";
1283     /**
1284      * @tc.steps: step1. init animation and animator
1285      */
1286     InitAnimationAndAnimator(1, 1, INT32_MAX, INT32_MAX);
1287     platformWindowRaw_->TriggerOneFrame();
1288 
1289     /**
1290      * @tc.steps: step2. trigger long time to reach start delay's end
1291      * @tc.expected: step2. check reaches start delay's end
1292      */
1293     platformWindowRaw_->TriggerFrame(((uint64_t)(INT32_MAX - 1)) * NANOSECOND_TO_MILLISECOND, 1);
1294     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
1295     platformWindowRaw_->TriggerOneFrame();
1296     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1297 
1298     /**
1299      * @tc.steps: step3. trigger long time to make duration's end
1300      * @tc.expected: step3. check reaches start duration's end
1301      */
1302     platformWindowRaw_->TriggerFrame(((uint64_t)(INT32_MAX - 1)) * NANOSECOND_TO_MILLISECOND, 1);
1303     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
1304     platformWindowRaw_->TriggerOneFrame();
1305     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
1306 }
1307 
1308 /**
1309  * @tc.name: AnimationRepeatTest007
1310  * @tc.desc: test repeat animation for no repeat times with very large repeat times
1311  * @tc.type: FUNC
1312  * @tc.require: AR000DAIGS
1313  * @tc.author: zhouzebin
1314  */
1315 HWTEST_F(AnimationFrameworkTest, AnimationRepeatTest007, TestSize.Level1)
1316 {
1317     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationRepeatTest007 start";
1318     /**
1319      * @tc.steps: step1. init animation and animator
1320      */
1321     InitAnimationAndAnimator(1, INT32_MAX, 1, 1);
1322 
1323     /**
1324      * @tc.steps: step2. trigger one frame to reach start delay's end
1325      * @tc.expected: step2.  check reaches start delay's end
1326      */
1327     platformWindowRaw_->TriggerOneFrame();
1328     platformWindowRaw_->TriggerOneFrame();
1329     platformWindowRaw_->TriggerOneFrame();
1330     EXPECT_EQ(1, flushEventMock_->repeatDoneTimes_);
1331 
1332     /**
1333      * @tc.steps: step3. trigger very long frame to reach duration's end
1334      * @tc.expected: step3.  check reaches animation's end
1335      */
1336     platformWindowRaw_->TriggerFrame(((uint64_t)(INT32_MAX - 2)) * NANOSECOND_TO_MILLISECOND, 1);
1337     EXPECT_EQ(2, flushEventMock_->repeatDoneTimes_);
1338     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
1339     platformWindowRaw_->TriggerOneFrame();
1340     EXPECT_EQ(3, flushEventMock_->repeatDoneTimes_ + 1);
1341     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
1342 }
1343 
1344 /**
1345  * @tc.name: AnimationStartDelayTest001
1346  * @tc.desc: test start delay for animation
1347  * @tc.type: FUNC
1348  * @tc.require: AR000DAIGS
1349  * @tc.author: zhouzebin
1350  */
1351 HWTEST_F(AnimationFrameworkTest, AnimationStartDelayTest001, TestSize.Level1)
1352 {
1353     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationStartDelayTest001 start";
1354     /**
1355      * @tc.steps: step1. init animation and animator
1356      */
1357     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1358     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1359     flushEventMock_->InitController(context_);
1360     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1361     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1362     flushEventMock_->animationDuration_ = duration;
1363     flushEventMock_->startDelay_ = frameTimeMs;
1364     context_->AddPostFlushListener(flushEventMock_);
1365 
1366     /**
1367      * @tc.steps: step2. trigger one frame to make prepare animation work
1368      * @tc.expected: step2. postFlush has been called.
1369      */
1370     platformWindowRaw_->TriggerOneFrame();
1371     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1372 
1373     /**
1374      * @tc.steps: step3. trigger start delay and check
1375      * @tc.expected: step3. check start dely
1376      */
1377     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * (frameTimeMs - 1), 1);
1378     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
1379 
1380     /**
1381      * @tc.steps: step4. go with the left animation
1382      * @tc.expected: step4. check timestamp at start millisecond
1383      */
1384     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND, 1);
1385     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1386     platformWindowRaw_->TriggerOneFrame();
1387     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1388 
1389     platformWindowRaw_->TriggerOneFrame();
1390     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1391 
1392     /**
1393      * @tc.steps: step5. check animation at the end
1394      * @tc.expected: step5. check the end
1395      */
1396     platformWindowRaw_->TriggerOneFrame();
1397     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1398 }
1399 
1400 /**
1401  * @tc.name: AnimationStartDelayTest002
1402  * @tc.desc: test repeat & start delay animation
1403  * @tc.type: FUNC
1404  * @tc.require: AR000DAIGS
1405  * @tc.author: zhouzebin
1406  */
1407 HWTEST_F(AnimationFrameworkTest, AnimationStartDelayTest002, TestSize.Level1)
1408 {
1409     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationStartDelayTest002 start";
1410     /**
1411      * @tc.steps: step1. init animation and animator
1412      */
1413     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1414     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1415     flushEventMock_->InitController(context_);
1416     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1417     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1418     flushEventMock_->animationDuration_ = duration;
1419     flushEventMock_->startDelay_ = frameTimeMs;
1420     flushEventMock_->iteration_ = 2;
1421     context_->AddPostFlushListener(flushEventMock_);
1422 
1423     /**
1424      * @tc.steps: step2. trigger one frame to make prepare animation work
1425      * @tc.expected: step2. postFlush has been called.
1426      */
1427     platformWindowRaw_->TriggerOneFrame();
1428     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1429 
1430     /**
1431      * @tc.steps: step3. trigger start delay and check
1432      * @tc.expected: step3. check start dely
1433      */
1434     platformWindowRaw_->TriggerFrame(NANOSECOND_TO_MILLISECOND * (frameTimeMs - 1), 1);
1435     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
1436 
1437     /**
1438      * @tc.steps: step4. go with repeat loops and check
1439      * @tc.expected: step4. check timestamp at last millisecond
1440      */
1441     for (int32_t loop = 0; loop < 2; loop++) {
1442         platformWindowRaw_->TriggerOneFrame();
1443         EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1444         platformWindowRaw_->TriggerOneFrame();
1445         EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1446         platformWindowRaw_->TriggerOneFrame();
1447         EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1448     }
1449 
1450     /**
1451      * @tc.steps: step5. check animation at the end
1452      * @tc.expected: step5. check the end
1453      */
1454     platformWindowRaw_->TriggerOneFrame();
1455     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1456 }
1457 
1458 /**
1459  * @tc.name: AnimationStartDelayTest003
1460  * @tc.desc: test repeat & start delay animation with time scale
1461  * @tc.type: FUNC
1462  * @tc.require: AR000DAIGS
1463  * @tc.author: zhouzebin
1464  */
1465 HWTEST_F(AnimationFrameworkTest, AnimationStartDelayTest003, TestSize.Level1)
1466 {
1467     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationStartDelayTest003 start";
1468     /**
1469      * @tc.steps: step1. init animation and animator
1470      */
1471     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1472     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1473     flushEventMock_->InitController(context_);
1474     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1475     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1476     flushEventMock_->animationDuration_ = duration;
1477     flushEventMock_->startDelay_ = frameTimeMs;
1478     auto controller = flushEventMock_->GetAnimator();
1479     controller->SetDurationScale(2.0f);
1480     context_->AddPostFlushListener(flushEventMock_);
1481     /**
1482      * @tc.steps: step2. trigger start delay and check
1483      * @tc.expected: step2. check start delay
1484      */
1485     platformWindowRaw_->TriggerFrames(2);
1486     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
1487 
1488     /**
1489      * @tc.steps: step3. go forward and check
1490      * @tc.expected: step3. check timestamp at last millisecond
1491      */
1492     platformWindowRaw_->TriggerFrames(2);
1493     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
1494     platformWindowRaw_->TriggerFrames(2);
1495     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1496     platformWindowRaw_->TriggerFrames(2);
1497     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1498 
1499     /**
1500      * @tc.steps: step4. check animation at the end
1501      * @tc.expected: step4. check the end
1502      */
1503     platformWindowRaw_->TriggerFrames(2);
1504     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
1505     controller->SetDurationScale(1.0f);
1506 }
1507 
1508 /**
1509  * @tc.name: AnimationPauseTest001
1510  * @tc.desc: test pause animation
1511  * @tc.type: FUNC
1512  * @tc.require: AR000DAIGS
1513  * @tc.author: zhouzebin
1514  */
1515 HWTEST_F(AnimationFrameworkTest, AnimationPauseTest001, TestSize.Level1)
1516 {
1517     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationPauseTest001 start";
1518     /**
1519      * @tc.steps: step1. init animation and animator
1520      */
1521     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1522     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1523     flushEventMock_->InitController(context_);
1524     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1525     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1526     flushEventMock_->animationDuration_ = duration;
1527     context_->AddPostFlushListener(flushEventMock_);
1528 
1529     /**
1530      * @tc.steps: step2. trigger one frame to make prepare animation work
1531      * @tc.expected: step2. postFlush has been called.
1532      */
1533     platformWindowRaw_->TriggerOneFrame();
1534     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1535 
1536     /**
1537      * @tc.steps: step3. trigger frame after resume ahead
1538      * @tc.expected: step3. check linear curve's value in every frame
1539      */
1540     auto controller = flushEventMock_->GetAnimator();
1541     controller->Resume();
1542     platformWindowRaw_->TriggerOneFrame();
1543     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1544 
1545     controller->Pause();
1546 
1547     /**
1548      * @tc.steps: step4. pause animator
1549      * @tc.expected: step4. check linear curve's value do not change.
1550      */
1551     for (int32_t i = 0; i < 10; i++) {
1552         platformWindowRaw_->TriggerOneFrame();
1553         controller->Pause();
1554         EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1555     }
1556 
1557     /**
1558      * @tc.steps: step5. resume animator and trigger last frame
1559      * @tc.expected: step5. check linear curve's value reach the end value.
1560      */
1561     controller->Resume();
1562     platformWindowRaw_->TriggerOneFrame();
1563     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1564 }
1565 
1566 /**
1567  * @tc.name: AnimationPauseTest002
1568  * @tc.desc: test pause animation
1569  * @tc.type: FUNC
1570  * @tc.require: AR000DAIGS
1571  * @tc.author: zhouzebin
1572  */
1573 HWTEST_F(AnimationFrameworkTest, AnimationPauseTest002, TestSize.Level1)
1574 {
1575     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationPauseTest002 start";
1576     /**
1577      * @tc.steps: step1. init animation and animator
1578      */
1579     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1580     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1581     flushEventMock_->InitController(context_);
1582     int32_t duration = frameTimeMs * ANIMATION_DURATION_MULTIPLE;
1583     flushEventMock_->animationInt_ = AceType::MakeRefPtr<CurveAnimation<int>>(1, 4, Curves::LINEAR);
1584     flushEventMock_->animationDuration_ = duration;
1585     context_->AddPostFlushListener(flushEventMock_);
1586 
1587     /**
1588      * @tc.steps: step2. trigger frames to make prepare animation work
1589      * @tc.expected: step2. postFlush has been called.
1590      */
1591     platformWindowRaw_->TriggerOneFrame();
1592     platformWindowRaw_->TriggerOneFrame();
1593     platformWindowRaw_->TriggerOneFrame();
1594     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1595 
1596     /**
1597      * @tc.steps: step3. pause -> stop -> goforward
1598      */
1599     auto controller = flushEventMock_->GetAnimator();
1600     controller->Pause();
1601     controller->Stop();
1602     controller->Play();
1603 
1604     /**
1605      * @tc.steps: step4. trigger one frame
1606      * @tc.expected: step4. check linear curve's value change.
1607      */
1608     platformWindowRaw_->TriggerOneFrame();
1609     EXPECT_EQ(2, flushEventMock_->animationIntValue_);
1610 
1611     /**
1612      * @tc.steps: step5. trigger the last frame
1613      * @tc.expected: step5. check linear curve's value change.
1614      */
1615     controller->Resume();
1616     platformWindowRaw_->TriggerOneFrame();
1617     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
1618 }
1619 
1620 /**
1621  * @tc.name: KeyframeAnimationTest001
1622  * @tc.desc: Verify the keyframe animation with only one keyframe.
1623  * @tc.type: FUNC
1624  * @tc.require: AR000DBTLS
1625  * @tc.author: jiangdayuan
1626  */
1627 HWTEST_F(AnimationFrameworkTest, KeyframeAnimationTest001, TestSize.Level1)
1628 {
1629     GTEST_LOG_(INFO) << "AnimationFrameworkTest KeyframeAnimationTest001 start";
1630     /**
1631      * @tc.steps: step1. init keyframe animation and animator.
1632      */
1633     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1634     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1635     flushEventMock_->InitController(context_);
1636     int32_t duration = frameTimeMs * KEYFRAME_ANIMATION_DURATION_MULTIPLE;
1637     float begin = 1.0f;
1638     auto kf1 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, begin);
1639     flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
1640     flushEventMock_->keyframeAnimation_->AddKeyframe(kf1);
1641     flushEventMock_->animationDuration_ = duration;
1642     context_->AddPostFlushListener(flushEventMock_);
1643 
1644     /**
1645      * @tc.steps: step2. trigger one frame to make prepare animation work
1646      * @tc.expected: step2. postFlush has been called.
1647      */
1648     platformWindowRaw_->TriggerOneFrame();
1649     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1650 
1651     /**
1652      * @tc.steps: step3. trigger 3 frames to verify keyframe animation
1653      * @tc.expected: step3. the value of each frame remains the same as the beginning value.
1654      */
1655     platformWindowRaw_->TriggerOneFrame();
1656     EXPECT_NEAR(begin, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1657 
1658     platformWindowRaw_->TriggerOneFrame();
1659     EXPECT_NEAR(begin, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1660 
1661     platformWindowRaw_->TriggerOneFrame();
1662     EXPECT_NEAR(begin, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1663 }
1664 
1665 /**
1666  * @tc.name: KeyframeAnimationTest002
1667  * @tc.desc: Verify the keyframe animation with two keyframes and set curve to linear curve.
1668  * @tc.type: FUNC
1669  * @tc.require: AR000DBTLS
1670  * @tc.author: jiangdayuan
1671  */
1672 HWTEST_F(AnimationFrameworkTest, KeyframeAnimationTest002, TestSize.Level1)
1673 {
1674     GTEST_LOG_(INFO) << "AnimationFrameworkTest KeyframeAnimationTest002 start";
1675     /**
1676      * @tc.steps: step1. init keyframe animation and animator,set curve to linear curve.
1677      */
1678     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1679     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1680     flushEventMock_->InitController(context_);
1681     int32_t duration = frameTimeMs * KEYFRAME_ANIMATION_DURATION_MULTIPLE;
1682     float begin = 1.0f;
1683     float end = 10.0f;
1684     auto kf1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
1685     auto kf2 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
1686     kf2->SetCurve(Curves::LINEAR);
1687     flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
1688     flushEventMock_->keyframeAnimation_->AddKeyframe(kf1);
1689     flushEventMock_->keyframeAnimation_->AddKeyframe(kf2);
1690     flushEventMock_->animationDuration_ = duration;
1691     context_->AddPostFlushListener(flushEventMock_);
1692 
1693     /**
1694      * @tc.steps: step2. trigger one frame to make prepare animation work
1695      * @tc.expected: step2. postFlush has been called.
1696      */
1697     platformWindowRaw_->TriggerOneFrame();
1698     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1699 
1700     /**
1701      * @tc.steps: step3. trigger 2 frames to verify keyframe animation
1702      * @tc.expected: step3. the value of each frame changes linearly
1703      */
1704     platformWindowRaw_->TriggerOneFrame();
1705     EXPECT_NEAR((begin + end) / 2.0f, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1706 
1707     platformWindowRaw_->TriggerOneFrame();
1708     EXPECT_NEAR(end, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1709 }
1710 
1711 /**
1712  * @tc.name: KeyframeAnimationTest003
1713  * @tc.desc: Verify the keyframe animation with two keyframes and without setting curve.
1714  * @tc.type: FUNC
1715  * @tc.require: AR000DBTLS
1716  * @tc.author: jiangdayuan
1717  */
1718 HWTEST_F(AnimationFrameworkTest, KeyframeAnimationTest003, TestSize.Level1)
1719 {
1720     GTEST_LOG_(INFO) << "AnimationFrameworkTest KeyframeAnimationTest003 start";
1721     /**
1722      * @tc.steps: step1. init keyframe animation and animator.
1723      */
1724     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1725     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1726     flushEventMock_->InitController(context_);
1727     int32_t duration = frameTimeMs * KEYFRAME_ANIMATION_DURATION_MULTIPLE;
1728     float begin = 1.0f;
1729     float end = 10.0f;
1730     auto kf1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
1731     auto kf2 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
1732 
1733     flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
1734     flushEventMock_->keyframeAnimation_->AddKeyframe(kf1);
1735     flushEventMock_->keyframeAnimation_->AddKeyframe(kf2);
1736     flushEventMock_->animationDuration_ = duration;
1737     context_->AddPostFlushListener(flushEventMock_);
1738 
1739     /**
1740      * @tc.steps: step2. trigger one frame to make prepare animation work
1741      * @tc.expected: step2. postFlush has been called.
1742      */
1743     platformWindowRaw_->TriggerOneFrame();
1744     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1745 
1746     /**
1747      * @tc.steps: step3. trigger 2 frames to verify keyframe animation
1748      * @tc.expected: step3. the value of each frame changes linearly
1749      */
1750     platformWindowRaw_->TriggerOneFrame();
1751     EXPECT_NEAR(8.21793, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1752 
1753     platformWindowRaw_->TriggerOneFrame();
1754     EXPECT_NEAR(end, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1755 }
1756 
1757 /**
1758  * @tc.name: KeyframeAnimationTest004
1759  * @tc.desc: Verify the keyframe animation with three keyframes and set all curves to linear curve.
1760  * @tc.type: FUNC
1761  * @tc.require: AR000DBTLS
1762  * @tc.author: jiangdayuan
1763  */
1764 HWTEST_F(AnimationFrameworkTest, KeyframeAnimationTest004, TestSize.Level1)
1765 {
1766     GTEST_LOG_(INFO) << "AnimationFrameworkTest KeyframeAnimationTest004 start";
1767     /**
1768      * @tc.steps: step1. init keyframe animation and animator.
1769      */
1770     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1771     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1772     flushEventMock_->InitController(context_);
1773     int32_t duration = frameTimeMs * KEYFRAME_ANIMATION_DURATION_MULTIPLE;
1774     float begin = 1.0f;
1775     float middle = 5.0f;
1776     float end = 10.0f;
1777 
1778     auto kf1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
1779     auto kf2 = AceType::MakeRefPtr<Keyframe<float>>(0.5f, middle);
1780     auto kf3 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
1781 
1782     kf2->SetCurve(Curves::LINEAR);
1783     kf3->SetCurve(Curves::LINEAR);
1784 
1785     flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
1786     flushEventMock_->keyframeAnimation_->AddKeyframe(kf1);
1787     flushEventMock_->keyframeAnimation_->AddKeyframe(kf2);
1788     flushEventMock_->keyframeAnimation_->AddKeyframe(kf3);
1789     flushEventMock_->animationDuration_ = duration;
1790     context_->AddPostFlushListener(flushEventMock_);
1791 
1792     /**
1793      * @tc.steps: step2. trigger one frame to make prepare animation work
1794      * @tc.expected: step2. postFlush has been called.
1795      */
1796     platformWindowRaw_->TriggerOneFrame();
1797     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1798 
1799     /**
1800      * @tc.steps: step3. trigger 2 frames to verify keyframe animation
1801      * @tc.expected: step3. the value of each frame changes linearly
1802      */
1803     platformWindowRaw_->TriggerOneFrame();
1804     EXPECT_NEAR(middle, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1805 
1806     platformWindowRaw_->TriggerOneFrame();
1807     EXPECT_NEAR(end, flushEventMock_->keyframeAnimationValue_, CUBIC_ERROR_BOUND);
1808 }
1809 
1810 /**
1811  * @tc.name: KeyframeAnimationTest005
1812  * @tc.desc: Verify the keyframe animation with three keyframes and set different curve.
1813  * @tc.type: FUNC
1814  * @tc.require: AR000DBTLS
1815  * @tc.author: jiangdayuan
1816  */
1817 HWTEST_F(AnimationFrameworkTest, KeyframeAnimationTest005, TestSize.Level1)
1818 {
1819     GTEST_LOG_(INFO) << "AnimationFrameworkTest KeyframeAnimationTest005 start";
1820     /**
1821      * @tc.steps: step1. init keyframe animation and animator.
1822      */
1823     int32_t frameTimeMs = FRAME_TIME_IN_MILLISECOND;
1824     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * frameTimeMs);
1825     flushEventMock_->InitController(context_);
1826     int32_t duration = frameTimeMs * KEYFRAME_ANIMATION_DURATION_MULTIPLE;
1827     float begin = 1.0f;
1828     float middle = 5.0f;
1829     float end = 10.0f;
1830 
1831     auto kf1 = AceType::MakeRefPtr<Keyframe<float>>(0.0f, begin);
1832     auto kf2 = AceType::MakeRefPtr<Keyframe<float>>(0.5f, middle);
1833     auto kf3 = AceType::MakeRefPtr<Keyframe<float>>(1.0f, end);
1834 
1835     kf2->SetCurve(Curves::LINEAR);
1836     kf3->SetCurve(Curves::SINE);
1837 
1838     flushEventMock_->keyframeAnimation_ = AceType::MakeRefPtr<KeyframeAnimation<float>>();
1839     flushEventMock_->keyframeAnimation_->AddKeyframe(kf1);
1840     flushEventMock_->keyframeAnimation_->AddKeyframe(kf2);
1841     flushEventMock_->keyframeAnimation_->AddKeyframe(kf3);
1842     flushEventMock_->animationDuration_ = duration;
1843     context_->AddPostFlushListener(flushEventMock_);
1844 
1845     /**
1846      * @tc.steps: step2. trigger one frame to make prepare animation work
1847      * @tc.expected: step2. postFlush has been called.
1848      */
1849     platformWindowRaw_->TriggerOneFrame();
1850     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1851 
1852     /**
1853      * @tc.steps: step3. trigger 2 frames to verify keyframe animation
1854      * @tc.expected: step3. the value of each frame changes correctly
1855      */
1856     platformWindowRaw_->TriggerOneFrame();
1857     EXPECT_NEAR(middle, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
1858 
1859     platformWindowRaw_->TriggerOneFrame();
1860     EXPECT_NEAR(end, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
1861 }
1862 
1863 /**
1864  * @tc.name: AnimationInterpolateTest001
1865  * @tc.desc: duration equals zero
1866  * @tc.type: FUNC
1867  * @tc.require: AR000DAIGS
1868  * @tc.author: zhouzebin
1869  */
1870 HWTEST_F(AnimationFrameworkTest, AnimationInterpolateTest001, TestSize.Level1)
1871 {
1872     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationInterpolateTest001 start";
1873     /**
1874      * @tc.steps: step1. init animation and animator
1875      */
1876     flushEventMock_->InitController(context_);
1877     int32_t duration = 0;
1878     // default curve is linear. test it with nullptr.
1879     flushEventMock_->animationFloat_ = AceType::MakeRefPtr<CurveAnimation<float>>(1.0f, 6.0f, nullptr);
1880     flushEventMock_->animationDuration_ = duration;
1881     context_->AddPostFlushListener(flushEventMock_);
1882 
1883     /**
1884      * @tc.steps: step2. trigger one frame to make prepare animation work
1885      * @tc.expected: step2. postFlush has been called.
1886      */
1887     platformWindowRaw_->TriggerOneFrame();
1888     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1889 
1890     /**
1891      * @tc.steps: step3. trigger 1 frame to let animation done
1892      * @tc.expected: step3. stop status is true
1893      */
1894     platformWindowRaw_->TriggerOneFrame();
1895     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
1896 }
1897 
1898 /**
1899  * @tc.name: AnimationInterpolateTest002
1900  * @tc.desc: start interpolate animation without set it.
1901  * @tc.type: FUNC
1902  * @tc.require: AR000DAIGS
1903  * @tc.author: zhouzebin
1904  */
1905 HWTEST_F(AnimationFrameworkTest, AnimationInterpolateTest002, TestSize.Level1)
1906 {
1907     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationInterpolateTest001 start";
1908     /**
1909      * @tc.steps: step1. init animation and animator
1910      */
1911     flushEventMock_->InitController(context_);
1912     int32_t duration = 0;
1913     // default curve is linear. test it with nullptr.
1914     flushEventMock_->animationDuration_ = duration;
1915     context_->AddPostFlushListener(flushEventMock_);
1916 
1917     /**
1918      * @tc.steps: step2. trigger one frame to make prepare animation work
1919      * @tc.expected: step2. postFlush has been called.
1920      */
1921     platformWindowRaw_->TriggerOneFrame();
1922     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
1923 
1924     /**
1925      * @tc.steps: step3. trigger 1 frame to let animation done
1926      * @tc.expected: step3. check no animation get listener callback
1927      */
1928     platformWindowRaw_->TriggerOneFrame();
1929     EXPECT_NEAR(0.0f, flushEventMock_->animationFloatValue_, FLT_EPSILON);
1930 }
1931 
1932 /**
1933  * @tc.name: AnimationFrictionMotionTest001
1934  * @tc.desc: play friction motion in a very short duration (less than a frame)
1935  * @tc.type: FUNC
1936  * @tc.require: AR000DAIGS
1937  * @tc.author: zhouzebin
1938  */
1939 HWTEST_F(AnimationFrameworkTest, AnimationFrictionMotionTest001, TestSize.Level1)
1940 {
1941     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrictionMotionTest001 start";
1942     /**
1943      * @tc.steps: step1. init friction motion and animator
1944      */
1945     platformWindowRaw_->SetNanoFrameTime(NANO_FRAME_TIME * 1000);
1946     flushEventMock_->InitController(context_);
1947     auto frictionMotion = AceType::MakeRefPtr<FrictionMotion>(0.0, 1.0, 1.0);
1948     auto controller = flushEventMock_->GetAnimator();
1949     controller->PlayMotion(frictionMotion);
1950 
1951     /**
1952      * @tc.steps: step2. trigger one frame to make it done
1953      * @tc.expected: step2. scroll has been done.
1954      */
1955     platformWindowRaw_->TriggerOneFrame();
1956     EXPECT_TRUE(frictionMotion->IsCompleted());
1957 }
1958 
1959 /**
1960  * @tc.name: AnimationFrictionMotionTest002
1961  * @tc.desc: play friction motion in positive velocity.
1962  * @tc.type: FUNC
1963  * @tc.require: AR000DAIGS
1964  * @tc.author: zhouzebin
1965  */
1966 HWTEST_F(AnimationFrameworkTest, AnimationFrictionMotionTest002, TestSize.Level1)
1967 {
1968     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationFrictionMotionTest002 start";
1969     /**
1970      * @tc.steps: step1. init friction motion and animator
1971      */
1972     platformWindowRaw_->SetNanoFrameTime(NANO_FRAME_TIME * 1000);
1973     flushEventMock_->InitController(context_);
1974     auto frictionMotion = AceType::MakeRefPtr<FrictionMotion>(1.0, 100.0, 100.0);
1975 
1976     EXPECT_NEAR(100.0, frictionMotion->GetPosition(0.0), 0.1);
1977     EXPECT_NEAR(100.0, frictionMotion->GetVelocity(0.0), 0.1);
1978 
1979     EXPECT_NEAR(120.89, frictionMotion->GetPosition(0.5), 1.0);
1980     EXPECT_NEAR(113.09, frictionMotion->GetFinalPosition(), 0.1);
1981 }
1982 
1983 /**
1984  * @tc.name: AnimationSpringMotionTest001
1985  * @tc.desc: Verify critical damped motion
1986  * @tc.type: FUNC
1987  * @tc.require: AR000DBULF
1988  * @tc.author: jiangdayuan
1989  */
1990 HWTEST_F(AnimationFrameworkTest, AnimationSpringMotionTest001, TestSize.Level1)
1991 {
1992     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationSpringMotionTest001 start";
1993     /**
1994      * @tc.steps: step1. init SpringMotion with critical damped SpringProperty.
1995      */
1996     auto springDescription = AceType::MakeRefPtr<SpringProperty>(1.0, 100.0, 20.0);
1997     auto springMotion = AceType::MakeRefPtr<SpringMotion>(0.0, 500.0, 0.0, springDescription);
1998     EXPECT_EQ(springMotion->GetType(), SpringModelType::CRITICAL_DAMPED);
1999 
2000     /**
2001      * @tc.steps: step2. verify springMotion start point.
2002      * @tc.expected: step2. result is correct.
2003      */
2004     springMotion->Move(0.0f);
2005     EXPECT_FALSE(springMotion->IsCompleted());
2006     EXPECT_NEAR(springMotion->GetCurrentPosition(), 0.0, DBL_EPSILON);
2007     EXPECT_NEAR(springMotion->GetCurrentVelocity(), 5000.0, DBL_EPSILON);
2008 
2009     /**
2010      * @tc.steps: step3. verify springMotion middle point.
2011      * @tc.expected: step3. result is correct.
2012      */
2013     springMotion->Move(500.0f);
2014     EXPECT_FALSE(springMotion->IsCompleted());
2015     EXPECT_EQ(floor(springMotion->GetCurrentPosition()), 496);
2016     EXPECT_EQ(floor(springMotion->GetCurrentVelocity()), 33);
2017 
2018     /**
2019      * @tc.steps: step4. verify springMotion end point.
2020      * @tc.expected: step4. result is correct.
2021      */
2022     springMotion->Move(1600.0f);
2023     EXPECT_TRUE(springMotion->IsCompleted());
2024     EXPECT_NEAR(springMotion->GetCurrentPosition(), 500.0, DBL_EPSILON);
2025     EXPECT_NEAR(springMotion->GetCurrentVelocity(), 0.0, DBL_EPSILON);
2026 }
2027 
2028 /**
2029  * @tc.name: AnimationSpringMotionTest002
2030  * @tc.desc: Verify overdamped motion
2031  * @tc.type: FUNC
2032  * @tc.require: AR000DBULF
2033  * @tc.author: jiangdayuan
2034  */
2035 HWTEST_F(AnimationFrameworkTest, AnimationSpringMotionTest002, TestSize.Level1)
2036 {
2037     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationSpringMotionTest002 start";
2038     /**
2039      * @tc.steps: step1. init SpringMotion with overdamped SpringProperty.
2040      */
2041     auto springDescription = AceType::MakeRefPtr<SpringProperty>(1.0, 100.0, 25.0);
2042     auto springMotion = AceType::MakeRefPtr<SpringMotion>(0.0, 500.0, 0.0, springDescription);
2043     EXPECT_EQ(springMotion->GetType(), SpringModelType::OVER_DAMPED);
2044 
2045     /**
2046      * @tc.steps: step2. verify springMotion start point.
2047      * @tc.expected: step2. result is correct.
2048      */
2049     springMotion->Move(0.0f);
2050     EXPECT_FALSE(springMotion->IsCompleted());
2051     EXPECT_NEAR(springMotion->GetCurrentPosition(), 0.0, DBL_EPSILON);
2052 
2053     /**
2054      * @tc.steps: step3. verify springMotion middle point.
2055      * @tc.expected: step3. result is correct.
2056      */
2057     springMotion->Move(500.0f);
2058     EXPECT_FALSE(springMotion->IsCompleted());
2059     EXPECT_EQ(floor(springMotion->GetCurrentPosition()), 445);
2060     EXPECT_EQ(floor(springMotion->GetCurrentVelocity()), 273);
2061 
2062     /**
2063      * @tc.steps: step4. verify springMotion end point.
2064      * @tc.expected: step4. result is correct.
2065      */
2066     springMotion->Move(3100.0f);
2067     EXPECT_TRUE(springMotion->IsCompleted());
2068     EXPECT_NEAR(springMotion->GetCurrentPosition(), 500.0, DBL_EPSILON);
2069     EXPECT_NEAR(springMotion->GetCurrentVelocity(), 0.0, DBL_EPSILON);
2070 }
2071 
2072 /**
2073  * @tc.name: AnimationSpringMotionTest003
2074  * @tc.desc: Verify underdamped motion
2075  * @tc.type: FUNC
2076  * @tc.require: AR000DBULF
2077  * @tc.author: jiangdayuan
2078  */
2079 HWTEST_F(AnimationFrameworkTest, AnimationSpringMotionTest003, TestSize.Level1)
2080 {
2081     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationSpringMotionTest003 start";
2082     /**
2083      * @tc.steps: step1. init SpringMotion with underdamped SpringProperty.
2084      */
2085     auto springDescription = AceType::MakeRefPtr<SpringProperty>(1.0, 100.0, 5.0);
2086     auto springMotion = AceType::MakeRefPtr<SpringMotion>(0.0, 300.0, 0.0, springDescription);
2087     EXPECT_EQ(springMotion->GetType(), SpringModelType::UNDER_DAMPED);
2088 
2089     /**
2090      * @tc.steps: step2. verify springMotion start point.
2091      * @tc.expected: step2. result is correct.
2092      */
2093     springMotion->Move(0.0f);
2094     EXPECT_FALSE(springMotion->IsCompleted());
2095     EXPECT_NEAR(springMotion->GetCurrentPosition(), 0.0, DBL_EPSILON);
2096 
2097     /**
2098      * @tc.steps: step3. verify springMotion middle point.
2099      * @tc.expected: step3. result is correct.
2100      */
2101     springMotion->Move(1000.0f);
2102     EXPECT_FALSE(springMotion->IsCompleted());
2103     EXPECT_EQ(floor(springMotion->GetCurrentPosition()), 325);
2104     EXPECT_EQ(floor(springMotion->GetCurrentVelocity()), -65);
2105 
2106     /**
2107      * @tc.steps: step4. verify springMotion end point.
2108      * @tc.expected: step4. result is correct.
2109      */
2110     springMotion->Move(6000.0f);
2111     EXPECT_TRUE(springMotion->IsCompleted());
2112     EXPECT_NEAR(springMotion->GetCurrentPosition(), 300.0, DBL_EPSILON);
2113     EXPECT_NEAR(springMotion->GetCurrentVelocity(), 0.0, DBL_EPSILON);
2114 }
2115 
2116 /**
2117  * @tc.name: AnimationSpringMotionTest004
2118  * @tc.desc: Verify Scroll Spring motion
2119  * @tc.type: FUNC
2120  * @tc.require: AR000DBULF
2121  * @tc.author: jiangdayuan
2122  */
2123 HWTEST_F(AnimationFrameworkTest, AnimationSpringMotionTest004, TestSize.Level1)
2124 {
2125     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationSpringMotionTest004 start";
2126     /**
2127      * @tc.steps: step1. init ScrollSpringMotion with critical damped SpringProperty.
2128      */
2129     auto springDescription = AceType::MakeRefPtr<SpringProperty>(1.0, 100.0, 20.0);
2130     auto scrollSpringMotion = AceType::MakeRefPtr<ScrollSpringMotion>(0.0, 500.0, 0.0, springDescription);
2131     EXPECT_EQ(scrollSpringMotion->GetType(), SpringModelType::CRITICAL_DAMPED);
2132 
2133     /**
2134      * @tc.steps: step2. verify ScrollSpringMotion start point.
2135      * @tc.expected: step2. result is correct.
2136      */
2137     scrollSpringMotion->Move(0.0f);
2138     EXPECT_FALSE(scrollSpringMotion->IsCompleted());
2139     EXPECT_NEAR(scrollSpringMotion->GetCurrentPosition(), 0.0, DBL_EPSILON);
2140 
2141     /**
2142      * @tc.steps: step3. verify ScrollSpringMotion middle point.
2143      * @tc.expected: step3. result is correct.
2144      */
2145     scrollSpringMotion->Move(500.0f);
2146     EXPECT_FALSE(scrollSpringMotion->IsCompleted());
2147     EXPECT_EQ(floor(scrollSpringMotion->GetCurrentPosition()), 496);
2148 
2149     /**
2150      * @tc.steps: step4. verify ScrollSpringMotion end point.
2151      * @tc.expected: step4. result is correct.
2152      */
2153     scrollSpringMotion->Move(1500.0f);
2154     EXPECT_TRUE(scrollSpringMotion->IsCompleted());
2155     EXPECT_NEAR(scrollSpringMotion->GetCurrentPosition(), 500.0, DBL_EPSILON);
2156 }
2157 
2158 /**
2159  * @tc.name: AnimationScrollMotionTest001
2160  * @tc.desc: play scroll motion: always spring
2161  * @tc.type: FUNC
2162  * @tc.require: AR000DAIGS
2163  * @tc.author: zhouzebin
2164  */
2165 HWTEST_F(AnimationFrameworkTest, AnimationScrollMotionTest001, TestSize.Level1)
2166 {
2167     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationScrollMotionTest001 start";
2168     /**
2169      * @tc.steps: step1. init motion and animator
2170      */
2171     auto spring = AceType::MakeRefPtr<SpringProperty>(1.0, 170.0, 28.684);
2172     platformWindowRaw_->SetNanoFrameTime(NANOSECOND_TO_MILLISECOND * 1000);
2173     flushEventMock_->InitController(context_);
2174     auto scrollMotion =
2175         AceType::MakeRefPtr<ScrollMotion>(500.0, -7500.0, ExtentPair(0.0, 1000.0), ExtentPair(0.0, 1000.0), spring);
__anonf8f9cd0e0402(const double& position) 2176     scrollMotion->AddListener([this](const double& position) { flushEventMock_->SetPositionResult(position); });
2177     auto controller = flushEventMock_->GetAnimator();
2178     controller->PlayMotion(scrollMotion);
2179 
2180     /**
2181      * @tc.steps: step2. trigger frames to make it done
2182      * @tc.expected: step2. friction has been done.
2183      */
2184     platformWindowRaw_->TriggerOneFrame();
2185     EXPECT_FALSE(scrollMotion->IsCompleted());
2186 
2187     platformWindowRaw_->TriggerOneFrame();
2188     EXPECT_FALSE(scrollMotion->IsCompleted());
2189     EXPECT_NEAR(500.0, flushEventMock_->GetPositionResult(), CUBIC_ERROR_BOUND);
2190 }
2191 
2192 /**
2193  * @tc.name: AnimationBasicPropertyTest001
2194  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: none, duration: 0
2195  * @tc.type: FUNC
2196  * @tc.require: AR000DAIGS
2197  * @tc.author: zhouzebin
2198  */
2199 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest001, TestSize.Level1)
2200 {
2201     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest001 start";
2202     /**
2203      * @tc.steps: step1. init animation and animator
2204      */
2205     InitBasicPropertyTest(0, 1, AnimationOperation::REVERSE, FillMode::NONE, true);
2206 
2207     /**
2208      * @tc.steps: step2. trigger frames to make animation done
2209      * @tc.expected: step2. check interpolateValue and end value is correct
2210      */
2211     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
2212 }
2213 
2214 /**
2215  * @tc.name: AnimationBasicPropertyTest002
2216  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: none, duration: 20
2217  * @tc.type: FUNC
2218  * @tc.require: AR000DAIGS
2219  * @tc.author: zhouzebin
2220  */
2221 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest002, TestSize.Level1)
2222 {
2223     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest002 start";
2224     /**
2225      * @tc.steps: step1. init animation and animator
2226      */
2227     InitBasicPropertyTest(20, 1, AnimationOperation::REVERSE, FillMode::NONE, true);
2228 
2229     /**
2230      * @tc.steps: step2. trigger frames to make animation done
2231      * @tc.expected: step2. check interpolateValue and end value is correct
2232      */
2233     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
2234 }
2235 
2236 /**
2237  * @tc.name: AnimationBasicPropertyTest003
2238  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: forward, duration: 0
2239  * @tc.type: FUNC
2240  * @tc.require: AR000DAIGS
2241  * @tc.author: zhouzebin
2242  */
2243 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest003, TestSize.Level1)
2244 {
2245     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest003 start";
2246     /**
2247      * @tc.steps: step1. init animation and animator
2248      */
2249     InitBasicPropertyTest(0, 1, AnimationOperation::REVERSE, FillMode::FORWARDS, true);
2250 
2251     /**
2252      * @tc.steps: step2. trigger frames to make animation done
2253      * @tc.expected: step2. check interpolateValue and end value is correct
2254      */
2255     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2256 }
2257 
2258 /**
2259  * @tc.name: AnimationBasicPropertyTest004
2260  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: forward, duration: 20
2261  * @tc.type: FUNC
2262  * @tc.require: AR000DAIGS
2263  * @tc.author: zhouzebin
2264  */
2265 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest004, TestSize.Level1)
2266 {
2267     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest004 start";
2268     /**
2269      * @tc.steps: step1. init animation and animator
2270      */
2271     InitBasicPropertyTest(20, 1, AnimationOperation::REVERSE, FillMode::FORWARDS, true);
2272 
2273     /**
2274      * @tc.steps: step2. trigger frames to make animation done
2275      * @tc.expected: step2. check interpolateValue and end value is correct
2276      */
2277     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2278 }
2279 
2280 /**
2281  * @tc.name: AnimationBasicPropertyTest005
2282  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: none, duration: 0
2283  * @tc.type: FUNC
2284  * @tc.require: AR000DAIGS
2285  * @tc.author: zhouzebin
2286  */
2287 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest005, TestSize.Level1)
2288 {
2289     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest005 start";
2290     /**
2291      * @tc.steps: step1. init animation and animator
2292      */
2293     InitBasicPropertyTest(0, 1, AnimationOperation::PLAY, FillMode::NONE, true);
2294 
2295     /**
2296      * @tc.steps: step2. trigger frames to make animation done
2297      * @tc.expected: step2. check interpolateValue and end value is correct
2298      */
2299     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
2300 }
2301 
2302 /**
2303  * @tc.name: AnimationBasicPropertyTest006
2304  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: none, duration: 20
2305  * @tc.type: FUNC
2306  * @tc.require: AR000DAIGS
2307  * @tc.author: zhouzebin
2308  */
2309 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest006, TestSize.Level1)
2310 {
2311     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest006 start";
2312     /**
2313      * @tc.steps: step1. init animation and animator
2314      */
2315     InitBasicPropertyTest(20, 1, AnimationOperation::PLAY, FillMode::NONE, true);
2316 
2317     /**
2318      * @tc.steps: step2. trigger frames to make animation done
2319      * @tc.expected: step2. check interpolateValue and end value is correct
2320      */
2321     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
2322 }
2323 
2324 /**
2325  * @tc.name: AnimationBasicPropertyTest007
2326  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: forward, duration: 0
2327  * @tc.type: FUNC
2328  * @tc.require: AR000DAIGS
2329  * @tc.author: zhouzebin
2330  */
2331 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest007, TestSize.Level1)
2332 {
2333     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest007 start";
2334     /**
2335      * @tc.steps: step1. init animation and animator
2336      */
2337     InitBasicPropertyTest(0, 1, AnimationOperation::PLAY, FillMode::FORWARDS, true);
2338 
2339     /**
2340      * @tc.steps: step2. trigger frames to make animation done
2341      * @tc.expected: step2. check interpolateValue and end value is correct
2342      */
2343     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
2344 }
2345 
2346 /**
2347  * @tc.name: AnimationBasicPropertyTest008
2348  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: forward, duration: 20
2349  * @tc.type: FUNC
2350  * @tc.require: AR000DAIGS
2351  * @tc.author: zhouzebin
2352  */
2353 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest008, TestSize.Level1)
2354 {
2355     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest008 start";
2356     /**
2357      * @tc.steps: step1. init animation and animator
2358      */
2359     InitBasicPropertyTest(20, 1, AnimationOperation::PLAY, FillMode::FORWARDS, true);
2360 
2361     /**
2362      * @tc.steps: step2. trigger frames to make animation done
2363      * @tc.expected: step2. check interpolateValue and end value is correct
2364      */
2365     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
2366 }
2367 
2368 /**
2369  * @tc.name: AnimationBasicPropertyTest009
2370  * @tc.desc: Test combination for init: null, from 1 -> 9; reverse, fill-mode: none, duration: 0,repeat: 1, delay: 10
2371  * @tc.type: FUNC
2372  * @tc.require: AR000DAIGS
2373  * @tc.author: jiangdayuan
2374  */
2375 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest009, TestSize.Level1)
2376 {
2377     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest009 start";
2378     /**
2379      * @tc.steps: step1. init animation and animator
2380      */
2381     InitBasicPropertyTest(0, 2, AnimationOperation::REVERSE, FillMode::NONE, false);
2382 
2383     /**
2384      * @tc.steps: step2. trigger frames to make animation done
2385      * @tc.expected: step2. check interpolateValue and end value is correct
2386      */
2387     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
2388 }
2389 
2390 /**
2391  * @tc.name: AnimationBasicPropertyTest010
2392  * @tc.desc: Test combination for init: null, from 1 -> 9; reverse, fill-mode: none, duration: 20,repeat: 1, delay: 10
2393  * @tc.type: FUNC
2394  * @tc.require: AR000DAIGS
2395  * @tc.author: jiangdayuan
2396  */
2397 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest010, TestSize.Level1)
2398 {
2399     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest010 start";
2400     /**
2401      * @tc.steps: step1. init animation and animator
2402      */
2403     InitBasicPropertyTest(20, 2, AnimationOperation::REVERSE, FillMode::NONE, false);
2404 
2405     /**
2406      * @tc.steps: step2. trigger frames to make animation done
2407      * @tc.expected: step2. check interpolateValue and end value is correct
2408      */
2409     platformWindowRaw_->TriggerOneFrame();
2410     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2411     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2412     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2413 
2414     platformWindowRaw_->TriggerOneFrame();
2415     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2416     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2417     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2418 
2419     /**
2420      * @tc.steps: step3. repeat animation
2421      * @tc.expected: step3. check repeat animation value is correct
2422      */
2423     platformWindowRaw_->TriggerOneFrame();
2424     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2425     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2426     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2427 
2428     platformWindowRaw_->TriggerOneFrame();
2429     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2430     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2431     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2432 
2433     platformWindowRaw_->TriggerOneFrame();
2434     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2435     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2436     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2437 }
2438 
2439 /**
2440  * @tc.name: AnimationBasicPropertyTest011
2441  * @tc.desc: Test combination for init: null, from 1 -> 9; reverse, fill-mode: forwards, duration: 0,repeat: 1, delay:
2442  * 10
2443  * @tc.type: FUNC
2444  * @tc.require: AR000DAIGS
2445  * @tc.author: jiangdayuan
2446  */
2447 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest011, TestSize.Level1)
2448 {
2449     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest011 start";
2450     /**
2451      * @tc.steps: step1. init animation and animator
2452      */
2453     InitBasicPropertyTest(0, 2, AnimationOperation::REVERSE, FillMode::FORWARDS, false);
2454 
2455     /**
2456      * @tc.steps: step2. trigger frames to make animation done
2457      * @tc.expected: step2. check interpolateValue and end value is correct
2458      */
2459     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2460 }
2461 
2462 /**
2463  * @tc.name: AnimationBasicPropertyTest012
2464  * @tc.desc: Test combination for init: null, from 1 -> 9; reverse, fill-mode: forwards, duration: 20,repeat: 1, delay:
2465  * 10
2466  * @tc.type: FUNC
2467  * @tc.require: AR000DAIGS
2468  * @tc.author: jiangdayuan
2469  */
2470 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest012, TestSize.Level1)
2471 {
2472     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest012 start";
2473     /**
2474      * @tc.steps: step1. init animation and animator
2475      */
2476     InitBasicPropertyTest(20, 2, AnimationOperation::REVERSE, FillMode::FORWARDS, false);
2477 
2478     /**
2479      * @tc.steps: step2. trigger frames to make animation done
2480      * @tc.expected: step2. check interpolateValue and end value is correct
2481      */
2482     platformWindowRaw_->TriggerOneFrame();
2483     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2484     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2485     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2486 
2487     platformWindowRaw_->TriggerOneFrame();
2488     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2489     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2490     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2491 
2492     /**
2493      * @tc.steps: step3. repeat animation
2494      * @tc.expected: step3. check repeat animation value is correct
2495      */
2496     platformWindowRaw_->TriggerOneFrame();
2497     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2498     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2499     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2500 
2501     platformWindowRaw_->TriggerOneFrame();
2502     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2503     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2504     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2505 
2506     platformWindowRaw_->TriggerOneFrame();
2507     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2508     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2509     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2510 }
2511 
2512 /**
2513  * @tc.name: AnimationBasicPropertyTest013
2514  * @tc.desc: Test combination for init: null, from 1 -> 9; normal, fill-mode: none, duration: 0,repeat: 1, delay: 10
2515  * @tc.type: FUNC
2516  * @tc.require: AR000DAIGS
2517  * @tc.author: jiangdayuan
2518  */
2519 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest013, TestSize.Level1)
2520 {
2521     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest013 start";
2522     /**
2523      * @tc.steps: step1. init animation and animator
2524      */
2525     InitBasicPropertyTest(0, 2, AnimationOperation::PLAY, FillMode::NONE, false);
2526 
2527     /**
2528      * @tc.steps: step2. trigger frames to make animation done
2529      * @tc.expected: step2. check interpolateValue and end value is correct
2530      */
2531     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2532 }
2533 
2534 /**
2535  * @tc.name: AnimationBasicPropertyTest014
2536  * @tc.desc: Test combination for init: null, from 1 -> 9; normal, fill-mode: none, duration: 20,repeat: 1, delay: 10
2537  * @tc.type: FUNC
2538  * @tc.require: AR000DAIGS
2539  * @tc.author: jiangdayuan
2540  */
2541 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest014, TestSize.Level1)
2542 {
2543     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest014 start";
2544     /**
2545      * @tc.steps: step1. init animation and animator
2546      */
2547     InitBasicPropertyTest(20, 2, AnimationOperation::PLAY, FillMode::NONE, false);
2548 
2549     /**
2550      * @tc.steps: step2. trigger frames to make animation done
2551      * @tc.expected: step2. check interpolateValue and end value is correct
2552      */
2553     platformWindowRaw_->TriggerOneFrame();
2554     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2555     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2556     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2557 
2558     platformWindowRaw_->TriggerOneFrame();
2559     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2560     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2561     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2562 
2563     /**
2564      * @tc.steps: step3. repeat animation
2565      * @tc.expected: step3. check repeat animation value is correct
2566      */
2567     platformWindowRaw_->TriggerOneFrame();
2568     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2569     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2570     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2571 
2572     platformWindowRaw_->TriggerOneFrame();
2573     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2574     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2575     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2576 
2577     platformWindowRaw_->TriggerOneFrame();
2578     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2579     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2580     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2581 }
2582 
2583 /**
2584  * @tc.name: AnimationBasicPropertyTest015
2585  * @tc.desc: Test combination for init: null, from 1 -> 9; normal, fill-mode: forwards, duration: 0,repeat: 1, delay:
2586  * 10
2587  * @tc.type: FUNC
2588  * @tc.require: AR000DAIGS
2589  * @tc.author: jiangdayuan
2590  */
2591 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest015, TestSize.Level1)
2592 {
2593     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest015 start";
2594     /**
2595      * @tc.steps: step1. init animation and animator
2596      */
2597     InitBasicPropertyTest(0, 2, AnimationOperation::PLAY, FillMode::FORWARDS, false);
2598 
2599     /**
2600      * @tc.steps: step2. trigger frames to make animation done
2601      * @tc.expected: step2. check interpolateValue and end value is correct
2602      */
2603     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
2604 }
2605 
2606 /**
2607  * @tc.name: AnimationBasicPropertyTest016
2608  * @tc.desc: Test combination for init: null, from 1 -> 9; normal, fill-mode: forwards, duration: 20,repeat: 1, delay:
2609  * 10
2610  * @tc.type: FUNC
2611  * @tc.require: AR000DAIGS
2612  * @tc.author: jiangdayuan
2613  */
2614 HWTEST_F(AnimationFrameworkTest, AnimationBasicPropertyTest016, TestSize.Level1)
2615 {
2616     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest016 start";
2617     /**
2618      * @tc.steps: step1. init animation and animator
2619      */
2620     InitBasicPropertyTest(20, 2, AnimationOperation::PLAY, FillMode::FORWARDS, false);
2621 
2622     /**
2623      * @tc.steps: step2. trigger frames to make animation done
2624      * @tc.expected: step2. check interpolateValue and end value is correct
2625      */
2626     platformWindowRaw_->TriggerOneFrame();
2627     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2628     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2629     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2630 
2631     platformWindowRaw_->TriggerOneFrame();
2632     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2633     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2634     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2635 
2636     /**
2637      * @tc.steps: step3. repeat animation
2638      * @tc.expected: step3. check repeat animation value is correct
2639      */
2640     platformWindowRaw_->TriggerOneFrame();
2641     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2642     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2643     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2644 
2645     platformWindowRaw_->TriggerOneFrame();
2646     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2647     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2648     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2649 
2650     platformWindowRaw_->TriggerOneFrame();
2651     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2652     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
2653     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2654 }
2655 
2656 /**
2657  * @tc.name: AnimationEndTest001
2658  * @tc.desc: End controller for animation when in start delay
2659  * @tc.type: FUNC
2660  * @tc.require: AR000DAIGS
2661  * @tc.author: zhouzebin
2662  */
2663 HWTEST_F(AnimationFrameworkTest, AnimationEndTest001, TestSize.Level1)
2664 {
2665     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationEndTest001 start";
2666     /**
2667      * @tc.steps: step1. init animation and animator
2668      */
2669     InitAnimationAndAnimator(FRAME_TIME_IN_MILLISECOND, 2, FRAME_TIME_IN_MILLISECOND);
2670 
2671     /**
2672      * @tc.steps: step2. trigger one frame to make prepare animation work
2673      * @tc.expected: step2. postFlush has been called.
2674      */
2675     platformWindowRaw_->TriggerOneFrame();
2676     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
2677 
2678     /**
2679      * @tc.steps: step3. end when in start delay
2680      */
2681     platformWindowRaw_->TriggerOneFrame();
2682     flushEventMock_->GetAnimator()->Finish();
2683 
2684     /**
2685      * @tc.expected: step4. check the end
2686      */
2687     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
2688     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2689 }
2690 
2691 /**
2692  * @tc.name: AnimationEndTest002
2693  * @tc.desc: End controller for animation when in first loop
2694  * @tc.type: FUNC
2695  * @tc.require: AR000DAIGS
2696  * @tc.author: zhouzebin
2697  */
2698 HWTEST_F(AnimationFrameworkTest, AnimationEndTest002, TestSize.Level1)
2699 {
2700     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationEndTest002 start";
2701     /**
2702      * @tc.steps: step1. init animation and animator
2703      */
2704     InitAnimationAndAnimator(FRAME_TIME_IN_MILLISECOND, 2, FRAME_TIME_IN_MILLISECOND);
2705 
2706     /**
2707      * @tc.steps: step2. trigger one frame to make prepare animation work
2708      * @tc.expected: step2. postFlush has been called.
2709      */
2710     platformWindowRaw_->TriggerOneFrame();
2711     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
2712 
2713     /**
2714      * @tc.steps: step3. skip start delay.
2715      */
2716     platformWindowRaw_->TriggerOneFrame();
2717     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2718     flushEventMock_->GetAnimator()->Finish();
2719 
2720     /**
2721      * @tc.expected: step4. check the end
2722      */
2723     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
2724     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2725 }
2726 
2727 /**
2728  * @tc.name: AnimationEndTest003
2729  * @tc.desc: End controller for animation when in last loop
2730  * @tc.type: FUNC
2731  * @tc.require: AR000DAIGS
2732  * @tc.author: zhouzebin
2733  */
2734 HWTEST_F(AnimationFrameworkTest, AnimationEndTest003, TestSize.Level1)
2735 {
2736     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationEndTest003 start";
2737     /**
2738      * @tc.steps: step1. init animation and animator
2739      */
2740     InitAnimationAndAnimator(FRAME_TIME_IN_MILLISECOND, 1, FRAME_TIME_IN_MILLISECOND);
2741 
2742     /**
2743      * @tc.steps: step2. trigger one frame to make prepare animation work
2744      * @tc.expected: step2. postFlush has been called.
2745      */
2746     platformWindowRaw_->TriggerOneFrame();
2747     EXPECT_EQ(1, flushEventMock_->postFlushCallTimes_);
2748 
2749     /**
2750      * @tc.steps: step3. skip start delay.
2751      */
2752     platformWindowRaw_->TriggerOneFrame();
2753     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
2754     flushEventMock_->GetAnimator()->Finish();
2755 
2756     /**
2757      * @tc.expected: step4. check the end
2758      */
2759     EXPECT_EQ(4, flushEventMock_->animationIntValue_);
2760     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2761 }
2762 
2763 /**
2764  * @tc.name: AnimationPlayTest001
2765  * @tc.desc: play controller for animation when is playing
2766  * @tc.type: FUNC
2767  * @tc.require: AR000DQ20L
2768  * @tc.author: zhouzebin
2769  */
2770 HWTEST_F(AnimationFrameworkTest, AnimationPlayTest001, TestSize.Level1)
2771 {
2772     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest001 start";
2773     /**
2774      * @tc.steps: step1. init animation and animator
2775      */
2776     InitBasicPropertyTest(20, 1, AnimationOperation::PLAY, FillMode::NONE, true);
2777 
2778     /**
2779      * @tc.steps: step2. trigger frames to make animation done
2780      * @tc.expected: step2. check interpolateValue and end value is correct
2781      */
2782     platformWindowRaw_->TriggerOneFrame();
2783     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2784     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2785     auto controller = flushEventMock_->GetAnimator();
2786     controller->Play();
2787 
2788     platformWindowRaw_->TriggerOneFrame();
2789     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
2790     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2791 }
2792 
2793 /**
2794  * @tc.name: AnimationPlayTest002
2795  * @tc.desc: play controller for animation when is reverse playing
2796  * @tc.type: FUNC
2797  * @tc.require: AR000DQ20L
2798  * @tc.author: zhouzebin
2799  */
2800 HWTEST_F(AnimationFrameworkTest, AnimationPlayTest002, TestSize.Level1)
2801 {
2802     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest001 start";
2803     /**
2804      * @tc.steps: step1. init animation and animator
2805      */
2806     InitBasicPropertyTest(20, 1, AnimationOperation::REVERSE, FillMode::NONE, true);
2807 
2808     /**
2809      * @tc.steps: step2. trigger frames to make animation done
2810      * @tc.expected: step2. check interpolateValue and end value is correct
2811      */
2812     platformWindowRaw_->TriggerOneFrame();
2813     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2814     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2815     auto controller = flushEventMock_->GetAnimator();
2816     controller->Play();
2817 
2818     platformWindowRaw_->TriggerOneFrame();
2819     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
2820     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2821 }
2822 
2823 /**
2824  * @tc.name: AnimationPlayTest003
2825  * @tc.desc: play controller for animation when is finished
2826  * @tc.type: FUNC
2827  * @tc.require: AR000DQ20L
2828  * @tc.author: zhouzebin
2829  */
2830 HWTEST_F(AnimationFrameworkTest, AnimationPlayTest003, TestSize.Level1)
2831 {
2832     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest003 start";
2833     /**
2834      * @tc.steps: step1. init animation and animator
2835      */
2836     InitBasicPropertyTest(20, 1, AnimationOperation::FINISH, FillMode::FORWARDS, true);
2837 
2838     /**
2839      * @tc.steps: step2. trigger frames to make animation done
2840      * @tc.expected: step2. check interpolateValue and end value is correct
2841      */
2842     platformWindowRaw_->TriggerOneFrame();
2843     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2844     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2845     flushEventMock_->animationStopStatus_ = false;
2846     auto controller = flushEventMock_->GetAnimator();
2847     controller->Play();
2848 
2849     platformWindowRaw_->TriggerOneFrame();
2850     platformWindowRaw_->TriggerOneFrame();
2851     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2852     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2853 }
2854 
2855 /**
2856  * @tc.name: AnimationPlayTest004
2857  * @tc.desc: play controller for animation when is paused
2858  * @tc.type: FUNC
2859  * @tc.require: AR000DQ20L
2860  * @tc.author: zhouzebin
2861  */
2862 HWTEST_F(AnimationFrameworkTest, AnimationPlayTest004, TestSize.Level1)
2863 {
2864     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest004 start";
2865     /**
2866      * @tc.steps: step1. init animation and animator
2867      */
2868     InitBasicPropertyTest(20, 1, AnimationOperation::PAUSE, FillMode::FORWARDS, true);
2869 
2870     /**
2871      * @tc.steps: step2. trigger frames to make animation done
2872      * @tc.expected: step2. check interpolateValue and end value is correct
2873      */
2874     platformWindowRaw_->TriggerOneFrame();
2875     EXPECT_EQ(-1, flushEventMock_->animationIntValue_);
2876     auto controller = flushEventMock_->GetAnimator();
2877     controller->Play();
2878 
2879     platformWindowRaw_->TriggerOneFrame();
2880     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2881     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2882 
2883     platformWindowRaw_->TriggerOneFrame();
2884     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2885     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2886 }
2887 
2888 /**
2889  * @tc.name: AnimationPlayTest005
2890  * @tc.desc: play controller for animation when is canceled
2891  * @tc.type: FUNC
2892  * @tc.require: AR000DQ20L
2893  * @tc.author: zhouzebin
2894  */
2895 HWTEST_F(AnimationFrameworkTest, AnimationPlayTest005, TestSize.Level1)
2896 {
2897     GTEST_LOG_(INFO) << "AnimationFrameworkTest AnimationBasicPropertyTest005 start";
2898     /**
2899      * @tc.steps: step1. init animation and animator
2900      */
2901     InitBasicPropertyTest(20, 1, AnimationOperation::CANCEL, FillMode::FORWARDS, true);
2902 
2903     /**
2904      * @tc.steps: step2. trigger frames to make animation done
2905      * @tc.expected: step2. check interpolateValue and end value is correct
2906      */
2907     platformWindowRaw_->TriggerOneFrame();
2908     EXPECT_EQ(-1, flushEventMock_->animationIntValue_);
2909     auto controller = flushEventMock_->GetAnimator();
2910     controller->Play();
2911 
2912     platformWindowRaw_->TriggerOneFrame();
2913     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
2914     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
2915 
2916     platformWindowRaw_->TriggerOneFrame();
2917     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
2918     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
2919 }
2920 
2921 /**
2922  * @tc.name: AnimationDirectionTest001
2923  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: forwards,
2924  * AnimationDirection: alternate, duration: 0
2925  * @tc.type: FUNC
2926  * @tc.require: AR000FL0VN
2927  * @tc.author: wanyanglan
2928  */
2929 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest001, TestSize.Level1)
2930 {
2931     /**
2932      * @tc.steps: step1. init animation and simulation controller
2933      */
2934     InitBasicAnimationDirectionPropertyTest(
2935         0, 1, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
2936 
2937     /**
2938      * @tc.steps: step2. trigger frames to make animation done
2939      * @tc.expected: step2. check interpolateValue and end value is correct
2940      */
2941     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2942 }
2943 
2944 /**
2945  * @tc.name: AnimationDirectionTest002
2946  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; reverse, fill-mode: forward,
2947  * AnimationDirection: alternate, duration: 20
2948  * @tc.type: FUNC
2949  * @tc.require: AR000FL0VN
2950  * @tc.author: wanyanglan
2951  */
2952 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest002, TestSize.Level1)
2953 {
2954     /**
2955      * @tc.steps: step1. init animation and simulation controller
2956      */
2957     InitBasicAnimationDirectionPropertyTest(
2958         20, 1, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
2959 
2960     /**
2961      * @tc.steps: step2. trigger frames to make animation done
2962      * @tc.expected: step2. check interpolateValue and end value is correct
2963      */
2964     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
2965 }
2966 
2967 /**
2968  * @tc.name: AnimationDirectionTest003
2969  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: forward,
2970  * AnimationDirection: alternate, duration: 20
2971  * @tc.type: FUNC
2972  * @tc.require: AR000FL0VN
2973  * @tc.author: wanyanglan
2974  */
2975 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest003, TestSize.Level1)
2976 {
2977     /**
2978      * @tc.steps: step1. init animation and simulation controller
2979      */
2980     InitBasicAnimationDirectionPropertyTest(
2981         20, 1, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
2982 
2983     /**
2984      * @tc.steps: step2. trigger frames to make animation done
2985      * @tc.expected: step2. check interpolateValue and end value is correct
2986      */
2987     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
2988 }
2989 
2990 /**
2991  * @tc.name: AnimationDirectionTest004
2992  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forward, AnimationDirection:
2993  * alternate, duration: 0, repeat: 2
2994  * @tc.type: FUNC
2995  * @tc.require: AR000FL0VN
2996  * @tc.author: wanyanglan
2997  */
2998 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest004, TestSize.Level1)
2999 {
3000     /**
3001      * @tc.steps: step1. init animation and simulation controller
3002      */
3003     InitBasicAnimationDirectionPropertyTest(
3004         0, 2, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
3005 
3006     /**
3007      * @tc.steps: step2. trigger frames to make animation done
3008      * @tc.expected: step2. check interpolateValue and end value is correct
3009      */
3010     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
3011 }
3012 
3013 /**
3014  * @tc.name: AnimationDirectionTest005
3015  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forward, AnimationDirection:
3016  * alternate, duration: 20, repeat: 2
3017  * @tc.type: FUNC
3018  * @tc.require: AR000FL0VN
3019  * @tc.author: wanyanglan
3020  */
3021 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest005, TestSize.Level1)
3022 {
3023     /**
3024      * @tc.steps: step1. init animation and simulation controller
3025      */
3026     InitBasicAnimationDirectionPropertyTest(
3027         20, 2, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
3028 
3029     /**
3030      * @tc.steps: step2. trigger frames to make animation done
3031      * @tc.expected: step2. check interpolateValue and end value is correct
3032      */
3033     RunAndCheckBasicAnimationDirectionPropertyTest(1.0f, 2);
3034 }
3035 
3036 /**
3037  * @tc.name: AnimationDirectionTest006
3038  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3039  * alternate, duration: 20, repeat: 2
3040  * @tc.type: FUNC
3041  * @tc.require: AR000FL0VN
3042  * @tc.author: wanyanglan
3043  */
3044 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest006, TestSize.Level1)
3045 {
3046     /**
3047      * @tc.steps: step1. init animation and simulation controller
3048      */
3049     InitBasicAnimationDirectionPropertyTest(
3050         20, 2, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
3051 
3052     /**
3053      * @tc.steps: step2. trigger frames to make animation done
3054      * @tc.expected: step2. check interpolateValue and end value is correct
3055      */
3056     RunAndCheckBasicAnimationDirectionPropertyTest(1.0f, 2);
3057 }
3058 
3059 /**
3060  * @tc.name: AnimationDirectionTest007
3061  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3062  * normal, duration: 0, repeat: 2
3063  * @tc.type: FUNC
3064  * @tc.require: AR000FL0VN
3065  * @tc.author: wanyanglan
3066  */
3067 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest007, TestSize.Level1)
3068 {
3069     /**
3070      * @tc.steps: step1. init animation and simulation controller
3071      */
3072     InitBasicAnimationDirectionPropertyTest(
3073         0, 2, AnimationDirection::NORMAL, AnimationOperation::PLAY, FillMode::FORWARDS);
3074 
3075     /**
3076      * @tc.steps: step2. trigger frames to make animation done
3077      * @tc.expected: step2. check interpolateValue and end value is correct
3078      */
3079     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
3080 }
3081 
3082 /**
3083  * @tc.name: AnimationDirectionTest008
3084  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forward, AnimationDirection:
3085  * alternate, duration: 0, repeat: 3
3086  * @tc.type: FUNC
3087  * @tc.require: AR000FL0VN
3088  * @tc.author: wanyanglan
3089  */
3090 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest008, TestSize.Level1)
3091 {
3092     /**
3093      * @tc.steps: step1. init animation and simulation controller
3094      */
3095     InitBasicAnimationDirectionPropertyTest(
3096         0, 3, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
3097 
3098     /**
3099      * @tc.steps: step2. trigger frames to make animation done
3100      * @tc.expected: step2. check interpolateValue and end value is correct
3101      */
3102     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
3103 }
3104 
3105 /**
3106  * @tc.name: AnimationDirectionTest009
3107  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forward, AnimationDirection:
3108  * alternate, duration: 20, repeat: 3
3109  * @tc.type: FUNC
3110  * @tc.require: AR000FL0VN
3111  * @tc.author: wanyanglan
3112  */
3113 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest009, TestSize.Level1)
3114 {
3115     /**
3116      * @tc.steps: step1. init animation and simulation controller
3117      */
3118     InitBasicAnimationDirectionPropertyTest(
3119         20, 3, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
3120 
3121     /**
3122      * @tc.steps: step2. trigger frames to make animation done
3123      * @tc.expected: step2. check interpolateValue and end value is correct
3124      */
3125     RunAndCheckBasicAnimationDirectionPropertyTest(1.0f, 3);
3126 }
3127 
3128 /**
3129  * @tc.name: AnimationDirectionTest010
3130  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3131  * alternate, duration: 20, repeat: 3
3132  * @tc.type: FUNC
3133  * @tc.require: AR000FL0VN
3134  * @tc.author: wanyanglan
3135  */
3136 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest010, TestSize.Level1)
3137 {
3138     /**
3139      * @tc.steps: step1. init animation and simulation controller
3140      */
3141     InitBasicAnimationDirectionPropertyTest(
3142         20, 3, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
3143 
3144     RunAndCheckBasicAnimationDirectionPropertyTest(9.0f, 3);
3145 }
3146 
3147 /**
3148  * @tc.name: AnimationDirectionTest011
3149  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3150  * alternate, duration: 0, repeat: 3
3151  * @tc.type: FUNC
3152  * @tc.require: AR000FL0VN
3153  * @tc.author: wanyanglan
3154  */
3155 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest011, TestSize.Level1)
3156 {
3157     /**
3158      * @tc.steps: step1. init animation and simulation controller
3159      */
3160     InitBasicAnimationDirectionPropertyTest(
3161         0, 3, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
3162 
3163     /**
3164      * @tc.steps: step2. trigger frames to make animation done
3165      * @tc.expected: step2. check interpolateValue and end value is correct
3166      */
3167     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
3168 }
3169 
3170 /**
3171  * @tc.name: AnimationDirectionTest012
3172  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forward, AnimationDirection:
3173  * alternate, duration: 20, repeat: infinite
3174  * @tc.type: FUNC
3175  * @tc.require: AR000FL0VN
3176  * @tc.author: wanyanglan
3177  */
3178 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest012, TestSize.Level1)
3179 {
3180     /**
3181      * @tc.steps: step1. init animation and simulation controller
3182      */
3183     InitBasicAnimationDirectionPropertyTest(
3184         20, -1, AnimationDirection::ALTERNATE, AnimationOperation::REVERSE, FillMode::FORWARDS);
3185 
3186     /**
3187      * @tc.steps: step2. trigger frames to make animation done
3188      * @tc.expected: step2. check interpolateValue and end value is correct
3189      */
3190     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3191 
3192     /**
3193      * @tc.steps: step3. repeat animation
3194      * @tc.expected: step3. check repeat animation value is correct
3195      */
3196     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3197 
3198     /**
3199      * @tc.steps: step4. repeat animation
3200      * @tc.expected: step4. check repeat animation value is correct
3201      */
3202     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3203 
3204     /**
3205      * @tc.steps: step5. repeat animation
3206      * @tc.expected: step5. check repeat animation value is correct
3207      */
3208     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3209 }
3210 
3211 /**
3212  * @tc.name: AnimationDirectionTest013
3213  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3214  * alternate, duration: 20, repeat: infinite
3215  * @tc.type: FUNC
3216  * @tc.require: AR000FL0VN
3217  * @tc.author: wanyanglan
3218  */
3219 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest013, TestSize.Level1)
3220 {
3221     /**
3222      * @tc.steps: step1. init animation and simulation controller
3223      */
3224     InitBasicAnimationDirectionPropertyTest(
3225         20, -1, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
3226 
3227     /**
3228      * @tc.steps: step2. trigger frames to make animation done
3229      * @tc.expected: step2. check interpolateValue and end value is correct
3230      */
3231     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3232 
3233     /**
3234      * @tc.steps: step3. trigger frames to make animation done
3235      * @tc.expected: step3. check interpolateValue and end value is correct
3236      */
3237     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3238 
3239     /**
3240      * @tc.steps: step4. repeat animation
3241      * @tc.expected: step4. check repeat animation value is correct
3242      */
3243     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3244 
3245     /**
3246      * @tc.steps: step5. repeat animation
3247      * @tc.expected: step5. check repeat animation value is correct
3248      */
3249     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3250 }
3251 
3252 /**
3253  * @tc.name: AnimationDirectionTest014
3254  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forward, AnimationDirection:
3255  * alternate, duration: 40, repeat: 3
3256  * @tc.type: FUNC
3257  * @tc.require: AR000FL0VN
3258  * @tc.author: wanyanglan
3259  */
3260 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest014, TestSize.Level1)
3261 {
3262     /**
3263      * @tc.steps: step1. init animation and simulation controller
3264      */
3265     InitBasicAnimationDirectionPropertyTest(
3266         40, -1, AnimationDirection::ALTERNATE, AnimationOperation::PLAY, FillMode::FORWARDS);
3267 
3268     /**
3269      * @tc.steps: step2. trigger frames to make animation done
3270      * @tc.expected: step2. check interpolateValue and end value is correct
3271      */
3272     platformWindowRaw_->TriggerOneFrame();
3273     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3274     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3275     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3276 
3277     platformWindowRaw_->TriggerOneFrame();
3278     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3279     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3280     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3281     flushEventMock_->GetAnimator()->Reverse();
3282 
3283     /**
3284      * @tc.steps: step3. repeat animation
3285      * @tc.expected: step3. check repeat animation value is correct
3286      */
3287     platformWindowRaw_->TriggerOneFrame();
3288     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3289     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3290     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3291 
3292     platformWindowRaw_->TriggerOneFrame();
3293     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
3294     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3295     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3296 
3297     /**
3298      * @tc.steps: step3. repeat animation
3299      * @tc.expected: step3. check repeat animation value is correct
3300      */
3301     platformWindowRaw_->TriggerOneFrame();
3302     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3303     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3304     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3305 
3306     platformWindowRaw_->TriggerOneFrame();
3307     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3308     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3309     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3310 
3311     platformWindowRaw_->TriggerOneFrame();
3312     EXPECT_EQ(7, flushEventMock_->animationIntValue_);
3313     EXPECT_NEAR(7.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3314     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3315     flushEventMock_->GetAnimator()->Play();
3316 
3317     platformWindowRaw_->TriggerOneFrame();
3318     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
3319     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3320     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3321     flushEventMock_->GetAnimator()->Play();
3322 
3323     platformWindowRaw_->TriggerOneFrame();
3324     EXPECT_EQ(7, flushEventMock_->animationIntValue_);
3325     EXPECT_NEAR(7.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3326     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3327 }
3328 
3329 /**
3330  * @tc.name: AnimationDirectionTest015
3331  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: none,
3332  * AnimationDirection: normal, duration: 0
3333  * @tc.type: FUNC
3334  * @tc.require: AR000FL0VN
3335  * @tc.author: wanyanglan
3336  */
3337 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest015, TestSize.Level1)
3338 {
3339     /**
3340      * @tc.steps: step1. init animation and simulation controller
3341      */
3342     InitBasicAnimationDirectionPropertyTest(0, 1, AnimationDirection::NORMAL, AnimationOperation::PLAY, FillMode::NONE);
3343 
3344     /**
3345      * @tc.steps: step2. trigger frames to make animation done
3346      * @tc.expected: step2. check interpolateValue and end value is correct
3347      */
3348     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
3349 }
3350 
3351 /**
3352  * @tc.name: AnimationDirectionTest016
3353  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: forwards,
3354  * AnimationDirection: alternate-reverse, duration: 0
3355  * @tc.type: FUNC
3356  * @tc.require: AR000FL0VN
3357  * @tc.author: jiangdayuan
3358  */
3359 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest016, TestSize.Level1)
3360 {
3361     /**
3362      * @tc.steps: step1. init animation and simulation controller
3363      */
3364     InitBasicAnimationDirectionPropertyTest(
3365         0, 1, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3366 
3367     /**
3368      * @tc.steps: step2. trigger frames to make animation done
3369      * @tc.expected: step2. check interpolateValue and end value is correct
3370      */
3371     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
3372 }
3373 
3374 /**
3375  * @tc.name: AnimationDirectionTest017
3376  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: forwards,
3377  * AnimationDirection: alternate-reverse, duration: 20
3378  * @tc.type: FUNC
3379  * @tc.require: AR000FL0VN
3380  * @tc.author: jiangdayuan
3381  */
3382 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest017, TestSize.Level1)
3383 {
3384     /**
3385      * @tc.steps: step1. init animation and simulation controller
3386      */
3387     InitBasicAnimationDirectionPropertyTest(
3388         20, 1, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3389 
3390     /**
3391      * @tc.steps: step2. trigger frames to make animation done
3392      * @tc.expected: step2. check interpolateValue and end value is correct
3393      */
3394     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
3395 }
3396 
3397 /**
3398  * @tc.name: AnimationDirectionTest018
3399  * @tc.desc: Test combination for no delay, no repeat. init: 0, from 1 -> 9; normal, fill-mode: none,
3400  * AnimationDirection: alternate-reverse, duration: 20
3401  * @tc.type: FUNC
3402  * @tc.require: AR000FL0VN
3403  * @tc.author: jiangdayuan
3404  */
3405 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest018, TestSize.Level1)
3406 {
3407     /**
3408      * @tc.steps: step1. init animation and simulation controller
3409      */
3410     InitBasicAnimationDirectionPropertyTest(
3411         20, 1, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::NONE);
3412 
3413     /**
3414      * @tc.steps: step2. trigger frames to make animation done
3415      * @tc.expected: step2. check interpolateValue and end value is correct
3416      */
3417     RunAndCheckBasicPropertyTestInterpolateValue(0.0f);
3418 }
3419 
3420 /**
3421  * @tc.name: AnimationDirectionTest019
3422  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forwards, AnimationDirection:
3423  * alternate-reverse, duration: 0, repeat: 2
3424  * @tc.type: FUNC
3425  * @tc.require: AR000FL0VN
3426  * @tc.author: jiangdayuan
3427  */
3428 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest019, TestSize.Level1)
3429 {
3430     /**
3431      * @tc.steps: step1. init animation and simulation controller
3432      */
3433     InitBasicAnimationDirectionPropertyTest(
3434         0, 2, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3435 
3436     /**
3437      * @tc.steps: step2. trigger frames to make animation done
3438      * @tc.expected: step2. check interpolateValue and end value is correct
3439      */
3440     RunAndCheckBasicPropertyTestInterpolateValue(9.0f);
3441 }
3442 
3443 /**
3444  * @tc.name: AnimationDirectionTest020
3445  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forwards, AnimationDirection:
3446  * alternate-reverse, duration: 20, repeat: 2
3447  * @tc.type: FUNC
3448  * @tc.require: AR000FL0VN
3449  * @tc.author: jiangdayuan
3450  */
3451 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest020, TestSize.Level1)
3452 {
3453     /**
3454      * @tc.steps: step1. init animation and simulation controller
3455      */
3456     InitBasicAnimationDirectionPropertyTest(
3457         20, 2, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3458 
3459     /**
3460      * @tc.steps: step2. trigger frames to make animation done
3461      * @tc.expected: step2. check interpolateValue and end value is correct
3462      */
3463     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3464 
3465     RunAndCheckBasicPropertyTestInterpolateValueForward(9.0f);
3466 }
3467 
3468 /**
3469  * @tc.name: AnimationDirectionTest021
3470  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forwards, AnimationDirection:
3471  * alternate-reverse, duration: 20, repeat: 3
3472  * @tc.type: FUNC
3473  * @tc.require: AR000FL0VK
3474  * @tc.author: jiangdayuan
3475  */
3476 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest021, TestSize.Level1)
3477 {
3478     /**
3479      * @tc.steps: step1. init animation and simulation controller
3480      */
3481     InitBasicAnimationDirectionPropertyTest(
3482         20, 3, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3483 
3484     /**
3485      * @tc.steps: step2. trigger frames to make animation done
3486      * @tc.expected: step2. check interpolateValue and end value is correct
3487      */
3488     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3489 
3490     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3491 
3492     RunAndCheckBasicPropertyTestInterpolateValueReverse(1.0f);
3493 }
3494 
3495 /**
3496  * @tc.name: AnimationDirectionTest022
3497  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: none, AnimationDirection:
3498  * alternate-reverse, duration: 20, repeat: 3
3499  * @tc.type: FUNC
3500  * @tc.require: AR000FL0VJ
3501  * @tc.author: jiangdayuan
3502  */
3503 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest022, TestSize.Level1)
3504 {
3505     /**
3506      * @tc.steps: step1. init animation and simulation controller
3507      */
3508     InitBasicAnimationDirectionPropertyTest(
3509         20, 3, AnimationDirection::ALTERNATE_REVERSE, AnimationOperation::PLAY, FillMode::NONE);
3510 
3511     /**
3512      * @tc.steps: step2. trigger frames to make animation done
3513      * @tc.expected: step2. check interpolateValue and end value is correct
3514      */
3515     RunAndCheckBasicAnimationDirectionPropertyTestReverse();
3516 
3517     RunAndCheckBasicAnimationDirectionPropertyTestForward();
3518 
3519     RunAndCheckBasicPropertyTestInterpolateValueReverse(0.0f);
3520 }
3521 
3522 /**
3523  * @tc.name: AnimationDirectionTest023
3524  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; reverse, fill-mode: forwards, AnimationDirection:
3525  * reverse, duration: 0, repeat: 2
3526  * @tc.type: FUNC
3527  * @tc.require: AR000FL0VI
3528  * @tc.author: jiangdayuan
3529  */
3530 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest023, TestSize.Level1)
3531 {
3532     /**
3533      * @tc.steps: step1. init animation and simulation controller
3534      */
3535     InitBasicAnimationDirectionPropertyTest(
3536         0, 2, AnimationDirection::REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3537 
3538     /**
3539      * @tc.steps: step2. trigger frames to make animation done
3540      * @tc.expected: step2. check interpolateValue and end value is correct
3541      */
3542     RunAndCheckBasicPropertyTestInterpolateValue(1.0f);
3543 }
3544 
3545 /**
3546  * @tc.name: AnimationDirectionTest024
3547  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: forwards, AnimationDirection:
3548  * reverse, duration: 20, repeat: 2
3549  * @tc.type: FUNC
3550  * @tc.require: AR000FL0VH
3551  * @tc.author: jiangdayuan
3552  */
3553 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest024, TestSize.Level1)
3554 {
3555     /**
3556      * @tc.steps: step1. init animation and simulation controller
3557      */
3558     InitBasicAnimationDirectionPropertyTest(
3559         20, 2, AnimationDirection::REVERSE, AnimationOperation::PLAY, FillMode::FORWARDS);
3560 
3561     /**
3562      * @tc.steps: step2. trigger frames to make animation done
3563      * @tc.expected: step2. check interpolateValue and end value is correct
3564      */
3565     platformWindowRaw_->TriggerOneFrame();
3566     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3567     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3568     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3569 
3570     platformWindowRaw_->TriggerOneFrame();
3571     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
3572     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3573     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3574 
3575     platformWindowRaw_->TriggerOneFrame();
3576     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3577     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3578     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3579 
3580     platformWindowRaw_->TriggerOneFrame();
3581     EXPECT_EQ(1, flushEventMock_->animationIntValue_);
3582     EXPECT_NEAR(1.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3583     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
3584 }
3585 
3586 /**
3587  * @tc.name: AnimationDirectionTest025
3588  * @tc.desc: Test combination for no delay. init: 0, from 1 -> 9; normal, fill-mode: none, AnimationDirection:
3589  * reverse, duration: 20, repeat: 2
3590  * @tc.type: FUNC
3591  * @tc.require: AR000FL0VM
3592  * @tc.author: jiangdayuan
3593  */
3594 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest025, TestSize.Level1)
3595 {
3596     /**
3597      * @tc.steps: step1. init animation and simulation controller
3598      */
3599     InitBasicAnimationDirectionPropertyTest(
3600         20, 2, AnimationDirection::REVERSE, AnimationOperation::PLAY, FillMode::NONE);
3601 
3602     /**
3603      * @tc.steps: step2. trigger frames to make animation done
3604      * @tc.expected: step2. check interpolateValue and end value is correct
3605      */
3606     platformWindowRaw_->TriggerOneFrame();
3607     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3608     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3609     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3610 
3611     platformWindowRaw_->TriggerOneFrame();
3612     EXPECT_EQ(9, flushEventMock_->animationIntValue_);
3613     EXPECT_NEAR(9.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3614     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3615 
3616     platformWindowRaw_->TriggerOneFrame();
3617     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3618     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3619     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3620 
3621     platformWindowRaw_->TriggerOneFrame();
3622     EXPECT_EQ(0, flushEventMock_->animationIntValue_);
3623     EXPECT_NEAR(0.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3624     EXPECT_TRUE(flushEventMock_->animationStopStatus_);
3625 }
3626 
3627 /**
3628  * @tc.name: AnimationDirectionTest026
3629  * @tc.desc: Test for Forward and Backward twice
3630  * reverse, duration: 40, repeat: 2
3631  * @tc.type: FUNC
3632  * @tc.require: AR000FL0VM
3633  * @tc.author: zhouzebin
3634  */
3635 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest026, TestSize.Level1)
3636 {
3637     /**
3638      * @tc.steps: step1. init animation and simulation controller
3639      */
3640     InitBasicAnimationDirectionPropertyTest(
3641         40, 1, AnimationDirection::NORMAL, AnimationOperation::NONE, FillMode::FORWARDS);
3642 
3643     /**
3644      * @tc.steps: step2. first round. trigger forward and backward
3645      * @tc.expected: step2. check interpolateValue and end value is correct
3646      */
3647     auto controller = flushEventMock_->GetAnimator();
3648     controller->Forward();
3649     platformWindowRaw_->TriggerOneFrame();
3650     platformWindowRaw_->TriggerOneFrame();
3651     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3652     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3653     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3654 
3655     controller->Backward();
3656     platformWindowRaw_->TriggerOneFrame();
3657     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3658     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3659 
3660     /**
3661      * @tc.steps: step3. second round. trigger forward and backward
3662      * @tc.expected: step3. check interpolateValue and end value is correct
3663      */
3664     controller->Forward();
3665     platformWindowRaw_->TriggerOneFrame();
3666     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3667     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3668 
3669     controller->Backward();
3670     platformWindowRaw_->TriggerOneFrame();
3671     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3672     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3673 }
3674 
3675 /**
3676  * @tc.name: AnimationDirectionTest027
3677  * @tc.desc: Test for play / Forward
3678  * normal, duration: 40, repeat: 0
3679  * @tc.type: FUNC
3680  * @tc.require: AR000FL0VM
3681  * @tc.author: zhouzebin
3682  */
3683 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest027, TestSize.Level1)
3684 {
3685     /**
3686      * @tc.steps: step1. init animation and simulation controller
3687      */
3688     InitBasicAnimationDirectionPropertyTest(
3689         40, 1, AnimationDirection::NORMAL, AnimationOperation::NONE, FillMode::FORWARDS);
3690 
3691     /**
3692      * @tc.steps: step2. first round. trigger play and forward
3693      * @tc.expected: step2. check interpolateValue and end value is correct
3694      */
3695     auto controller = flushEventMock_->GetAnimator();
3696     controller->Play();
3697     platformWindowRaw_->TriggerOneFrame();
3698     platformWindowRaw_->TriggerOneFrame();
3699     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3700     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3701     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3702 
3703     controller->Forward();
3704     platformWindowRaw_->TriggerOneFrame();
3705     EXPECT_EQ(7, flushEventMock_->animationIntValue_);
3706     EXPECT_NEAR(7.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3707 }
3708 
3709 /**
3710  * @tc.name: AnimationDirectionTest028
3711  * @tc.desc: Test for Reverse / Backward
3712  * normal, duration: 40, repeat: 0
3713  * @tc.type: FUNC
3714  * @tc.require: AR000FL0VM
3715  * @tc.author: zhouzebin
3716  */
3717 HWTEST_F(AnimationFrameworkTest, AnimationDirectionTest028, TestSize.Level1)
3718 {
3719     /**
3720      * @tc.steps: step1. init animation and simulation controller
3721      */
3722     InitBasicAnimationDirectionPropertyTest(
3723         40, 1, AnimationDirection::NORMAL, AnimationOperation::NONE, FillMode::FORWARDS);
3724 
3725     /**
3726      * @tc.steps: step2. first round. trigger reverse and backward
3727      * @tc.expected: step2. check interpolateValue and end value is correct
3728      */
3729     auto controller = flushEventMock_->GetAnimator();
3730     controller->Reverse();
3731     platformWindowRaw_->TriggerOneFrame();
3732     platformWindowRaw_->TriggerOneFrame();
3733     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3734     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3735     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3736 
3737     controller->Backward();
3738     platformWindowRaw_->TriggerOneFrame();
3739     EXPECT_EQ(3, flushEventMock_->animationIntValue_);
3740     EXPECT_NEAR(3.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3741 
3742     controller->Reverse();
3743     platformWindowRaw_->TriggerOneFrame();
3744     EXPECT_EQ(5, flushEventMock_->animationIntValue_);
3745     EXPECT_NEAR(5.0f, flushEventMock_->keyframeAnimationValue_, FLT_EPSILON);
3746     EXPECT_FALSE(flushEventMock_->animationStopStatus_);
3747 }
3748 } // namespace OHOS::Ace
3749