first commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools.Logging;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal abstract class BuildActionTaskBase<T> : TestTaskBase
|
||||
{
|
||||
private string typeName;
|
||||
internal IAttributeFinder attributeFinder;
|
||||
internal Action<string> logAction = Debug.Log;
|
||||
internal Func<ILogScope> logScopeProvider = () => new LogScope();
|
||||
internal Func<Type, object> createInstance = Activator.CreateInstance;
|
||||
|
||||
protected BuildActionTaskBase(IAttributeFinder attributeFinder)
|
||||
{
|
||||
this.attributeFinder = attributeFinder;
|
||||
typeName = typeof(T).Name;
|
||||
}
|
||||
|
||||
protected abstract void Action(T target);
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.testTree == null)
|
||||
{
|
||||
throw new Exception($"Test tree is not available for {GetType().Name}.");
|
||||
}
|
||||
|
||||
var enumerator = ExecuteMethods(testJobData.testTree, testJobData.testFilter, testJobData.TargetRuntimePlatform ?? Application.platform);
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ExecuteMethods(ITest testTree, ITestFilter testRunnerFilter, RuntimePlatform targetPlatform)
|
||||
{
|
||||
var exceptions = new List<Exception>();
|
||||
|
||||
foreach (var targetClassType in attributeFinder.Search(testTree, testRunnerFilter, targetPlatform))
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetClass = (T)createInstance(targetClassType);
|
||||
|
||||
logAction($"Executing {typeName} for: {targetClassType.FullName}.");
|
||||
|
||||
using (var logScope = logScopeProvider())
|
||||
{
|
||||
Action(targetClass);
|
||||
logScope.EvaluateLogScope(true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions.Count > 0)
|
||||
{
|
||||
throw new AggregateException($"One or more exceptions when executing {typeName}.", exceptions);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2441d353f9c42a44af6e224e4901b52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal.Filters;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class BuildNUnitFilterTask : TestTaskBase
|
||||
{
|
||||
public BuildNUnitFilterTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var executionSettings = testJobData.executionSettings;
|
||||
ITestFilter filter = new OrFilter(executionSettings.filters.Select(f => f.ToRuntimeTestRunnerFilter(executionSettings.runSynchronously).BuildNUnitFilter()).ToArray());
|
||||
|
||||
testJobData.testFilter = filter;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5640d0c51961421997c9f36f0ec45480
|
||||
timeCreated: 1594728627
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.TestTools.NUnitExtensions;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class BuildTestTreeTask : TestTaskBase
|
||||
{
|
||||
private TestPlatform m_TestPlatform;
|
||||
|
||||
public BuildTestTreeTask(TestPlatform testPlatform)
|
||||
{
|
||||
m_TestPlatform = testPlatform;
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
internal IEditorLoadedTestAssemblyProvider m_testAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());
|
||||
internal Func<string[], int, IAsyncTestAssemblyBuilder> m_testAssemblyBuilderFactory = (orderedTestNames, seed) => new UnityTestAssemblyBuilder(orderedTestNames, seed);
|
||||
internal ICallbacksDelegator m_CallbacksDelegator = CallbacksDelegator.instance;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.testTree != null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var assembliesEnumerator = m_testAssemblyProvider.GetAssembliesGroupedByTypeAsync(m_TestPlatform);
|
||||
while (assembliesEnumerator.MoveNext())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (assembliesEnumerator.Current == null)
|
||||
{
|
||||
throw new Exception("Assemblies not retrieved.");
|
||||
}
|
||||
|
||||
var assemblies = assembliesEnumerator.Current.Where(pair => m_TestPlatform.IsFlagIncluded(pair.Key)).SelectMany(pair => pair.Value).Select(x => x.Assembly).ToArray();
|
||||
var buildSettings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(m_TestPlatform);
|
||||
var testAssemblyBuilder = m_testAssemblyBuilderFactory(testJobData.executionSettings.orderedTestNames, testJobData.executionSettings.randomOrderSeed);
|
||||
var enumerator = testAssemblyBuilder.BuildAsync(assemblies, Enumerable.Repeat(m_TestPlatform, assemblies.Length).ToArray(), buildSettings);
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
var testList = enumerator.Current;
|
||||
if (testList== null)
|
||||
{
|
||||
throw new Exception("Test list not retrieved.");
|
||||
}
|
||||
|
||||
testJobData.testTree = testList;
|
||||
m_CallbacksDelegator.TestTreeRebuild(testList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0288e1c9324e824bab7e2044a72a434
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class CleanUpContext : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.Context = null;
|
||||
TestContext.CurrentTestExecutionContext = null;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c97cd557b334b27bc325649466d1872
|
||||
timeCreated: 1669207857
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class CleanupConstructDelegatorTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.ConstructDelegator.DestroyCurrentTestObjectIfExists();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a155fee568ce42a4b561ee3a27d88532
|
||||
timeCreated: 1584451388
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class CleanupTestControllerTask : TestTaskBase
|
||||
{
|
||||
public CleanupTestControllerTask()
|
||||
{
|
||||
RunOnCancel = true;
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.PlaymodeTestsController == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
testJobData.PlaymodeTestsController.Cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 822fa0a65be2467b95721422157c93f0
|
||||
timeCreated: 1695389918
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestRunner.NUnitExtensions.Runner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class CleanupVerificationTask : FileCleanupVerifierTaskBase
|
||||
{
|
||||
private const string k_Indent = " ";
|
||||
|
||||
internal Action<object> logWarning = Debug.LogWarning;
|
||||
internal Action<object> logError = Debug.LogError;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var currentFiles = GetAllFilesInAssetsDirectory();
|
||||
var existingFiles = testJobData.existingFiles;
|
||||
|
||||
if (currentFiles.Length != existingFiles.Length)
|
||||
{
|
||||
var existingFilesHashSet = new HashSet<string>(existingFiles);
|
||||
var newFiles = currentFiles.Where(file => !existingFilesHashSet.Contains(file)).ToArray();
|
||||
LogWarningForFilesIfAny(newFiles, testJobData.executionSettings.featureFlags.fileCleanUpCheck);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
private void LogWarningForFilesIfAny(string[] filePaths, bool fileCleanUpCheck)
|
||||
{
|
||||
if (filePaths.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var stringWriter = new StringWriter();
|
||||
stringWriter.WriteLine("Files generated by test without cleanup.");
|
||||
stringWriter.WriteLine(k_Indent + "Found {0} new files.", filePaths.Length);
|
||||
|
||||
foreach (var filePath in filePaths)
|
||||
{
|
||||
stringWriter.WriteLine(k_Indent + filePath);
|
||||
}
|
||||
|
||||
if (fileCleanUpCheck)
|
||||
{
|
||||
logError(stringWriter.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
logWarning(stringWriter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93eb6389f4fb6924987867ce0bc339ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class CreateBootstrapSceneTask : TestTaskBase
|
||||
{
|
||||
private bool m_includeTestController;
|
||||
private bool m_saveScene;
|
||||
private NewSceneSetup m_SceneSetup;
|
||||
|
||||
public CreateBootstrapSceneTask(bool mIncludeTestController, bool saveScene, NewSceneSetup sceneSetup)
|
||||
{
|
||||
m_includeTestController = mIncludeTestController;
|
||||
m_saveScene = saveScene;
|
||||
m_SceneSetup = sceneSetup;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (m_saveScene)
|
||||
{
|
||||
testJobData.InitTestScenePath = "Assets/InitTestScene" + Guid.NewGuid() + ".unity";
|
||||
}
|
||||
|
||||
testJobData.InitTestScene = EditorSceneManager.NewScene(m_SceneSetup, NewSceneMode.Single);
|
||||
|
||||
/* This code from 2.0 is likely not needed and can be removed once backporting has finished.
|
||||
while (PlaymodeTestsController.IsControllerOnScene())
|
||||
{
|
||||
var gameObject = PlaymodeTestsController.GetController().gameObject;
|
||||
Object.DestroyImmediate(gameObject);
|
||||
}
|
||||
*/
|
||||
|
||||
var settings = PlaymodeTestsControllerSettings.CreateRunnerSettings(testJobData.executionSettings.filters
|
||||
.Select(filter => filter.ToRuntimeTestRunnerFilter(testJobData.executionSettings.runSynchronously)).ToArray(), testJobData.executionSettings.orderedTestNames,
|
||||
testJobData.executionSettings.randomOrderSeed, testJobData.executionSettings.featureFlags, testJobData.executionSettings.retryCount, testJobData.executionSettings.repeatCount, IsAutomated());
|
||||
|
||||
if (m_includeTestController)
|
||||
{
|
||||
var go = new GameObject(PlaymodeTestsController.kPlaymodeTestControllerName);
|
||||
|
||||
var editorLoadedTestAssemblyProvider =
|
||||
new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(),
|
||||
new EditorAssembliesProxy());
|
||||
|
||||
var runner = go.AddComponent<PlaymodeTestsController>();
|
||||
runner.AssembliesWithTests = editorLoadedTestAssemblyProvider
|
||||
.GetAssembliesGroupedByType(TestPlatform.PlayMode).Select(x => x.Assembly.GetName().Name)
|
||||
.ToList();
|
||||
runner.settings = settings;
|
||||
testJobData.PlaymodeTestsController = runner;
|
||||
}
|
||||
|
||||
testJobData.PlayModeSettings = settings;
|
||||
|
||||
if (m_saveScene)
|
||||
{
|
||||
EditorSceneManager.MarkSceneDirty(testJobData.InitTestScene);
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorSceneManager.SaveScene(testJobData.InitTestScene, testJobData.InitTestScenePath, false);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4400cdda235b4ea48b9078953ffc8e89
|
||||
timeCreated: 1695384344
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class DeleteBootstrapSceneTask : TestTaskBase
|
||||
{
|
||||
public DeleteBootstrapSceneTask()
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
RunOnCancel = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(testJobData.InitTestScenePath))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
AssetDatabase.DeleteAsset(testJobData.InitTestScenePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6465fa5b49fc4c739059189aca21f391
|
||||
timeCreated: 1695390255
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class EditModeRunTask : TestTaskBase
|
||||
{
|
||||
public EditModeRunTask()
|
||||
{
|
||||
SupportsResumingEnumerator = true;
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Canceled)
|
||||
{
|
||||
var runner = testJobData.editModeRunner;
|
||||
if (runner != null)
|
||||
{
|
||||
runner.OnRunCancel();
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
else if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Resume)
|
||||
{
|
||||
var runner = testJobData.editModeRunner;
|
||||
if (runner == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
runner.Resume(testJobData.executionSettings.BuildNUnitFilter(), testJobData.testTree, testJobData.TestStartedEvent, testJobData.TestFinishedEvent, testJobData.Context);
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return null; // Allow for setting the test job data after a resume.
|
||||
var editModeRunner = ScriptableObject.CreateInstance<EditModeRunner>();
|
||||
testJobData.editModeRunner = editModeRunner;
|
||||
|
||||
editModeRunner.UnityTestAssemblyRunnerFactory = new UnityTestAssemblyRunnerFactory();
|
||||
editModeRunner.Init(testJobData.executionSettings.BuildNUnitFilter(), testJobData.executionSettings.runSynchronously, testJobData.testTree, testJobData.TestStartedEvent,
|
||||
testJobData.TestFinishedEvent, testJobData.Context, testJobData.executionSettings.orderedTestNames, testJobData.executionSettings.randomOrderSeed, testJobData.executionSettings.featureFlags.disableNestedEnumeratorBugfix);
|
||||
|
||||
while (testJobData.editModeRunner != null && !testJobData.editModeRunner.RunFinished)
|
||||
{
|
||||
testJobData.editModeRunner.TestConsumer(testJobData.testRunnerStateSerializer);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
testJobData.TestResults = testJobData.editModeRunner.m_Runner.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4246555189b5ee43b4857220f9fd29b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor.TestTools.TestRunner.UnityTestProtocol;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class EnableTestOutLoggerTask : TestTaskBase, IDisposable
|
||||
{
|
||||
internal Action<Action<PlayModeStateChange>> SubscribePlayModeStateChanged = callback =>
|
||||
EditorApplication.playModeStateChanged += callback;
|
||||
internal Action<Action<PlayModeStateChange>> UnsubscribePlayModeStateChanged = callback =>
|
||||
EditorApplication.playModeStateChanged -= callback;
|
||||
internal Action<Application.LogCallback> SubscribeLogMessageReceivedThreaded =
|
||||
callback => Application.logMessageReceived += callback;
|
||||
internal Action<Application.LogCallback> UnsubscribeLogMessageReceivedThreaded =
|
||||
callback => Application.logMessageReceived -= callback;
|
||||
|
||||
internal Func<TextWriter> GetCurrentContextWriter = () => TestContext.Out;
|
||||
|
||||
public EnableTestOutLoggerTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
SubscribePlayModeStateChanged(WaitForExitPlaymode);
|
||||
SubscribeLogMessageReceivedThreaded(LogReceived);
|
||||
yield break;
|
||||
}
|
||||
|
||||
private void WaitForExitPlaymode(PlayModeStateChange state)
|
||||
{
|
||||
if (state == PlayModeStateChange.EnteredEditMode)
|
||||
{
|
||||
UnsubscribePlayModeStateChanged(WaitForExitPlaymode);
|
||||
UnsubscribeLogMessageReceivedThreaded(LogReceived);
|
||||
SubscribeLogMessageReceivedThreaded(LogReceived);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogReceived(string message, string stacktrace, LogType type)
|
||||
{
|
||||
if (message.StartsWith(UtpDebugLogger.UtpPrefix))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = GetCurrentContextWriter();
|
||||
if (writer != null)
|
||||
{
|
||||
writer.WriteLine(message);
|
||||
if (type == LogType.Exception)
|
||||
{
|
||||
writer.WriteLine(stacktrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnsubscribeLogMessageReceivedThreaded(LogReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a9f3fcee3bd2334593373b00d7b5ca2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class EnterPlayModeTask : TestTaskBase
|
||||
{
|
||||
public Func<bool> IsInPlayMode = () => Application.isPlaying;
|
||||
public Action EnterPlayMode = () => EditorApplication.isPlaying = true;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (IsInPlayMode())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Give the UI a change to update the progress bar, sa entering playmode freezes.
|
||||
yield return null;
|
||||
|
||||
EnterPlayMode();
|
||||
|
||||
while (!IsInPlayMode())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b45f42910304b00a63958173ee2c76f
|
||||
timeCreated: 1588855708
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cca5935142d6c754f9ecdce1294f7079
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class CreateEventsTask : TestTaskBase
|
||||
{
|
||||
public CreateEventsTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.RunStartedEvent = new RunStartedEvent();
|
||||
testJobData.TestStartedEvent = new TestStartedEvent();
|
||||
testJobData.TestFinishedEvent = new TestFinishedEvent();
|
||||
testJobData.RunFinishedEvent = new RunFinishedEvent();
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2675f346a0926b4aa7928805fd8bc9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class RegisterCallbackDelegatorEventsTask : TestTaskBase
|
||||
{
|
||||
public RegisterCallbackDelegatorEventsTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
internal ICallbacksDelegator ApiCallbacksDelegator = CallbacksDelegator.instance;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
ApiCallbacksDelegator.SetTestRunFilter(testJobData.executionSettings.BuildNUnitFilter());
|
||||
testJobData.RunStartedEvent.AddListener(ApiCallbacksDelegator.RunStarted);
|
||||
testJobData.TestStartedEvent.AddListener(ApiCallbacksDelegator.TestStarted);
|
||||
testJobData.TestFinishedEvent.AddListener(ApiCallbacksDelegator.TestFinished);
|
||||
testJobData.RunFinishedEvent.AddListener(ApiCallbacksDelegator.RunFinished);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 311d065aced2092409deadf0c0934f61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestRunner.Utils;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class RegisterTestRunCallbackEventsTask : TestTaskBase
|
||||
{
|
||||
public RegisterTestRunCallbackEventsTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
internal Func<TestRunCallbackListener> GetListener = () => ScriptableObject.CreateInstance<TestRunCallbackListener>();
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var listener = GetListener();
|
||||
testJobData.RunStartedEvent.AddListener(v => listener.RunStarted(v));
|
||||
testJobData.TestStartedEvent.AddListener(v => listener.TestStarted(v));
|
||||
testJobData.TestFinishedEvent.AddListener(v => listener.TestFinished(v));
|
||||
testJobData.RunFinishedEvent.AddListener(v => listener.RunFinished(v));
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9b3520efe42f4ee887f8b99b7e1deae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine.TestRunner.NUnitExtensions;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class RunFinishedInvocationEvent : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.TestResults == null)
|
||||
{
|
||||
// Temporary workaround to ensure that we do not loose the non serializable results due to a test leaking a domain reload.
|
||||
testJobData.TestResults = testJobData.editModeRunner.m_Runner.Result;
|
||||
}
|
||||
testJobData.editModeRunner.Dispose();
|
||||
|
||||
testJobData.RunFinishedEvent.Invoke(testJobData.TestResults);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8ea9765889ae054c9b32cce583af855
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class RunStartedInvocationEvent : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.testTree == null)
|
||||
{
|
||||
throw new Exception("TestTree must be set before run started event.");
|
||||
}
|
||||
testJobData.RunStartedEvent.Invoke(testJobData.testTree);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59267e29055f657429098a57e13debe1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
|
||||
{
|
||||
internal class UpdateTestProgressTask : TestTaskBase
|
||||
{
|
||||
private TestProgress m_TestProgress;
|
||||
|
||||
public UpdateTestProgressTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.testProgress == null)
|
||||
{
|
||||
throw new RequiredTestRunDataMissingException(nameof(testJobData.testProgress));
|
||||
}
|
||||
|
||||
if (testJobData.TestStartedEvent == null)
|
||||
{
|
||||
throw new RequiredTestRunDataMissingException(nameof(testJobData.TestStartedEvent));
|
||||
}
|
||||
|
||||
if (testJobData.TestFinishedEvent == null)
|
||||
{
|
||||
throw new RequiredTestRunDataMissingException(nameof(testJobData.TestFinishedEvent));
|
||||
}
|
||||
|
||||
m_TestProgress = testJobData.testProgress;
|
||||
testJobData.TestStartedEvent.AddListener(TestStarted);
|
||||
testJobData.TestFinishedEvent.AddListener(TestFinished);
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
private void TestStarted(ITest test)
|
||||
{
|
||||
if (test.IsSuite || !(test is TestMethod))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_TestProgress.CurrentTest = test.Name;
|
||||
}
|
||||
|
||||
private void TestFinished(ITestResult testResult)
|
||||
{
|
||||
if (testResult.Test.IsSuite)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var name = testResult.Test.FullName;
|
||||
m_TestProgress.RemainingTests.Remove(name);
|
||||
m_TestProgress.CompletedTests.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5c78f2ef0d32a948bbb93266ef69a6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class ExitPlayModeTask : TestTaskBase
|
||||
{
|
||||
public ExitPlayModeTask()
|
||||
{
|
||||
RunOnCancel = true;
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
}
|
||||
|
||||
public Func<bool> IsInPlayMode = () => Application.isPlaying;
|
||||
public Action ExitPlayMode = () => EditorApplication.isPlaying = false;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (!IsInPlayMode())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
ExitPlayMode();
|
||||
|
||||
while (IsInPlayMode())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5842bd968af34a328bb5a3f3c78db54a
|
||||
timeCreated: 1587459149
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal abstract class FileCleanupVerifierTaskBase : TestTaskBase
|
||||
{
|
||||
internal Func<string[]> GetAllAssetPathsAction = AssetDatabase.GetAllAssetPaths;
|
||||
|
||||
protected string[] GetAllFilesInAssetsDirectory()
|
||||
{
|
||||
return GetAllAssetPathsAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad7bb166069f8414e9ad26606b305e66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEditor.TestTools.TestRunner.UnityTestProtocol;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestRunner.NUnitExtensions.Runner;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class GenerateContextTask : TestTaskBase
|
||||
{
|
||||
public GenerateContextTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Normal)
|
||||
{
|
||||
testJobData.setUpTearDownState = new BeforeAfterTestCommandState();
|
||||
testJobData.outerUnityTestActionState = new BeforeAfterTestCommandState();
|
||||
testJobData.enumerableTestState = new EnumerableTestState();
|
||||
}
|
||||
|
||||
testJobData.Context = new UnityTestExecutionContext()
|
||||
{
|
||||
SetUpTearDownState = testJobData.setUpTearDownState,
|
||||
OuterUnityTestActionState = testJobData.outerUnityTestActionState,
|
||||
EnumerableTestState = testJobData.enumerableTestState,
|
||||
Automated = UnityTestProtocolStarter.IsEnabled(),
|
||||
RetryCount = testJobData.executionSettings.retryCount,
|
||||
RepeatCount = testJobData.executionSettings.repeatCount,
|
||||
RetryRepeatState = testJobData.RetryRepeatState
|
||||
};
|
||||
|
||||
if (testJobData.executionSettings.ignoreTests != null)
|
||||
{
|
||||
testJobData.Context.IgnoreTests = testJobData.executionSettings.ignoreTests.Select(ignoreTest => ignoreTest.ParseToEngine()).ToArray();
|
||||
}
|
||||
|
||||
testJobData.Context.FeatureFlags = testJobData.executionSettings.featureFlags;
|
||||
|
||||
UnityTestExecutionContext.CurrentContext = testJobData.Context;
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee6c7dc47e844c3d823b833abbd5f981
|
||||
timeCreated: 1669207714
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class InitializeTestProgressTask : TestTaskBase
|
||||
{
|
||||
public InitializeTestProgressTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.TestStartedEvent.AddListener(test => OnTestStarted(test, testJobData));
|
||||
testJobData.TestFinishedEvent.AddListener(test => OnTestFinished(test, testJobData));
|
||||
|
||||
if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Resume)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (testJobData.testTree == null)
|
||||
{
|
||||
throw new RequiredTestRunDataMissingException(nameof(testJobData.testTree));
|
||||
}
|
||||
|
||||
var allTests =
|
||||
GetTestsExpectedToRun(testJobData.testTree, testJobData.executionSettings.BuildNUnitFilter());
|
||||
testJobData.testProgress = new TestProgress(allTests.ToArray());
|
||||
var numTasks = testJobData.Tasks.Count();
|
||||
var numTests = testJobData.testProgress.AllTestsToRun.Length;
|
||||
var progressAvailableToTests = 1.0f - numTasks * RunProgress.progressPrTask;
|
||||
|
||||
if (numTests > 0)
|
||||
{
|
||||
testJobData.runProgress.progressPrTest = progressAvailableToTests / numTests;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTestStarted(ITest test, TestJobData data)
|
||||
{
|
||||
if (!test.IsSuite)
|
||||
{
|
||||
data.runProgress.stepName = test.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTestFinished(ITestResult result, TestJobData data)
|
||||
{
|
||||
if (!result.Test.IsSuite)
|
||||
{
|
||||
data.runProgress.progress += data.runProgress.progressPrTest;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> GetTestsExpectedToRun(ITest test, ITestFilter filter)
|
||||
{
|
||||
var expectedTests = new List<string>();
|
||||
|
||||
if (filter.Pass(test))
|
||||
{
|
||||
if (test.IsSuite)
|
||||
{
|
||||
expectedTests.AddRange(test.Tests.SelectMany(subTest => GetTestsExpectedToRun(subTest, filter)));
|
||||
}
|
||||
else
|
||||
{
|
||||
expectedTests.Add(test.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
return expectedTests;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83d2df796f82ab847a190a706f00d6eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEditor.TestRunner.TestLaunchers;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class LegacyPlayerRunTask : TestTaskBase
|
||||
{
|
||||
public LegacyPlayerRunTask()
|
||||
{
|
||||
SupportsResumingEnumerator = true;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return "Build Test Player";
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
yield return null; // Allow for setting the test job data after a resume.
|
||||
var executionSettings = testJobData.executionSettings;
|
||||
var launcher = new PlayerLauncher(testJobData.PlayModeSettings, executionSettings.targetPlatform, executionSettings.overloadTestRunSettings, executionSettings.playerHeartbeatTimeout, executionSettings.playerSavePath, testJobData.InitTestScenePath, testJobData.InitTestScene, testJobData.PlaymodeTestsController);
|
||||
launcher.Run();
|
||||
testJobData.PlayerBuildOptions = launcher.playerBuildOptions.BuildPlayerOptions; // This can be removed once the player build options are created in a separate task
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b93fe5bbea454ae438fcec241c5fa85b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class MarkRunAsPlayModeTask : TestTaskBase
|
||||
{
|
||||
public MarkRunAsPlayModeTask()
|
||||
{
|
||||
RerunAfterResume = true;
|
||||
}
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
// This is a workaround to raise the signal that Playmode Launcher is running.
|
||||
// It is used by the graphics test framework, as there is no api to provide that information yet.
|
||||
PlaymodeLauncher.IsRunning = true;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23383565f01f46dfa583710e5108e443
|
||||
timeCreated: 1705306484
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class PerformUndoTask : TestTaskBase
|
||||
{
|
||||
private const double warningThreshold = 1000;
|
||||
|
||||
internal Action<int> RevertAllDownToGroup = Undo.RevertAllDownToGroup;
|
||||
internal Action<string> LogWarning = Debug.LogWarning;
|
||||
internal Action<string, string, float> DisplayProgressBar = EditorUtility.DisplayProgressBar;
|
||||
internal Action ClearProgressBar = EditorUtility.ClearProgressBar;
|
||||
internal Func<DateTime> TimeNow = () => DateTime.Now;
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.undoGroup < 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
DisplayProgressBar("Undo", "Reverting changes to the scene", 0);
|
||||
|
||||
var undoStartTime = TimeNow();
|
||||
|
||||
RevertAllDownToGroup(testJobData.undoGroup);
|
||||
|
||||
var timeDelta = TimeNow() - undoStartTime;
|
||||
if (timeDelta.TotalMilliseconds >= warningThreshold)
|
||||
{
|
||||
LogWarning($"Undo after editor test run took {timeDelta.Seconds} second{(timeDelta.Seconds == 1 ? "" : "s")}.");
|
||||
}
|
||||
|
||||
ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb1abebffd37bd4458c84e15a5d7ab04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d973b7805df545bdae3986ab72a6c2e8
|
||||
timeCreated: 1695720017
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform
|
||||
{
|
||||
internal class PlatformSpecificCleanupTask : TestTaskBase
|
||||
{
|
||||
public PlatformSpecificCleanupTask()
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.PlatformSpecificSetup?.CleanUp();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f3326f97c0d472bac74dc480099f983
|
||||
timeCreated: 1695723368
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform
|
||||
{
|
||||
internal class PlatformSpecificPostBuildTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if ((testJobData.PlayerBuildOptions.options & BuildOptions.AutoRunPlayer) != 0)
|
||||
{
|
||||
testJobData.PlatformSpecificSetup.PostBuildAction();
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 646cce3bdb8d461d980d11d729ab3312
|
||||
timeCreated: 1695720480
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform
|
||||
{
|
||||
internal class PlatformSpecificSetupTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.executionSettings.targetPlatform == null)
|
||||
{
|
||||
throw new Exception($"{nameof(PlatformSpecificSetupTask)} can only run on a task with a target platform.");
|
||||
}
|
||||
|
||||
testJobData.PlatformSpecificSetup =
|
||||
new PlatformSpecificSetup(testJobData.executionSettings.targetPlatform.Value);
|
||||
testJobData.PlatformSpecificSetup.Setup();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49284fdc918b491aa9f4439e6cc59c9c
|
||||
timeCreated: 1695720223
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform
|
||||
{
|
||||
internal class PlatformSpecificSuccessfulBuildTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if ((testJobData.PlayerBuildOptions.options & BuildOptions.AutoRunPlayer) != 0)
|
||||
{
|
||||
testJobData.PlatformSpecificSetup.PostSuccessfulBuildAction();
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57e7d752d8e6494b9aca2f2724b98761
|
||||
timeCreated: 1695723269
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform
|
||||
{
|
||||
internal class PlatformSpecificSuccessfulLaunchTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if ((testJobData.PlayerBuildOptions.options & BuildOptions.AutoRunPlayer) != 0)
|
||||
{
|
||||
testJobData.PlatformSpecificSetup.PostSuccessfulLaunchAction();
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31d26a10516a4ac7a9bfdcac13a6386e
|
||||
timeCreated: 1695723321
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestRunner.NUnitExtensions.Runner;
|
||||
using UnityEngine.TestTools.TestRunner;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class PlayModeRunTask : TestTaskBase
|
||||
{
|
||||
public PlayModeRunTask()
|
||||
{
|
||||
SupportsResumingEnumerator = true;
|
||||
}
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
yield return null; // Allow for setting the test job data after a resume.
|
||||
|
||||
// Saving of the scene causes serialization of the runner, so the events needs to be resubscribed. This is temporary for now.
|
||||
// Wait for the active controller
|
||||
while (PlaymodeTestsController.ActiveController == null)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
var controller = PlaymodeTestsController.ActiveController;
|
||||
|
||||
if (controller.m_Runner != null && controller.m_Runner.IsTestComplete)
|
||||
{
|
||||
//Already finished, likely zero tests.
|
||||
testJobData.RunStartedEvent.Invoke(controller.m_Runner.LoadedTest);
|
||||
testJobData.RunFinishedEvent.Invoke(controller.m_Runner.Result);
|
||||
yield break;
|
||||
}
|
||||
|
||||
controller.runStartedEvent.AddListener(testJobData.RunStartedEvent.Invoke);
|
||||
controller.testStartedEvent.AddListener(testJobData.TestStartedEvent.Invoke);
|
||||
controller.testFinishedEvent.AddListener(testJobData.TestFinishedEvent.Invoke);
|
||||
controller.runFinishedEvent.AddListener(testJobData.RunFinishedEvent.Invoke);
|
||||
|
||||
controller.RunInfrastructureHasRegistered = true;
|
||||
|
||||
var runDone = false;
|
||||
controller.runFinishedEvent.AddListener((_) =>
|
||||
{
|
||||
runDone = true;
|
||||
});
|
||||
|
||||
while (!runDone)
|
||||
{
|
||||
if (controller.RaisedException != null)
|
||||
{
|
||||
throw controller.RaisedException;
|
||||
}
|
||||
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
throw new Exception("Playmode tests were aborted because the player was stopped.");
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4769fe1e7475c8843b092338acbcad25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94a6220ee1a442249702c9df66e0fe1b
|
||||
timeCreated: 1695719729
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Player
|
||||
{
|
||||
internal class DetermineRuntimePlatformTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var targetPlatform = testJobData.executionSettings.targetPlatform;
|
||||
if (targetPlatform.HasValue)
|
||||
{
|
||||
testJobData.TargetRuntimePlatform = BuildTargetConverter.TryConvertToRuntimePlatform(targetPlatform.Value);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 006c3457e983424bbdead50009cd0e00
|
||||
timeCreated: 1695719739
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class PostbuildCleanupTask : BuildActionTaskBase<IPostBuildCleanup>
|
||||
{
|
||||
public PostbuildCleanupTask() : base(new PostbuildCleanupAttributeFinder())
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
}
|
||||
|
||||
protected override void Action(IPostBuildCleanup target)
|
||||
{
|
||||
target.Cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b6931522502d68458016e3cadb89f1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class PrebuildSetupTask : BuildActionTaskBase<IPrebuildSetup>
|
||||
{
|
||||
public PrebuildSetupTask() : base(new PrebuildSetupAttributeFinder())
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Action(IPrebuildSetup target)
|
||||
{
|
||||
target.Setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc039194235714f48a39bd364885e744
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class PreparePlayModeRunTask : TestTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.OriginalProjectSettings = new TestJobData.SavedProjectSettings
|
||||
{
|
||||
consoleErrorPaused = ConsoleWindow.GetConsoleErrorPause(),
|
||||
runInBackgroundValue = Application.runInBackground
|
||||
};
|
||||
ConsoleWindow.SetConsoleErrorPause(false);
|
||||
Application.runInBackground = true;
|
||||
if (testJobData.InitTestScene.IsValid())
|
||||
{
|
||||
SceneManager.SetActiveScene(testJobData.InitTestScene);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1694e597ba745169b292914291c136b
|
||||
timeCreated: 1705486325
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class RegisterFilesForCleanupVerificationTask : FileCleanupVerifierTaskBase
|
||||
{
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.existingFiles = GetAllFilesInAssetsDirectory();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a398fde47a0349a40a9bdf8988c392c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class ResetInteractionModeTask : TestTaskBase
|
||||
{
|
||||
private const string ApplicationIdleTimeKey = "ApplicationIdleTime";
|
||||
private const string InteractionModeKey = "InteractionMode";
|
||||
|
||||
public ResetInteractionModeTask()
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
RunOnCancel = true;
|
||||
}
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SetInteractionModeToUserSetting(testJobData);
|
||||
EditorApplication.UpdateInteractionModeSettings();
|
||||
#endif
|
||||
yield break;
|
||||
}
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
private void SetInteractionModeToUserSetting(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.UserApplicationIdleTime != -1)
|
||||
{
|
||||
EditorPrefs.SetInt(ApplicationIdleTimeKey, testJobData.UserApplicationIdleTime);
|
||||
}
|
||||
|
||||
if (testJobData.UserInteractionMode != -1)
|
||||
{
|
||||
EditorPrefs.SetInt(InteractionModeKey, testJobData.UserInteractionMode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5db0e0c612cd489a89d330acbc4ac585
|
||||
timeCreated: 1713426017
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class RestoreProjectSettingsTask : TestTaskBase
|
||||
{
|
||||
public RestoreProjectSettingsTask()
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
RunOnCancel = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (testJobData.OriginalProjectSettings == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
ConsoleWindow.SetConsoleErrorPause(testJobData.OriginalProjectSettings.consoleErrorPaused);
|
||||
Application.runInBackground = testJobData.OriginalProjectSettings.runInBackgroundValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f691f67e4ca49a386e31761b0ff8238
|
||||
timeCreated: 1705486535
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class SaveUndoIndexTask : TestTaskBase
|
||||
{
|
||||
internal Func<int> GetUndoGroup = Undo.GetCurrentGroup;
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.undoGroup = GetUndoGroup();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc0ce06a7515c044bb8db4c75db84114
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 692476ac695e7b74a8d9eabd48862009
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class CreateNewSceneTask : TestTaskBase
|
||||
{
|
||||
internal Func<int> GetSceneCount = () => SceneManager.sceneCount;
|
||||
internal Func<int, ISceneWrapper> GetSceneAt = i => new SceneWrapper(SceneManager.GetSceneAt(i));
|
||||
internal Func<NewSceneSetup, NewSceneMode, ISceneWrapper> NewScene = (setup, mode) => new SceneWrapper(EditorSceneManager.NewScene(setup, mode));
|
||||
internal Action<ISceneWrapper> SetActiveScene = scene => SceneManager.SetActiveScene(scene.WrappedScene);
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
if (GetSceneCount() == 1 && string.IsNullOrEmpty(GetSceneAt(0).path))
|
||||
{
|
||||
NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
|
||||
yield break;
|
||||
}
|
||||
|
||||
var scene = NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
|
||||
SetActiveScene(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dff66623000ef448ab68db41d803d95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal interface ISceneWrapper
|
||||
{
|
||||
UnityEngine.SceneManagement.Scene WrappedScene { get; }
|
||||
bool isDirty { get; }
|
||||
string path { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c24a1e88fc49dce47930834ff9997443
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class ReloadModifiedScenesTask : TestTaskBase
|
||||
{
|
||||
internal Func<int> GetSceneCount = () => SceneManager.sceneCount;
|
||||
internal Func<int, ISceneWrapper> GetSceneAt = i => new SceneWrapper(SceneManager.GetSceneAt(i));
|
||||
internal Func<ISceneWrapper, bool> ReloadScene = scene => EditorSceneManager.ReloadScene(scene.WrappedScene);
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
for (var i = 0; i < GetSceneCount(); i++)
|
||||
{
|
||||
var scene = GetSceneAt(i);
|
||||
var isSceneSaved = !string.IsNullOrEmpty(scene.path);
|
||||
var isSceneDirty = scene.isDirty;
|
||||
if (isSceneSaved && isSceneDirty)
|
||||
{
|
||||
ReloadScene(scene);
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab19dca503e90904e95faefddb68150d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class RemoveAdditionalUntitledSceneTask : TestTaskBase
|
||||
{
|
||||
internal Func<int> GetSceneCount = () => SceneManager.sceneCount;
|
||||
internal Func<int, ISceneWrapper> GetSceneAt = i => new SceneWrapper(SceneManager.GetSceneAt(i));
|
||||
internal Func<ISceneWrapper, bool, bool> CloseScene = (scene, remove) => EditorSceneManager.CloseScene(scene.WrappedScene, remove);
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var sceneCount = GetSceneCount();
|
||||
if (sceneCount <= 1)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sceneCount; i++)
|
||||
{
|
||||
var scene = GetSceneAt(i);
|
||||
if (string.IsNullOrEmpty(scene.path))
|
||||
{
|
||||
CloseScene(scene, true);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e02e76bfece9a28408e2e7dcb2e14b8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class RestoreSceneSetupTask : TestTaskBase
|
||||
{
|
||||
internal Action<SceneSetup[]> RestoreSceneManagerSetup = EditorSceneManager.RestoreSceneManagerSetup;
|
||||
internal Func<NewSceneSetup, NewSceneMode, ISceneWrapper> NewScene = (setup, mode) => new SceneWrapper(EditorSceneManager.NewScene(setup, mode));
|
||||
|
||||
public RestoreSceneSetupTask()
|
||||
{
|
||||
RunOnError = ErrorRunMode.RunAlways;
|
||||
RunOnCancel = true;
|
||||
}
|
||||
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var sceneSetup = testJobData.SceneSetup;
|
||||
if (sceneSetup != null && sceneSetup.Length > 0)
|
||||
{
|
||||
RestoreSceneManagerSetup(sceneSetup);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 337f28535644395459f6de8c60d9db37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class SaveModifiedSceneTask : TestTaskBase
|
||||
{
|
||||
internal Func<bool> SaveCurrentModifiedScenesIfUserWantsTo =
|
||||
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo;
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
var cancelled = !SaveCurrentModifiedScenesIfUserWantsTo();
|
||||
if (cancelled)
|
||||
{
|
||||
throw new TestRunCanceledException();
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 881143a1a3652e343bdcc07166d6f6f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class SceneWrapper : ISceneWrapper
|
||||
{
|
||||
private UnityEngine.SceneManagement.Scene m_WrappedScene;
|
||||
|
||||
public SceneWrapper(UnityEngine.SceneManagement.Scene wrappedScene)
|
||||
{
|
||||
m_WrappedScene = wrappedScene;
|
||||
}
|
||||
|
||||
public UnityEngine.SceneManagement.Scene WrappedScene
|
||||
{
|
||||
get { return m_WrappedScene; }
|
||||
}
|
||||
|
||||
public bool isDirty
|
||||
{
|
||||
get { return m_WrappedScene.isDirty; }
|
||||
}
|
||||
|
||||
public string path
|
||||
{
|
||||
get { return m_WrappedScene.path; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43c24fd91e60170469bfb8d79c565ad3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene
|
||||
{
|
||||
internal class StoreSceneSetupTask : TestTaskBase
|
||||
{
|
||||
internal Func<SceneSetup[]> GetSceneManagerSetup = EditorSceneManager.GetSceneManagerSetup;
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
testJobData.SceneSetup = GetSceneManagerSetup();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c4d36a13e7466e43940732365f53bf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
|
||||
{
|
||||
internal class SetInteractionModeTask : TestTaskBase
|
||||
{
|
||||
private const string ApplicationIdleTimeKey = "ApplicationIdleTime";
|
||||
private const string InteractionModeKey = "InteractionMode";
|
||||
public override IEnumerator Execute(TestJobData testJobData)
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SetInteractionModeToNoThrottling(testJobData);
|
||||
EditorApplication.UpdateInteractionModeSettings();
|
||||
#endif
|
||||
yield break;
|
||||
}
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
private void SetInteractionModeToNoThrottling(TestJobData testJobData)
|
||||
{
|
||||
testJobData.UserApplicationIdleTime = EditorPrefs.GetInt(ApplicationIdleTimeKey);
|
||||
testJobData.UserInteractionMode = EditorPrefs.GetInt(InteractionModeKey);
|
||||
EditorPrefs.SetInt(ApplicationIdleTimeKey, 0);
|
||||
EditorPrefs.SetInt(InteractionModeKey, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3710fe6aef52449b9c9bbf0b17ae6960
|
||||
timeCreated: 1713425998
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user