Skip to content

Commit 0c98f9b

Browse files
committed
add unit test for not exporting one of the sources
- check that it still exports the other two sources as expected
1 parent f479d61 commit 0c98f9b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxConstraintTest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,38 @@ public int TestWeightAnimation(float[] keyTimes, float[] keyValues, string prope
217217
return tester.DoIt();
218218
}
219219

220+
[Test]
221+
public void TestDontExportSource()
222+
{
223+
// test that no error occurs if a source is not exported
224+
var constrained = new GameObject("constrained");
225+
var source1 = new GameObject("source1");
226+
var source2 = new GameObject("source2");
227+
var source3 = new GameObject("source3");
228+
229+
var constraint = SetupConstraintWithSources<PositionConstraint>(constrained, new List<GameObject>() { source1, source2, source3 });
230+
231+
// don't export source2
232+
var exportedGO = ExportConstraints(new Object[] { constrained, source1, source3 });
233+
234+
// get exported constraint
235+
var expConstraint = exportedGO.GetComponentInChildren<PositionConstraint>();
236+
Assert.That(expConstraint, Is.Not.Null);
237+
238+
var origSources = new List<ConstraintSource>();
239+
constraint.GetSources(origSources);
240+
241+
var expSources = new List<ConstraintSource>();
242+
expConstraint.GetSources(expSources);
243+
244+
Assert.That(expSources.Count, Is.EqualTo(origSources.Count-1));
245+
246+
Assert.That(expSources[0].sourceTransform, Is.EqualTo(origSources[0].sourceTransform));
247+
Assert.That(expSources[0].weight, Is.EqualTo(origSources[0].weight));
248+
Assert.That(expSources[1].sourceTransform, Is.EqualTo(origSources[2].sourceTransform));
249+
Assert.That(expSources[1].weight, Is.EqualTo(origSources[2].weight));
250+
}
251+
220252
public bool AreEqual(Vector3 a, Vector3 b, double epsilon = 0.0001)
221253
{
222254
return Vector3.SqrMagnitude(a - b) < epsilon;

0 commit comments

Comments
 (0)