Skip to content

Commit 5af203d

Browse files
committed
add unroll unittest
1 parent 10f5276 commit 5af203d

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxAnimationTest.cs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// NOTE: comment out the next line to leave temporary FBX files on disk
2+
// #define DEBUG_UNITTEST
3+
14
using UnityEngine;
25
using UnityEditor;
36
using NUnit.Framework;
@@ -77,11 +80,11 @@ public static IEnumerable TestCases4 {
7780
// specify continuous rotations
7881
public static IEnumerable TestCases5 {
7982
get {
80-
yield return new TestCaseData (RotationInterpolation.kEuler /*use euler values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
83+
yield return new TestCaseData (RotationInterpolation.kEuler /*use euler values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (6);
8184
// Uni-35616 can't programmatically define a Euler (Quaternion) mix.
8285
// yield return new TestCaseData (RotationInterpolation.kMixed /*use euler+quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
8386
// Uni-35616 doesn't work with quaternions; rotations don't exceed 180
84-
// yield return new TestCaseData (RotationInterpolation.kQuaternion /*use quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
87+
yield return new TestCaseData (RotationInterpolation.kQuaternion /*use quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (6);
8588
}
8689
}
8790

@@ -112,8 +115,9 @@ public class FbxAnimationTest : ExporterTestBase
112115
[TearDown]
113116
public override void Term ()
114117
{
115-
// NOTE: comment out the next line to leave temporary FBX files on disk
118+
#if (!DEBUG_UNITTEST)
116119
base.Term ();
120+
#endif
117121
}
118122

119123
protected void AnimClipPropertyTest (AnimationClip animClipExpected, AnimationClip animClipActual)
@@ -384,6 +388,13 @@ public int AnimTest (KeyData keyData, string testName)
384388
AssetDatabase.ImportAsset (path);
385389
}
386390

391+
// create a scene GO so we can compare.
392+
#if DEBUG_UNITTEST
393+
GameObject prefabGO = AssetDatabase.LoadMainAssetAtPath (path) as GameObject;
394+
GameObject sceneGO = Object.Instantiate(prefabGO, keyData.targetObject.transform.localPosition, keyData.targetObject.transform.localRotation);
395+
sceneGO.name = "Imported_" + testName;
396+
#endif
397+
387398
//acquire imported object from exported file
388399
AnimationClip animClipImported = GetClipFromFbx (path);
389400

@@ -392,23 +403,31 @@ public int AnimTest (KeyData keyData, string testName)
392403
// check animCurve & keys
393404
int result = 0;
394405

406+
// keyed localEulerAnglesRaw.z m_LocalRotation.z -1
395407
foreach (EditorCurveBinding curveBinding in AnimationUtility.GetCurveBindings (animClipImported)) {
396408
AnimationCurve animCurveImported = AnimationUtility.GetEditorCurve (animClipImported, curveBinding);
397409
Assert.That (animCurveImported, Is.Not.Null);
398410

399-
string altPropertyName;
411+
string altBinding;
412+
413+
MapAltPropertyName.TryGetValue (curveBinding.propertyName, out altBinding);
400414

401-
MapAltPropertyName.TryGetValue (curveBinding.propertyName, out altPropertyName);
415+
bool hasAltBinding = !string.IsNullOrEmpty (altBinding);
402416

403-
bool hasAltPropertyName = !string.IsNullOrEmpty (altPropertyName);
417+
if (!hasAltBinding)
418+
altBinding = curveBinding.propertyName;
404419

405-
if (!hasAltPropertyName)
406-
altPropertyName = curveBinding.propertyName;
420+
int id = keyData.GetIndexOf (curveBinding.propertyName);
407421

408-
int id = keyData.GetIndexOf (altPropertyName);
422+
if (id == -1)
423+
id = keyData.GetIndexOf (altBinding);
424+
425+
#if DEBUG_UNITTEST
426+
Debug.Log(string.Format("animtest binding={0} altBinding={1} id={2}", curveBinding.propertyName, altBinding, id));
427+
#endif
409428

410429
if (id != -1) {
411-
AnimCurveTest (keyData.keyTimesInSeconds, hasAltPropertyName ? keyData.GetAltKeyValues (id) : keyData.GetKeyValues (id), animCurveImported, curveBinding.propertyName);
430+
AnimCurveTest (keyData.keyTimesInSeconds, hasAltBinding ? keyData.GetAltKeyValues (id) : keyData.GetKeyValues (id), animCurveImported, curveBinding.propertyName);
412431
result++;
413432
}
414433
}
@@ -491,6 +510,8 @@ public void LegacySkinnedMeshAnimTest (string fbxPath)
491510
AnimCurveTest(animCurveImported, animCurveOrig, curveBinding.propertyName);
492511
}
493512
}
513+
514+
494515
}
495516

496517
[Test, TestCaseSource (typeof (AnimationTestDataClass), "TestCases1")]

0 commit comments

Comments
 (0)