Skip to content

Commit

Permalink
Merge pull request #138 from nowsprinting/chore/workaround_awaiter
Browse files Browse the repository at this point in the history
Workaround Awaitable.Awaiter bug
  • Loading branch information
bo40 authored Jan 9, 2025
2 parents 3a7236f + 415d488 commit b91d362
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Tests/Runtime/AutopilotTest.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<SpyAgent>();
var spyFallbackAgent = ScriptableObject.CreateInstance<SpyAgent>();

var autopilotSettings = ScriptableObject.CreateInstance<AutopilotSettings>();
autopilotSettings.sceneAgentMaps = new List<SceneAgentMap>
{
Expand All @@ -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");
Expand All @@ -224,15 +224,15 @@ public async Task Start_NoMappedSceneInLoadedScenes_DispatchFallbackAgent()
const string AdditiveScenePath = TestScenePath;
const string ActiveScenePath = TestScenePath2;

var spyFallbackAgent = ScriptableObject.CreateInstance<SpyAgent>();
await SceneManagerHelper.LoadSceneAsync(ActiveScenePath);
await SceneManagerHelper.LoadSceneAsync(AdditiveScenePath, LoadSceneMode.Additive);
// Note: Workaround for destroy ScriptableObject after await twice bug.

var spyFallbackAgent = ScriptableObject.CreateInstance<SpyAgent>();
var autopilotSettings = ScriptableObject.CreateInstance<AutopilotSettings>();
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));
Expand Down

0 comments on commit b91d362

Please sign in to comment.