Skip to content

Commit b4f99b5

Browse files
author
Austin Jubrey
committed
[CHANGED] moved unit test to more appropriate file
[CHANGED] replaced tabs with spaces for my unit test
1 parent a108b29 commit b4f99b5

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -221,62 +221,6 @@ GameObject ModifySourceFbx()
221221
return newModel;
222222
}
223223

224-
[Test]
225-
public void AnimationWithLightTest()
226-
{
227-
string filename = GetRandomFbxFilePath ();
228-
GameObject go = new GameObject ();
229-
Light light = go.AddComponent(typeof (Light)) as Light;
230-
Animation anim = go.AddComponent (typeof(Animation)) as Animation;
231-
232-
Keyframe[] keys;
233-
keys = new Keyframe[3];
234-
keys[0] = new Keyframe(0.0f, 0.25f);
235-
keys[1] = new Keyframe(1.0f, 0.5f);
236-
keys[2] = new Keyframe(2.0f, 1.0f);
237-
238-
AnimationCurve curve = new AnimationCurve (keys);
239-
240-
AnimationClip clip = new AnimationClip ();
241-
242-
clip.legacy = true;
243-
244-
clip.SetCurve ("", typeof(Light), "m_Intensity", curve);
245-
246-
anim.AddClip (clip, "test");
247-
248-
//export the object
249-
var exported = FbxExporters.Editor.ModelExporter.ExportObject(filename , go);
250-
251-
//acquire exported file
252-
GameObject asset = AssetDatabase.LoadMainAssetAtPath(filename) as GameObject;
253-
254-
//access the exported game objects' light
255-
Light foundLight = asset.GetComponent (typeof(Light)) as Light;
256-
257-
//Check that the light exists
258-
Assert.IsNotNull (foundLight);
259-
260-
//Set the time of the animation to 0 seconds
261-
clip.SampleAnimation(asset, 0.0f);
262-
263-
//check that the value matches the key at 0 seconds
264-
Assert.AreEqual (foundLight.intensity, 0.25f);
265-
266-
//Set the time of the animation to 1 second
267-
clip.SampleAnimation(asset, 1.0f);
268-
269-
//check that the value matches the key at 1 second
270-
Assert.AreEqual (foundLight.intensity, 0.5f);
271-
272-
//Set the time of the animation to 2 seconds
273-
clip.SampleAnimation(asset, 2.0f);
274-
275-
//check that the value matches the key at 2 seconds
276-
Assert.AreEqual (foundLight.intensity, 1.0f);
277-
278-
}
279-
280224
[Test]
281225
public void BasicTest() {
282226
// Verify we start in the right place.

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,62 @@ private void CompareLightValues(Light light, Light fbxLight, float delta=0.001f)
438438
Assert.IsTrue (light.transform.rotation == fbxLight.transform.rotation);
439439
}
440440

441+
[Test]
442+
public void AnimationWithLightTest()
443+
{
444+
string filename = GetRandomFbxFilePath ();
445+
GameObject go = new GameObject ();
446+
Light light = go.AddComponent(typeof (Light)) as Light;
447+
Animation anim = go.AddComponent (typeof(Animation)) as Animation;
448+
449+
Keyframe[] keys;
450+
keys = new Keyframe[3];
451+
keys[0] = new Keyframe(0.0f, 0.25f);
452+
keys[1] = new Keyframe(1.0f, 0.5f);
453+
keys[2] = new Keyframe(2.0f, 1.0f);
454+
455+
AnimationCurve curve = new AnimationCurve (keys);
456+
457+
AnimationClip clip = new AnimationClip ();
458+
459+
clip.legacy = true;
460+
461+
clip.SetCurve ("", typeof(Light), "m_Intensity", curve);
462+
463+
anim.AddClip (clip, "test");
464+
465+
//export the object
466+
var exported = FbxExporters.Editor.ModelExporter.ExportObject(filename , go);
467+
468+
//acquire exported file
469+
GameObject asset = AssetDatabase.LoadMainAssetAtPath(filename) as GameObject;
470+
471+
//access the exported game objects' light
472+
Light foundLight = asset.GetComponent (typeof(Light)) as Light;
473+
474+
//Check that the light exists
475+
Assert.IsNotNull (foundLight);
476+
477+
//Set the time of the animation to 0 seconds
478+
clip.SampleAnimation(asset, 0.0f);
479+
480+
//check that the value matches the key at 0 seconds
481+
Assert.AreEqual (foundLight.intensity, 0.25f);
482+
483+
//Set the time of the animation to 1 second
484+
clip.SampleAnimation(asset, 1.0f);
485+
486+
//check that the value matches the key at 1 second
487+
Assert.AreEqual (foundLight.intensity, 0.5f);
488+
489+
//Set the time of the animation to 2 seconds
490+
clip.SampleAnimation(asset, 2.0f);
491+
492+
//check that the value matches the key at 2 seconds
493+
Assert.AreEqual (foundLight.intensity, 1.0f);
494+
495+
}
496+
441497
[Test]
442498
public void TestComponentAttributeExport()
443499
{

0 commit comments

Comments
 (0)