27
27
public class MotionKeyTimeCycleTest {
28
28
private static final boolean DEBUG = true ;
29
29
private static final int SAMPLES = 30 ;
30
-
31
-
32
- class Scene {
33
- MotionWidget mw1 = new MotionWidget ();
34
- MotionWidget mw2 = new MotionWidget ();
35
- MotionWidget res = new MotionWidget ();
36
- KeyCache cache = new KeyCache ();
37
- Motion motion ;
38
-
39
- Scene () {
40
- motion = new Motion (mw1 );
41
- mw1 .setBounds (0 , 0 , 30 , 40 );
42
- mw2 .setBounds (400 , 400 , 430 , 440 );
43
- motion .setPathMotionArc (ArcCurveFit .ARC_START_VERTICAL );
44
- }
45
-
46
- public void setup () {
47
- motion .setStart (mw1 );
48
- motion .setEnd (mw2 );
49
- motion .setup (1000 , 1000 , 1 , 1000000 );
50
- }
51
-
52
- void sample (Runnable r ) {
53
- for (int p = 0 ; p <= SAMPLES ; p ++) {
54
- motion .interpolate (res , p * 0.1f , 1000000 + (int ) (p * 100 ), cache );
55
- r .run ();
56
- }
57
- }
58
- }
30
+ private static final boolean DISABLE = true ;
59
31
60
32
void cycleBuilder (Scene s , int type ) {
61
33
float [] amp = {0 , 50 , 0 };
@@ -66,7 +38,7 @@ void cycleBuilder(Scene s, int type) {
66
38
cycle .setValue (type , amp [i ]);
67
39
cycle .setValue (TypedValues .CycleType .TYPE_WAVE_PERIOD , period [i ]);
68
40
cycle .setFramePosition (pos [i ]);
69
- s .motion .addKey (cycle );
41
+ s .mMotion .addKey (cycle );
70
42
}
71
43
}
72
44
@@ -77,58 +49,120 @@ public Scene basicRunThrough(int type) {
77
49
78
50
if (DEBUG ) {
79
51
s .sample (() -> {
80
- System .out .println (s .res .getValueAttributes (type ));
52
+ System .out .println (s .mRes .getValueAttributes (type ));
81
53
});
82
54
}
83
- s .motion .interpolate (s .res , 0.5f , 1000000 + 1000 , s .cache );
55
+ s .mMotion .interpolate (s .mRes , 0.5f , 1000000 + 1000 , s .mCache );
84
56
return s ;
85
57
}
86
58
59
+ @ Test
60
+ public void disabled () {
61
+ if (DISABLE ) {
62
+ System .out .println (" all test in MotionKeyTimeCycle DISABLE!" );
63
+ }
64
+ assertEquals (DISABLE , true );
65
+ }
66
+
87
67
@ Test
88
68
public void keyCycleRotationX () {
69
+ if (DISABLE ) {
70
+ return ;
71
+ }
72
+
89
73
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_ROTATION_X );
90
- assertEquals (0.0 , s .res .getRotationX (), 0.0001 );
74
+ assertEquals (0.0 , s .mRes .getRotationX (), 0.0001 );
91
75
}
92
76
93
77
@ Test
94
78
public void keyCycleRotationY () {
79
+ if (DISABLE ) {
80
+ return ;
81
+ }
95
82
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_ROTATION_Y );
96
- assertEquals (0.0 , s .res .getRotationY (), 0.0001 );
83
+ assertEquals (0.0 , s .mRes .getRotationY (), 0.0001 );
97
84
}
98
85
99
86
@ Test
100
87
public void keyCycleRotationZ () {
88
+ if (DISABLE ) {
89
+ return ;
90
+ }
101
91
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_ROTATION_Z );
102
- assertEquals (0.0 , s .res .getRotationZ (), 0.0001 );
92
+ assertEquals (0.0 , s .mRes .getRotationZ (), 0.0001 );
103
93
}
104
94
105
95
@ Test
106
96
public void keyCycleTranslationX () {
97
+ if (DISABLE ) {
98
+ return ;
99
+ }
107
100
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_TRANSLATION_X );
108
- assertEquals (0.0 , s .res .getTranslationX (), 0.0001 );
101
+ assertEquals (0.0 , s .mRes .getTranslationX (), 0.0001 );
109
102
}
110
103
111
104
@ Test
112
105
public void keyCycleTranslationY () {
106
+ if (DISABLE ) {
107
+ return ;
108
+ }
113
109
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_TRANSLATION_Y );
114
- assertEquals (0.0 , s .res .getTranslationY (), 0.0001 );
110
+ assertEquals (0.0 , s .mRes .getTranslationY (), 0.0001 );
115
111
}
116
112
117
113
@ Test
118
114
public void keyCycleTranslationZ () {
115
+ if (DISABLE ) {
116
+ return ;
117
+ }
119
118
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_TRANSLATION_Z );
120
- assertEquals (0.0 , s .res .getTranslationZ (), 0.0001 );
119
+ assertEquals (0.0 , s .mRes .getTranslationZ (), 0.0001 );
121
120
}
122
121
123
122
@ Test
124
123
public void keyCycleScaleX () {
124
+ if (DISABLE ) {
125
+ return ;
126
+ }
125
127
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_SCALE_X );
126
- assertEquals (0.0 , s .res .getScaleX (), 0.0001 );
128
+ assertEquals (0.0 , s .mRes .getScaleX (), 0.0001 );
127
129
}
128
130
129
131
@ Test
130
132
public void keyCycleScaleY () {
133
+ if (DISABLE ) {
134
+ return ;
135
+ }
131
136
Scene s = basicRunThrough (TypedValues .CycleType .TYPE_SCALE_Y );
132
- assertEquals (0.0 , s .res .getScaleY (), 0.0001 );
137
+ assertEquals (0.0 , s .mRes .getScaleY (), 0.0001 );
138
+ }
139
+
140
+ class Scene {
141
+ MotionWidget mMW1 = new MotionWidget ();
142
+ MotionWidget mMW2 = new MotionWidget ();
143
+ MotionWidget mRes = new MotionWidget ();
144
+ KeyCache mCache = new KeyCache ();
145
+ Motion mMotion ;
146
+
147
+ Scene () {
148
+ mMotion = new Motion (mMW1 );
149
+ mMW1 .setBounds (0 , 0 , 30 , 40 );
150
+ mMW2 .setBounds (400 , 400 , 430 , 440 );
151
+ mMotion .setPathMotionArc (ArcCurveFit .ARC_START_VERTICAL );
152
+ }
153
+
154
+
155
+ public void setup () {
156
+ mMotion .setStart (mMW1 );
157
+ mMotion .setEnd (mMW2 );
158
+ mMotion .setup (1000 , 1000 , 1 , 1000000 );
159
+ }
160
+
161
+ void sample (Runnable r ) {
162
+ for (int p = 0 ; p <= SAMPLES ; p ++) {
163
+ mMotion .interpolate (mRes , p * 0.1f , 1000000 + (int ) (p * 100 ), mCache );
164
+ r .run ();
165
+ }
166
+ }
133
167
}
134
168
}
0 commit comments