@@ -8,43 +8,65 @@ namespace FbxExporters.UnitTests
8
8
{
9
9
public class AnimationComponentTestDataClass
10
10
{
11
- static float [ ] m_keytimes1 = new float [ 3 ] { 1f , 2f , 3f } ;
12
- static float [ ] m_keyvalues1 = new float [ 3 ] { 0f , 100f , 0f } ;
13
- static float [ ] m_keyvalues2 = new float [ 3 ] { 1f , 100f , 1f } ;
11
+ static float [ ] m_keytimes1 = new float [ 3 ] { 1f , 2f , 3f } ;
12
+ static float [ ] m_keyvalues1 = new float [ 3 ] { 0f , 100f , 0f } ;
13
+ static float [ ] m_keyvalues2 = new float [ 3 ] { 1f , 100f , 1f } ;
14
14
15
15
public static IEnumerable TestCases {
16
16
get {
17
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.x" ) . Returns ( 1 ) ;
18
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.y" ) . Returns ( 1 ) ;
19
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.z" ) . Returns ( 1 ) ;
20
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.x" ) . Returns ( 1 ) ;
21
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.y" ) . Returns ( 1 ) ;
22
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.z" ) . Returns ( 1 ) ;
23
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.x" ) . Returns ( 1 ) ;
24
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.y" ) . Returns ( 1 ) ;
25
- yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.z" ) . Returns ( 1 ) ;
17
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.x" ) . Returns ( 1 ) ;
18
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.y" ) . Returns ( 1 ) ;
19
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.z" ) . Returns ( 1 ) ;
20
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.x" ) . Returns ( 1 ) ;
21
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.y" ) . Returns ( 1 ) ;
22
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalRotation.z" ) . Returns ( 1 ) ;
23
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.x" ) . Returns ( 1 ) ;
24
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.y" ) . Returns ( 1 ) ;
25
+ yield return new TestCaseData ( m_keytimes1 , m_keyvalues1 , typeof ( Transform ) , "m_LocalPosition.z" ) . Returns ( 1 ) ;
26
26
}
27
27
}
28
28
}
29
29
30
30
[ TestFixture ]
31
31
public class FbxAnimationTest : ExporterTestBase
32
32
{
33
+ [ TearDown ]
34
+ public override void Term ( )
35
+ {
36
+ }
37
+
38
+ protected void DumpAnimCurve ( AnimationCurve animCurve , string message , float [ ] keyTimesExpected = null , float [ ] keyValuesExpected = null )
39
+ {
40
+ int idx = 0 ;
41
+ foreach ( var key in animCurve . keys ) {
42
+ if ( keyTimesExpected != null && keyValuesExpected != null ) {
43
+ Debug . Log ( string . Format ( "{5} keys[{0}] {1}({3}) {2} ({4})" ,
44
+ idx , key . time , key . value ,
45
+ keyTimesExpected [ idx ] , keyValuesExpected [ idx ] ,
46
+ message ) ) ;
47
+ } else {
48
+ Debug . Log ( string . Format ( "{3} keys[{0}] {1} {2}" , idx , key . time , key . value , message ) ) ;
49
+ }
50
+ idx ++ ;
51
+ }
52
+ }
53
+
33
54
protected void AnimClipTest ( AnimationClip animClipExpected , AnimationClip animClipActual )
34
55
{
35
- Assert . That ( animClipActual . name , Is . EqualTo ( animClipExpected . name ) ) ;
36
- Assert . That ( animClipActual . legacy , Is . EqualTo ( animClipExpected . legacy ) ) ;
37
- Assert . That ( animClipActual . isLooping , Is . EqualTo ( animClipExpected . isLooping ) ) ;
38
- Assert . That ( animClipActual . wrapMode , Is . EqualTo ( animClipExpected . wrapMode ) ) ;
56
+ Assert . That ( animClipActual . name , Is . EqualTo ( animClipExpected . name ) ) ;
57
+ Assert . That ( animClipActual . legacy , Is . EqualTo ( animClipExpected . legacy ) ) ;
58
+ Assert . That ( animClipActual . isLooping , Is . EqualTo ( animClipExpected . isLooping ) ) ;
59
+ Assert . That ( animClipActual . wrapMode , Is . EqualTo ( animClipExpected . wrapMode ) ) ;
39
60
40
61
// TODO: Uni-34489
41
- Assert . That ( animClipActual . length , Is . EqualTo ( animClipExpected . length ) . Within ( Mathf . Epsilon ) , "animClip length doesn't match" ) ;
62
+ Assert . That ( animClipActual . length , Is . EqualTo ( animClipExpected . length ) . Within ( Mathf . Epsilon ) , "animClip length doesn't match" ) ;
42
63
}
43
64
44
- protected void AnimCurveTest ( float [ ] keyTimesExpected , float [ ] keyValuesExpected , AnimationCurve animCurveActual )
65
+ protected void AnimCurveTest ( float [ ] keyTimesExpected , float [ ] keyValuesExpected , AnimationCurve animCurveActual , string message )
45
66
{
46
67
int numKeysExpected = keyTimesExpected . Length ;
47
68
69
+ DumpAnimCurve ( animCurveActual , message , keyTimesExpected , keyValuesExpected ) ;
48
70
// TODO : Uni-34492 number of keys don't match
49
71
Assert . That ( animCurveActual . length , Is . EqualTo ( numKeysExpected ) , "animcurve number of keys doesn't match" ) ;
50
72
@@ -55,12 +77,6 @@ protected void AnimCurveTest (float [] keyTimesExpected, float [] keyValuesExpec
55
77
return ;
56
78
}
57
79
58
- [ TearDown ]
59
- public override void Term ( )
60
- {
61
- return ;
62
- }
63
-
64
80
[ Test , TestCaseSource ( typeof ( AnimationComponentTestDataClass ) , "TestCases" ) ]
65
81
public int SinglePropertyLegacyAnimTest ( float [ ] keytimes , float [ ] keyvalues , System . Type propertyType , string propertyName )
66
82
{
@@ -140,9 +156,11 @@ public int SinglePropertyLegacyAnimTest (float [] keytimes, float [] keyvalues,
140
156
AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( animClipImported , curveBinding ) ;
141
157
Assert . That ( animCurveImported , Is . Not . Null ) ;
142
158
143
- AnimCurveTest ( keytimes , keyvalues , animCurveImported ) ;
144
-
145
- result ++ ;
159
+ if ( propertyName == curveBinding . propertyName )
160
+ {
161
+ AnimCurveTest ( keytimes , keyvalues , animCurveImported , curveBinding . propertyName ) ;
162
+ result ++ ;
163
+ }
146
164
}
147
165
148
166
return result ;
0 commit comments