diff --git a/Tests/Runtime/AutopilotTest.cs b/Tests/Runtime/AutopilotTest.cs index 53c826a..1aebd55 100644 --- a/Tests/Runtime/AutopilotTest.cs +++ b/Tests/Runtime/AutopilotTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2023-2024 DeNA Co., Ltd. +// Copyright (c) 2023-2025 DeNA Co., Ltd. // This software is released under the MIT License. using System.Collections.Generic; @@ -195,9 +195,13 @@ public async Task Start_MappedSceneIsNotActiveButLoaded_DispatchAgent() const string MappedScenePath = TestScenePath; const string ActiveScenePath = TestScenePath2; + await SceneManagerHelper.LoadSceneAsync(ActiveScenePath); + await SceneManagerHelper.LoadSceneAsync(MappedScenePath, LoadSceneMode.Additive); + // Note: Workaround for destroy ScriptableObject after await twice bug. + Assume.That(SceneManager.GetActiveScene().path, Is.EqualTo(ActiveScenePath), "Mapped scene is not active"); + var spyMappedAgent = ScriptableObject.CreateInstance(); var spyFallbackAgent = ScriptableObject.CreateInstance(); - var autopilotSettings = ScriptableObject.CreateInstance(); autopilotSettings.sceneAgentMaps = new List { @@ -206,10 +210,6 @@ public async Task Start_MappedSceneIsNotActiveButLoaded_DispatchAgent() autopilotSettings.fallbackAgent = spyFallbackAgent; autopilotSettings.lifespanSec = 1; - await SceneManagerHelper.LoadSceneAsync(ActiveScenePath); - await SceneManagerHelper.LoadSceneAsync(MappedScenePath, LoadSceneMode.Additive); - Assume.That(SceneManager.GetActiveScene().path, Is.EqualTo(ActiveScenePath), "Mapped scene is not active"); - await Launcher.LaunchAutopilotAsync(autopilotSettings); Assert.That(spyMappedAgent.CompleteCount, Is.EqualTo(1), "Mapped Agent dispatched"); @@ -224,15 +224,15 @@ public async Task Start_NoMappedSceneInLoadedScenes_DispatchFallbackAgent() const string AdditiveScenePath = TestScenePath; const string ActiveScenePath = TestScenePath2; - var spyFallbackAgent = ScriptableObject.CreateInstance(); + await SceneManagerHelper.LoadSceneAsync(ActiveScenePath); + await SceneManagerHelper.LoadSceneAsync(AdditiveScenePath, LoadSceneMode.Additive); + // Note: Workaround for destroy ScriptableObject after await twice bug. + var spyFallbackAgent = ScriptableObject.CreateInstance(); var autopilotSettings = ScriptableObject.CreateInstance(); autopilotSettings.fallbackAgent = spyFallbackAgent; autopilotSettings.lifespanSec = 1; - await SceneManagerHelper.LoadSceneAsync(ActiveScenePath); - await SceneManagerHelper.LoadSceneAsync(AdditiveScenePath, LoadSceneMode.Additive); - await Launcher.LaunchAutopilotAsync(autopilotSettings); Assert.That(spyFallbackAgent.CompleteCount, Is.EqualTo(1));