Skip to content

Commit 3e1479b

Browse files
committed
code review fixes
* use test case source to pass fbx files * allow for UnitTests to be anywhere in assets folder
1 parent 4cad1e2 commit 3e1479b

File tree

3 files changed

+300
-9
lines changed

3 files changed

+300
-9
lines changed

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,21 @@ public static void AssertSameHierarchy (
261261
AssertSameHierarchy (expectedChild.gameObject, actualChild.gameObject);
262262
}
263263
}
264+
265+
/// <summary>
266+
/// Given the path to a file, find the file relative to
267+
/// the UnitTests folder.
268+
/// </summary>
269+
/// <returns>The path in unit tests.</returns>
270+
/// <param name="partialPath">Partial path.</param>
271+
protected static string FindPathInUnitTests(string partialPath){
272+
foreach (var dir in Directory.GetDirectories(Application.dataPath, "UnitTests", SearchOption.AllDirectories)) {
273+
var fullPath = Path.Combine (dir, partialPath);
274+
if (File.Exists (fullPath)) {
275+
return FbxExporters.EditorTools.ExportSettings.ConvertToAssetRelativePath (fullPath);
276+
}
277+
}
278+
return null;
279+
}
264280
}
265281
}

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,26 @@ private void ExportSkinnedMesh(string fileToExport, out SkinnedMeshRenderer orig
528528
Assert.IsNotNull (exportedSkinnedMesh);
529529
}
530530

531-
[Test]
532-
public void TestSkinnedMeshExport(){
533-
// for now use this cowboy taken from the asset store as the test file
534-
// TODO: find a better/simpler test file
535-
var fbxPath = "FbxExporters/Editor/UnitTests/Models/Cowboy/cowboyMidPoly(riged).fbx";
531+
public class SkinnedMeshTestDataClass
532+
{
533+
public static System.Collections.IEnumerable TestCases1 {
534+
get {
535+
// for now use this cowboy taken from the asset store as the test file
536+
// TODO: find a better/simpler test file
537+
yield return "Models/Cowboy/cowboyMidPoly(riged).fbx";
538+
}
539+
}
540+
public static System.Collections.IEnumerable TestCases2 {
541+
get {
542+
yield return "Models/SimpleMan/SimpleMan.fbx";
543+
}
544+
}
545+
}
546+
547+
[Test, TestCaseSource(typeof(SkinnedMeshTestDataClass), "TestCases1")]
548+
public void TestSkinnedMeshExport(string fbxPath){
549+
fbxPath = FindPathInUnitTests (fbxPath);
550+
Assert.That (fbxPath, Is.Not.Null);
536551

537552
SkinnedMeshRenderer originalSkinnedMesh, exportedSkinnedMesh;
538553
ExportSkinnedMesh (fbxPath, out originalSkinnedMesh, out exportedSkinnedMesh);
@@ -600,10 +615,10 @@ public void TestSkinnedMeshExport(){
600615
Assert.IsNotNull (expWeights);
601616
}
602617

603-
[Test]
604-
public void TestBoneWeightExport()
605-
{
606-
var fbxPath = "FbxExporters/Editor/UnitTests/Models/SimpleMan/SimpleMan.fbx";
618+
[Test, TestCaseSource(typeof(SkinnedMeshTestDataClass), "TestCases2")]
619+
public void TestBoneWeightExport(string fbxPath){
620+
fbxPath = FindPathInUnitTests (fbxPath);
621+
Assert.That (fbxPath, Is.Not.Null);
607622

608623
SkinnedMeshRenderer originalSkinnedMesh, exportedSkinnedMesh;
609624
ExportSkinnedMesh (fbxPath, out originalSkinnedMesh, out exportedSkinnedMesh);

Assets/FbxExporters/Editor/UnitTests/Models/SimpleMan/SimpleMan.fbx.meta

Lines changed: 260 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)