1 /*
2  * Copyright (c) 2024 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 #ifndef ROSEN_MODULES_RENDER_SERVICE_CLIENT_TEST_UNITTEST_ANIMATION_RS_ANIMATION_TEST_UTILS_H
17 #define ROSEN_MODULES_RENDER_SERVICE_CLIENT_TEST_UNITTEST_ANIMATION_RS_ANIMATION_TEST_UTILS_H
18 
19 #include "animation/rs_animation_common.h"
20 #include "common/rs_vector2.h"
21 #include "common/rs_vector3.h"
22 #include "common/rs_vector4.h"
23 #include "common/rs_matrix3.h"
24 #include "modifier/rs_property.h"
25 #include "modifier/rs_property_modifier.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 namespace ANIMATIONTEST {
30 constexpr int64_t START_NUMBER = 181154000809;
31 constexpr int64_t INCREASE_NUMBER = 16666667;
32 constexpr  unsigned int FIRST_ANIMATION = 0;
33 constexpr  unsigned int SECOND_ANIMATION = 1;
34 constexpr  unsigned int CORRECT_SIZE = 1;
35 constexpr  unsigned int CORRECT_GROUP_SIZE = 2;
36 constexpr  unsigned int DELAY_TIME_ONE = 1;
37 constexpr  unsigned int DELAY_TIME_TWO = 2;
38 constexpr  unsigned int DELAY_TIME_THREE = 3;
39 constexpr  unsigned int DELAY_TIME_REFRESH = 16667;
40 constexpr float CANVAS_NODE_BOUNDS_WIDTH = 500.f;
41 constexpr float CANVAS_NODE_BOUNDS_HEIGHT = 500.f;
42 constexpr float ANIMATION_DEFAULT_VALUE = 0.f;
43 constexpr float ANIMATION_START_VALUE = 0.f;
44 constexpr float ANIMATION_END_VALUE = 500.f;
45 constexpr float ANIMATION_END_VALUE_ALPHA = 100.f;
46 constexpr uint32_t ANIMATION_DURATION = 1000;
47 constexpr uint32_t ANIMATION_DURATION_2 = 2000;
48 constexpr float KEYFRAME_ANIMATION_FRACTION = 1.f;
49 constexpr float KEYFRAME_ANIMATION_START_VALUE = 50.f;
50 constexpr float KEYFRAME_ANIMATION_END_VALUE = 150.f;
51 constexpr uint32_t ANIMATION_MOCK_ID = 1556;
52 constexpr float SPRING_ANIMATION_START_VALUE = 1.0f;
53 constexpr float SPRING_ANIMATION_END_VALUE = 100.0f;
54 constexpr uint32_t RGBA_DEFAULT_COLOR = 0x00;
55 constexpr uint32_t RGBA_START_COLOR = 0xFF000000;
56 constexpr uint32_t RGBA_END_COLOR = 0xFFFF0000;
57 const std::string  ANIMATION_PATH = "L350 0 L150 100";
58 const Vector2f PATH_ANIMATION_DEFAULT_VALUE = Vector2f(0.f, 0.f);
59 const Vector2f PATH_ANIMATION_START_VALUE = Vector2f(0.f, 0.f);
60 const Vector2f PATH_ANIMATION_END_VALUE = Vector2f(500.f, 500.f);
61 const Vector2f ANIMATION_NORMAL_SCALE = Vector2f(1.f, 1.f);
62 const Vector2f ANIMATION_TENTH_SCALE = Vector2f(0.1f, 0.1f);
63 const Vector2f ANIMATION_HALF_SCALE = Vector2f(0.5f, 0.5f);
64 const Vector2f ANIMATION_DOUBLE_SCALE = Vector2f(2.f, 2.f);
65 const Vector4f ANIMATION_START_BOUNDS = Vector4f(100.f, 100.f, 200.f, 300.f);
66 const Vector4f ANIMATION_MIDDLE_BOUNDS = Vector4f(100.f, 100.f, 250.f, 300.f);
67 const Vector4f ANIMATION_END_BOUNDS = Vector4f(100.f, 100.f, 300.f, 300.f);
68 const Vector4f ANIMATION_FIRST_BOUNDS = Vector4f(80.f, 100.f, 100.f, 250.f);
69 const Vector4f ANIMATION_SECOND_BOUNDS = Vector4f(50.f, 50.f, 150.f, 100.f);
70 const Vector4f ANIMATION_THIRD_BOUNDS = Vector4f(100.f, 80.f, 150.f, 500.f);
71 const Vector4f TRANSITION_EFFECT_ROTATE = Vector4f(50.f, 50.f, 50.f, 50.f);
72 const RotationMode ROTATION_MODE_DATA[] = {RotationMode::ROTATE_NONE,
73     RotationMode::ROTATE_AUTO,
74     RotationMode::ROTATE_AUTO_REVERSE};
75 const float BEGIN_FRACTION_DATA[] = {0.1f, 0.2f, 0.3f, 0.4f, 0.5f};
76 const float END_FRACTION_DATA[] = {0.6f, 0.7f, 0.8f, 0.9f, 1.0f};
77 constexpr uint32_t SUCCESS_INT = 1;
78 const std::string SUCCESS_STRING = "success";
79 constexpr bool SUCCESS_BOOL = true;
80 const unsigned int INVALID_STATUS = -1;  // invalid status label for replace animation
81 const unsigned int APPEAR_STATUS = 1 ;   // appear status label for replace animation
82 
83 const Drawing::DrawingPiecewiseParameter BOUNCE_FIRST_PHASE_PARAS = {
84     OHOS::Rosen::Drawing::DrawingCurveType::LINEAR, // animation curve type
85     {},
86     16, 0,                         // 16 is animation duration, 0 is animation delay
87     {
88         {"sx", {1.01, 1}},          // scale of x-axis is from 1.01 to 1
89         {"sy", {1.01, 1}}           // scale of y-axis is from 1.01 to 1
90     }
91 };
92 const Drawing::DrawingPiecewiseParameter BOUNCE_SECOND_PHASE_PARAS = {
93     OHOS::Rosen::Drawing::DrawingCurveType::SPRING, // animation curve type
94     {
95         {"velocity", 0},           // 0 is velocity of animation curve
96         {"mass", 1},               // 1 is mass of animation curve
97         {"stiffness", 228},        // 228 is stiffness of animation curve
98         {"damping", 22}            // 22 is damping of animation curve
99     },
100     16, 0,                         // 16 is animation duration, 0 is animation delay
101     {
102         {"sx", {1.01, 1}},          // scale of x-axis is from 1.01 to 1
103         {"sy", {1.01, 1}}           // scale of y-axis is from 1.01 to 1
104     }
105 };
106 const Drawing::DrawingPiecewiseParameter APPEAR_FIRST_PHASE_PARAS = {
107     OHOS::Rosen::Drawing::DrawingCurveType::SPRING, // animation curve type
108     {
109         {"velocity", 0},           // 0 is velocity of animation curve
110         {"mass", 1},               // 1 is mass of animation curve
111         {"stiffness", 228},        // 228 is stiffness of animation curve
112         {"damping", 22}            // 22 is damping of animation curve
113     },
114     16, 0,                         // 16 is animation duration, 0 is animation delay
115     {
116         {"sx", {0.9, 1}},          // scale of x-axis is from 0.9 to 1
117         {"sy", {0.9, 1}}           // scale of y-axis is from 0.9 to 1
118     }
119 };
120 const Drawing::DrawingPiecewiseParameter APPEAR_SECOND_PHASE_PARAS = {
121     OHOS::Rosen::Drawing::DrawingCurveType::LINEAR, // animation curve type
122     {},
123     100, 0,                        // 100 is animation duration, 0 is animation delay
124     {{"alpha", {0.0, 1}}}          // alpha is from 0 to 1
125 };
126 const std::vector<float> TIME_PERCENTS = {0.0, 0.35, 0.35, 1.0};
127 const std::vector<float> ALPHA_VALUES = {0.4, 1.0, 1.0, 0.4};
128 const Drawing::DrawingPiecewiseParameter VARIABLECOLOR_FIRST_PHASE_PARAS = {
129     OHOS::Rosen::Drawing::DrawingCurveType::SHARP, // animation curve type
130     {
131         {"ctrlX1", 0.33},          // 0.33 is x coord of the first control point
132         {"ctrlY1", 0},             // 0 is y coord of the first control point
133         {"ctrlX2", 0.67},          // 0.67 is x coord of the second control point
134         {"ctrlY2", 1}              // 1 is y coord of the second control point
135     },
136     250, 0,                        // 250 is animation duration, 0 is animation delay
137     {{"alpha", {0.4, 1}}}          // alpha is from 0.4 to 1
138 };
139 const Drawing::DrawingPiecewiseParameter VARIABLECOLOR_SECOND_PHASE_PARAS = {
140     OHOS::Rosen::Drawing::DrawingCurveType::SHARP, // animation curve type
141     {
142         {"ctrlX1", 0.33},          // 0.33 is x coord of the first control point
143         {"ctrlY1", 0},             // 0 is y coord of the first control point
144         {"ctrlX2", 0.67},          // 0.67 is x coord of the second control point
145         {"ctrlY2", 1}              // 1 is y coord of the second control point
146     },
147     450, 250,                      // 450 is animation duration, 250 is animation delay
148     {{"alpha", {1, 0.4}}}          // alpha is from 1 to 0.4
149 };
150 const Drawing::DrawingPiecewiseParameter DISAPPEAR_FIRST_PHASE_PARAS = {
151     OHOS::Rosen::Drawing::DrawingCurveType::SPRING, // animation curve type
152     {
153         {"velocity", 0},           // 0 is velocity of animation curve
154         {"mass", 1},               // 1 is mass of animation curve
155         {"stiffness", 228},        // 228 is stiffness of animation curve
156         {"damping", 22}            // 22 is damping of animation curve
157     },
158     16, 0,                         // 16 is animation duration, 0 is animation delay
159     {
160         {"sx", {1, 0.3}},          // scale of x-axis is from 1 to 0.3
161         {"sy", {1, 0.3}}           // scale of y-axis is from 1 to 0.3
162     }
163 };
164 const Drawing::DrawingPiecewiseParameter DISAPPEAR_SECOND_PHASE_PARAS = {
165     OHOS::Rosen::Drawing::DrawingCurveType::LINEAR, // animation curve type
166     {},
167     100, 0,                        // 100 is animation duration, 0 is animation delay
168     {{"alpha", {1.0, 0.0}}}        // alpha is from 1 to 0
169 };
170 
171 const TextEngine::SymbolAnimationConfig VARIABLE_COLOR_CONFIG = {
172     {}, 0, // symbolNodes is {}; numNodes is 0;
173     Drawing::DrawingEffectStrategy::VARIABLE_COLOR, // effectStrategy is VARIABLE_COLOR;
174     9999, 0, // symbolSpanId is 9999, which is a random value; animationMode is 0, which means iterative mode;
175     1, true, Drawing::DrawingCommonSubType::DOWN // repeatCount is 1; animationStart is true;move direction is
176 
177 };
178 
179 const TextEngine::SymbolAnimationConfig PULSE_CONFIG = {
180     {}, 0, // symbolNodes is {}; numNodes is 0;
181     Drawing::DrawingEffectStrategy::PULSE, // effectStrategy is PULSE;
182     8888, 0, // symbolSpanId is 8888, which is a random value; animationMode is 0, which means hierarchical mode;
183     1, true, Drawing::DrawingCommonSubType::DOWN // repeatCount is 1; animationStart is true;move direction is downward
184 };
185 } // ANIMATIONTEST
186 } // namespace Rosen
187 } // namespace OHOS
188 #endif // ROSEN_MODULES_RENDER_SERVICE_CLIENT_TEST_UNITTEST_ANIMATION_RS_ANIMATION_TEST_UTILS_H
189