Singularity/Library/PackageCache/com.unity.test-framework@1..../UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs
2024-05-06 11:45:45 -07:00

38 lines
1.0 KiB
C#

using NUnit.Framework.Interfaces;
using UnityEngine;
using UnityEngine.TestTools.TestRunner;
namespace UnityEditor.TestTools.TestRunner
{
internal class TestRunnerCallback : ScriptableObject, ITestRunnerListener
{
public void RunStarted(ITest testsToRun)
{
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
private void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingPlayMode)
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
//We need to make sure we don't block NUnit thread in case we exit PlayMode earlier
PlaymodeTestsController.TryCleanup();
}
}
public void RunFinished(ITestResult testResults)
{
EditorApplication.isPlaying = false;
}
public void TestStarted(ITest testName)
{
}
public void TestFinished(ITestResult test)
{
}
}
}