Skip to content

Commit 3851744

Browse files
committed
Fix of the unit tests, taking into account the Auto Updater toggle.
1 parent e85e92f commit 3851744

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,18 @@ public static void UpdateLinkedPrefab(GameObject prefabInstance)
237237
// Launch the manual update UI to allow the user to fix
238238
// renamed nodes (or auto-update if there's nothing to rename).
239239
var fbxPrefabUtility = new FbxPrefabUtility(fbxPrefabComponent);
240-
ManualUpdateEditorWindow window = (ManualUpdateEditorWindow)EditorWindow.GetWindow(typeof(ManualUpdateEditorWindow));
241-
window.Init(fbxPrefabUtility, fbxPrefabComponent);
242-
window.Show();
240+
241+
if (FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled || runningUnitTest)
242+
{
243+
fbxPrefabUtility.SyncPrefab();
244+
}
245+
else
246+
{
247+
ManualUpdateEditorWindow window = (ManualUpdateEditorWindow)EditorWindow.GetWindow(typeof(ManualUpdateEditorWindow));
248+
window.Init(fbxPrefabUtility, fbxPrefabComponent);
249+
window.Show();
250+
}
251+
243252
}
244253
}
245254

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace FbxExporters.UnitTests
99
{
1010
public abstract class ExporterTestBase
1111
{
12+
bool isAutoUpdaterOn;
1213
/// <summary>
1314
/// Sleep an amount of time (in ms) so we can safely assume that the
1415
/// timestamp on an fbx will change.
@@ -202,6 +203,20 @@ public virtual void Term ()
202203
EditorApplication.update += DeleteOnNextUpdate;
203204
}
204205

206+
[SetUp]
207+
public virtual void InitializeAutoUpdater()
208+
{
209+
isAutoUpdaterOn = FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled;
210+
FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled = true;
211+
}
212+
213+
[TearDown]
214+
public virtual void ResetAutoUpdater()
215+
{
216+
// Put back the initial setting for the auto-updater toggle
217+
FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled = isAutoUpdaterOn;
218+
}
219+
205220
/// <summary>
206221
/// Exports the Objects in selected.
207222
/// </summary>

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,6 @@ public void TestNameMapping()
175175

176176
public class FbxPrefabAutoUpdaterRemappingTest : ExporterTestBase
177177
{
178-
bool isAutoUpdaterOn;
179-
[SetUp]
180-
public void Init()
181-
{
182-
isAutoUpdaterOn = FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled;
183-
FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled = true;
184-
}
185-
186178
[Test]
187179
public void RemappingTest()
188180
{
@@ -228,11 +220,6 @@ public void RemappingTest()
228220
Assert.IsTrue(cubePrefabInstance.transform.GetChild(0).name == "SphereFBX");
229221
Assert.IsTrue(cubePrefabInstance.transform.GetChild(0).GetComponent<MeshFilter>().sharedMesh != null);
230222
}
231-
[TearDown]
232-
public void stopTest()
233-
{
234-
FbxExporters.EditorTools.ExportSettings.instance.autoUpdaterEnabled = isAutoUpdaterOn;
235-
}
236223
}
237224

238225
public class FbxPrefabAutoUpdaterToggleTest : ExporterTestBase

0 commit comments

Comments
 (0)