Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround Awaitable.Awaiter bug #138

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading