Skip to content

Commit d44e76b

Browse files
committed
fix broken unit tests
1 parent b9a8a19 commit d44e76b

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ protected override void OnEnable ()
3737
if (!m_innerEditor) {
3838
var ms = ExportSettings.instance.convertToPrefabSettings;
3939
if (!ms) {
40-
ExportSettings.LoadSettings ();
4140
ms = ExportSettings.instance.convertToPrefabSettings;
4241
}
4342
m_innerEditor = UnityEditor.Editor.CreateEditor (ms);

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ protected override void OnEnable ()
277277
if (!m_innerEditor) {
278278
var ms = ExportSettings.instance.exportModelSettings;
279279
if (!ms) {
280-
ExportSettings.LoadSettings ();
281280
ms = ExportSettings.instance.exportModelSettings;
282281
}
283282
m_innerEditor = UnityEditor.Editor.CreateEditor (ms);

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,16 +1010,16 @@ public static string GetAbsoluteSavePath(string relativePath){
10101010
}
10111011

10121012
public static string GetFbxAbsoluteSavePath(){
1013-
/*if (instance.fbxSavePaths.Count <= 0) {
1013+
if (instance.fbxSavePaths.Count <= 0) {
10141014
instance.fbxSavePaths.Add (kDefaultSavePath);
1015-
}*/
1015+
}
10161016
return GetAbsoluteSavePath (instance.fbxSavePaths [instance.selectedFbxPath]);
10171017
}
10181018

10191019
public static string GetPrefabAbsoluteSavePath(){
1020-
/*if (instance.prefabSavePaths.Count <= 0) {
1020+
if (instance.prefabSavePaths.Count <= 0) {
10211021
instance.prefabSavePaths.Add (kDefaultSavePath);
1022-
}*/
1022+
}
10231023
return GetAbsoluteSavePath (instance.prefabSavePaths [instance.selectedPrefabPath]);
10241024
}
10251025

@@ -1203,11 +1203,12 @@ static void ShowManager()
12031203
{
12041204
instance.name = "Fbx Export Settings";
12051205
Selection.activeObject = instance;
1206-
LoadSettings ();
1206+
instance.Load();
12071207
}
12081208

1209-
public static void LoadSettings(){
1210-
instance.Load();
1209+
protected override void Load ()
1210+
{
1211+
base.Load ();
12111212
if (!instance.exportModelSettings) {
12121213
instance.exportModelSettings = ScriptableObject.CreateInstance (typeof(ExportModelSettings)) as ExportModelSettings;
12131214
}
@@ -1217,6 +1218,7 @@ public static void LoadSettings(){
12171218
instance.convertToPrefabSettings = ScriptableObject.CreateInstance (typeof(ConvertToPrefabSettings)) as ConvertToPrefabSettings;
12181219
}
12191220
instance.convertToPrefabSettings.info = instance.convertToPrefabSettingsSerialize;
1221+
12201222
}
12211223

12221224
public void Save()

Assets/FbxExporters/Editor/UnitTests/ConvertToModelTest.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void BasicTest()
122122

123123
// Convert it to a prefab -- but keep the cube.
124124
var cubePrefabInstance = ConvertToModel.Convert(cube,
125-
fbxDirectoryFullPath: path);
125+
fbxDirectoryFullPath: path, prefabDirectoryFullPath: path);
126126

127127
// Make sure it's what we expect.
128128
Assert.That(cube); // we kept the original
@@ -155,7 +155,7 @@ public void BasicTest()
155155
// Convert it again, make sure there's only one FbxPrefab (see UNI-25528).
156156
// Also make sure we deleted.
157157
var cubePrefabInstance2 = ConvertToModel.Convert(cubePrefabInstance,
158-
fbxDirectoryFullPath: path);
158+
fbxDirectoryFullPath: path, prefabDirectoryFullPath: path);
159159
Assert.That(cubePrefabInstance2.GetComponents<FbxPrefab>().Length, Is.EqualTo(1));
160160
}
161161

@@ -176,7 +176,8 @@ public void SkinnedMeshTest()
176176
Object.DestroyImmediate(meshFilter);
177177

178178
// Convert it.
179-
var cubeInstance = ConvertToModel.Convert(cube, fbxFullPath: GetRandomFbxFilePath());
179+
var file = GetRandomFbxFilePath();
180+
var cubeInstance = ConvertToModel.Convert(cube, fbxFullPath: file, prefabFullPath: Path.ChangeExtension(file, ".prefab"));
180181

181182
// Make sure it doesn't have a skinned mesh renderer on it.
182183
// In the future we'll want to assert the opposite!
@@ -248,7 +249,7 @@ public void TestInstanceNameMatchesFilename()
248249

249250
// Convert it to a prefab -- but keep the cube.
250251
var cubePrefabInstance = ConvertToModel.Convert(cube,
251-
fbxFullPath: path);
252+
fbxFullPath: path, prefabFullPath: Path.ChangeExtension(path, ".prefab"));
252253

253254
Assert.That (cube);
254255
Assert.That (cubePrefabInstance);

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void RectTransformTest ()
8484
string filePath1 = GetRandomFbxFilePath ();
8585

