-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from nowsprinting/feature/launch_from_test
Support launch autopilot from Play Mode tests
- Loading branch information
Showing
18 changed files
with
278 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023-2024 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
namespace DeNA.Anjin | ||
{ | ||
/// <summary> | ||
/// Exit code for autopilot running | ||
/// </summary> | ||
public enum ExitCode | ||
{ | ||
/// <summary> | ||
/// Normally exit | ||
/// </summary> | ||
Normally = 0, | ||
|
||
/// <summary> | ||
/// Exit by un catch Exceptions | ||
/// </summary> | ||
UnCatchExceptions = 1, | ||
|
||
/// <summary> | ||
/// Exit by fault in log message | ||
/// </summary> | ||
AutopilotFailed = 2 | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2023-2024 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
namespace DeNA.Anjin | ||
{ | ||
/// <summary> | ||
/// Define of what autopilot was launched by | ||
/// </summary> | ||
public enum LaunchType | ||
{ | ||
/// <summary> | ||
/// Not launch yet | ||
/// </summary> | ||
NotSet = 0, | ||
|
||
/// <summary> | ||
/// Launch via Edit mode | ||
/// </summary> | ||
EditorEditMode, | ||
|
||
/// <summary> | ||
/// Launch via Play mode | ||
/// </summary> | ||
EditorPlayMode, | ||
|
||
/// <summary> | ||
/// Launch via Play mode tests | ||
/// </summary> | ||
PlayModeTests, | ||
|
||
/// <summary> | ||
/// Launch from commandline interface | ||
/// When autopilot is finished, Unity editor is also exit. | ||
/// </summary> | ||
Commandline, | ||
|
||
/// <summary> | ||
/// Launch on standalone platform player build (not support yet) | ||
/// </summary> | ||
Runtime, | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2023-2024 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
using Cysharp.Threading.Tasks; | ||
using DeNA.Anjin.Settings; | ||
using NUnit.Framework; | ||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
#endif | ||
|
||
namespace DeNA.Anjin | ||
{ | ||
/// <summary> | ||
/// Launch from Play Mode test interface. | ||
/// </summary> | ||
public static class LauncherFromTest | ||
{ | ||
/// <summary> | ||
/// Run autopilot from Play Mode test. | ||
/// If an error is detected in running, it will be output to `LogError` and the test will fail. | ||
/// </summary> | ||
/// <param name="settings">Autopilot settings</param> | ||
public static async UniTask AutopilotAsync(AutopilotSettings settings) | ||
{ | ||
#if UNITY_EDITOR | ||
if (!EditorApplication.isPlaying) | ||
{ | ||
throw new AssertionException("Not support run on Edit Mode tests"); | ||
} | ||
#endif | ||
var state = AutopilotState.Instance; | ||
if (state.IsRunning) | ||
{ | ||
throw new AssertionException("Autopilot is already running"); | ||
} | ||
|
||
state.launchFrom = LaunchType.PlayModeTests; | ||
state.settings = settings; | ||
Launcher.Run(); | ||
|
||
await UniTask.WaitUntil(() => !state.IsRunning); | ||
} | ||
|
||
/// <summary> | ||
/// Run autopilot from Play Mode test. | ||
/// If an error is detected in running, it will be output to `LogError` and the test will fail. | ||
/// </summary> | ||
/// <param name="autopilotSettingsPath">Asset file path for autopilot settings</param> | ||
public static async UniTask AutopilotAsync(string autopilotSettingsPath) | ||
{ | ||
var settings = AssetDatabase.LoadAssetAtPath<AutopilotSettings>(autopilotSettingsPath); | ||
await AutopilotAsync(settings); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.