Flutter Engine
The Flutter Engine
Functions
SpringAnimationTest.mm File Reference
#include <cmath>
#import "flutter/third_party/spring_animation/spring_animation.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (SpringAnimationTest, CanInitializeCorrectly)
 
 TEST (SpringAnimationTest, CurveFunctionCanWorkCorrectly)
 
 TEST (SpringAnimationTest, CanUpdatePositionValuesAndCalculateCorrectly)
 

Function Documentation

◆ TEST() [1/3]

TEST ( SpringAnimationTest  ,
CanInitializeCorrectly   
)

Definition at line 9 of file SpringAnimationTest.mm.

9 {
10 SpringAnimation* animation = [[SpringAnimation alloc] initWithStiffness:1000
11 damping:500
12 mass:3
13 initialVelocity:0
14 fromValue:0
15 toValue:1000];
16 ASSERT_TRUE(animation.stiffness == 1000);
17 ASSERT_TRUE(animation.damping == 500);
18 ASSERT_TRUE(animation.mass == 3);
19 ASSERT_TRUE(animation.initialVelocity == 0);
20 ASSERT_TRUE(animation.fromValue == 0);
21 ASSERT_TRUE(animation.toValue == 1000);
22}

◆ TEST() [2/3]

TEST ( SpringAnimationTest  ,
CanUpdatePositionValuesAndCalculateCorrectly   
)

Definition at line 42 of file SpringAnimationTest.mm.

42 {
43 SpringAnimation* animation = [[SpringAnimation alloc] initWithStiffness:1000
44 damping:500
45 mass:3
46 initialVelocity:0
47 fromValue:0
48 toValue:1000];
49 const double startTime = 0;
50 const double endTime = 0.6;
51
52 const double startValue1 = [animation curveFunction:startTime];
53 const double toValue1 = [animation curveFunction:endTime];
54
55 animation.fromValue = 10;
56 animation.toValue = 800;
57
58 ASSERT_TRUE(animation.fromValue == 10);
59 ASSERT_TRUE(animation.toValue == 800);
60
61 const double startValue2 = [animation curveFunction:startTime];
62 const double toValue2 = [animation curveFunction:endTime];
63 ASSERT_TRUE(startValue2 > startValue1);
64 ASSERT_TRUE(toValue2 < toValue1);
65}

◆ TEST() [3/3]

TEST ( SpringAnimationTest  ,
CurveFunctionCanWorkCorrectly   
)

Definition at line 24 of file SpringAnimationTest.mm.

24 {
25 // Here is the keyboard curve config on iOS platform.
26 SpringAnimation* animation = [[SpringAnimation alloc] initWithStiffness:1000
27 damping:500
28 mass:3
29 initialVelocity:0
30 fromValue:0
31 toValue:1000];
32 const double accuracy = 1.0;
33 const double startTime = 0;
34 const double endTime = 0.6;
35
36 const double startValue = [animation curveFunction:startTime];
37 ASSERT_TRUE(fabs(startValue - animation.fromValue) < accuracy);
38 const double toValue = [animation curveFunction:endTime];
39 ASSERT_TRUE(fabs(toValue - animation.toValue) < accuracy);
40}