8686
//instantiate our hierarchy as a prefab
87-
var oldInstance = ConvertToModel.Convert (cube, fbxFullPath: filePath1);
87+
var oldInstance = ConvertToModel.Convert (cube, fbxFullPath: filePath1, prefabFullPath: Path.ChangeExtension(filePath1, ".prefab"));
8888
Assert.IsTrue (oldInstance);
8989

9090
rectTransform = oldInstance.transform.GetChild (0).GetComponent<RectTransform> ();
@@ -154,7 +154,7 @@ public void TestNameMapping()
154154
string filePath = GetRandomFbxFilePath();
155155

156156
// Convert to linked prefab instance (auto-updating prefab)
157-
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath);
157+
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath, prefabFullPath: Path.ChangeExtension(filePath, ".prefab"));
158158

159159
// In FbxPrefab Component of Cube, add SphereFBX/Sphere name mapping
160160
FbxPrefab fbxPrefabScript = cubePrefabInstance.transform.GetComponent<FbxPrefab>();
@@ -189,7 +189,7 @@ public void RemappingTest()
189189
string filePath = GetRandomFbxFilePath();
190190

191191
// Convert to linked prefab instance (auto-updating prefab)
192-
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath);
192+
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath, prefabFullPath: Path.ChangeExtension(filePath, ".prefab"));
193193
Object cubePrefabParent = PrefabUtility.GetPrefabParent(cubePrefabInstance);
194194

195195
// In FbxPrefab Component of Cube, add SphereFBX/Sphere name mapping
@@ -249,7 +249,7 @@ public void RemappingTest()
249249
string filePath = GetRandomFbxFilePath();
250250

251251
// Convert to linked prefab instance (auto-updating prefab)
252-
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath);
252+
GameObject cubePrefabInstance = ConvertToModel.Convert(cube, fbxFullPath: filePath, prefabFullPath: Path.ChangeExtension(filePath, ".prefab"));
253253
Object cubePrefabParent = PrefabUtility.GetPrefabParent(cubePrefabInstance);
254254

255255
// In FbxPrefab Component of Cube, add SphereFBX/Sphere name mapping
@@ -310,7 +310,7 @@ public void RemappingTest()
310310
GameObject cylinder3 = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
311311
GameObject sphere3 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
312312
sphere3.transform.SetParent(cylinder3.transform);
313-
GameObject sphere3Instance = ConvertToModel.Convert(sphere3, fbxFullPath: filePath);
313+
GameObject sphere3Instance = ConvertToModel.Convert(sphere3, fbxFullPath: filePath, prefabFullPath: Path.ChangeExtension(filePath, ".prefab"));
314314
Selection.objects = new GameObject[] { sphere3Instance };
315315
Assert.IsTrue(FbxPrefabAutoUpdater.OnValidateMenuItem());
316316

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public void TestCubeAtRoot()
362362
cube.name = "Cube";
363363
var cubeAssetPath = GetRandomFbxFilePath();
364364
var autoPrefab = ConvertToModel.Convert(cube,
365-
fbxFullPath: cubeAssetPath);
365+
fbxFullPath: cubeAssetPath, prefabFullPath: System.IO.Path.ChangeExtension(cubeAssetPath, ".prefab"));
366366
Assert.IsTrue(autoPrefab);
367367

368368
// Make a maya locator.
@@ -415,8 +415,9 @@ public void TestTransformAndReparenting()
415415
building3.transform.parent = building2.transform;
416416
building3.transform.localScale = new Vector3(.5f, .5f, .5f);
417417

418+
var filePath = GetRandomFbxFilePath ();
418419
var original = ConvertToModel.Convert (root,
419-
fbxFullPath: GetRandomFbxFilePath ());
420+
fbxFullPath: filePath, prefabFullPath: System.IO.Path.ChangeExtension(filePath, ".prefab"));
420421

421422
// Make sure it's OK.
422423
Assert.That (original.transform.GetChild (0).name, Is.EqualTo ("building2"));
@@ -460,7 +461,7 @@ public void TestFbxPrefabNotAtRoot()
460461
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
461462
var cubeMesh = cube.GetComponent<MeshFilter>().sharedMesh;
462463
var cubePath = GetRandomFbxFilePath();
463-
var cubeInstance = ConvertToModel.Convert(cube, fbxFullPath: cubePath);
464+
var cubeInstance = ConvertToModel.Convert(cube, fbxFullPath: cubePath, prefabFullPath: System.IO.Path.ChangeExtension(cubePath, ".prefab"));
464465
var cubeName = cubeInstance.name;
465466

466467
// Create a prefab that has the cube as a child.

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ public void LODExportTest(){
808808
// expected LODs exported: Sphere_LOD0, Capsule_LOD0, Cube_LOD2
809809
// NOTE: Cylinder_LOD1 is not exported as it is not under the LODGroup hierarchy being exported
810810
filename = GetRandomFbxFilePath();
811-
var convertedHierarchy = ConvertToModel.Convert(lodGroup, fbxFullPath: filename);
811+
var convertedHierarchy = ConvertToModel.Convert(lodGroup, fbxFullPath: filename, prefabFullPath: System.IO.Path.ChangeExtension(filename, ".prefab"));
812812
Assert.That (convertedHierarchy, Is.Not.Null);
813813

814814
// check both converted hierarchy and fbx

0 commit comments

Comments
 (0)