Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
fileFormatVersion: 2
guid: ce567ddbf30368344bc7b80e20cac36e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ce567ddbf30368344bc7b80e20cac36e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class TestRunnerResult : TestRunnerFilter.IClearableResult
{
public string id;
public string uniqueId;
public string name;
public string fullName;
public ResultStatus resultStatus = ResultStatus.NotRun;
public float duration;
public string messages;
public string output;
public string stacktrace;
public bool notRunnable;
public bool ignoredOrSkipped;
public string description;
public bool isSuite;
public List<string> categories;
public string parentId;
public string parentUniqueId;
//This field is suppose to mark results from before domain reload
//Such result is outdated because the code might haev changed
//This field will get reset every time a domain reload happens
[NonSerialized]
public bool notOutdated;
protected Action<TestRunnerResult> m_OnResultUpdate;
internal TestRunnerResult(ITestAdaptor test)
{
id = test.Id;
uniqueId = test.UniqueName;
fullName = test.FullName;
name = test.Name;
description = test.Description;
isSuite = test.IsSuite;
ignoredOrSkipped = test.RunState == RunState.Ignored || test.RunState == RunState.Skipped;
notRunnable = test.RunState == RunState.NotRunnable;
if (ignoredOrSkipped)
{
messages = test.SkipReason;
}
if (notRunnable)
{
resultStatus = ResultStatus.Failed;
messages = test.SkipReason;
}
categories = test.Categories.ToList();
parentId = test.ParentId;
parentUniqueId = test.ParentUniqueName;
}
internal TestRunnerResult(ITestResultAdaptor testResult) : this(testResult.Test)
{
notOutdated = true;
messages = testResult.Message;
output = testResult.Output;
stacktrace = testResult.StackTrace;
duration = (float)testResult.Duration;
if (testResult.Test.IsSuite && testResult.ResultState == "Ignored")
{
resultStatus = ResultStatus.Passed;
}
else
{
resultStatus = ParseNUnitResultStatus(testResult.TestStatus);
}
}
public void Update(TestRunnerResult result)
{
if (ReferenceEquals(result, null))
return;
resultStatus = result.resultStatus;
duration = result.duration;
messages = result.messages;
output = result.output;
stacktrace = result.stacktrace;
ignoredOrSkipped = result.ignoredOrSkipped;
notRunnable = result.notRunnable;
description = result.description;
notOutdated = result.notOutdated;
if (m_OnResultUpdate != null)
m_OnResultUpdate(this);
}
public void SetResultChangedCallback(Action<TestRunnerResult> resultUpdated)
{
m_OnResultUpdate = resultUpdated;
}
[Serializable]
internal enum ResultStatus
{
NotRun,
Passed,
Failed,
Inconclusive,
Skipped
}
private static ResultStatus ParseNUnitResultStatus(TestStatus status)
{
switch (status)
{
case TestStatus.Passed:
return ResultStatus.Passed;
case TestStatus.Failed:
return ResultStatus.Failed;
case TestStatus.Inconclusive:
return ResultStatus.Inconclusive;
case TestStatus.Skipped:
return ResultStatus.Skipped;
default:
return ResultStatus.NotRun;
}
}
public override string ToString()
{
return string.Format("{0} ({1})", name, fullName);
}
public string Id { get { return uniqueId; } }
public string FullName { get { return fullName; } }
public string ParentId { get { return parentUniqueId; } }
public bool IsSuite { get { return isSuite; } }
public List<string> Categories { get { return categories; } }
public void Clear()
{
resultStatus = ResultStatus.NotRun;
if (m_OnResultUpdate != null)
m_OnResultUpdate(this);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class TestRunnerResult : TestRunnerFilter.IClearableResult
{
public string id;
public string uniqueId;
public string name;
public string fullName;
public ResultStatus resultStatus = ResultStatus.NotRun;
public float duration;
public string messages;
public string output;
public string stacktrace;
public bool notRunnable;
public bool ignoredOrSkipped;
public string description;
public bool isSuite;
public List<string> categories;
public string parentId;
public string parentUniqueId;
//This field is suppose to mark results from before domain reload
//Such result is outdated because the code might haev changed
//This field will get reset every time a domain reload happens
[NonSerialized]
public bool notOutdated;
protected Action<TestRunnerResult> m_OnResultUpdate;
internal TestRunnerResult(ITestAdaptor test)
{
id = test.Id;
uniqueId = test.UniqueName;
fullName = test.FullName;
name = test.Name;
description = test.Description;
isSuite = test.IsSuite;
ignoredOrSkipped = test.RunState == RunState.Ignored || test.RunState == RunState.Skipped;
notRunnable = test.RunState == RunState.NotRunnable;
if (ignoredOrSkipped)
{
messages = test.SkipReason;
}
if (notRunnable)
{
resultStatus = ResultStatus.Failed;
messages = test.SkipReason;
}
categories = test.Categories.ToList();
parentId = test.ParentId;
parentUniqueId = test.ParentUniqueName;
}
internal TestRunnerResult(ITestResultAdaptor testResult) : this(testResult.Test)
{
notOutdated = true;
messages = testResult.Message;
output = testResult.Output;
stacktrace = testResult.StackTrace;
duration = (float)testResult.Duration;
if (testResult.Test.IsSuite && testResult.ResultState == "Ignored")
{
resultStatus = ResultStatus.Passed;
}
else
{
resultStatus = ParseNUnitResultStatus(testResult.TestStatus);
}
}
public void Update(TestRunnerResult result)
{
if (ReferenceEquals(result, null))
return;
resultStatus = result.resultStatus;
duration = result.duration;
messages = result.messages;
output = result.output;
stacktrace = result.stacktrace;
ignoredOrSkipped = result.ignoredOrSkipped;
notRunnable = result.notRunnable;
description = result.description;
notOutdated = result.notOutdated;
if (m_OnResultUpdate != null)
m_OnResultUpdate(this);
}
public void SetResultChangedCallback(Action<TestRunnerResult> resultUpdated)
{
m_OnResultUpdate = resultUpdated;
}
[Serializable]
internal enum ResultStatus
{
NotRun,
Passed,
Failed,
Inconclusive,
Skipped
}
private static ResultStatus ParseNUnitResultStatus(TestStatus status)
{
switch (status)
{
case TestStatus.Passed:
return ResultStatus.Passed;
case TestStatus.Failed:
return ResultStatus.Failed;
case TestStatus.Inconclusive:
return ResultStatus.Inconclusive;
case TestStatus.Skipped:
return ResultStatus.Skipped;
default:
return ResultStatus.NotRun;
}
}
public override string ToString()
{
return string.Format("{0} ({1})", name, fullName);
}
public string Id { get { return uniqueId; } }
public string FullName { get { return fullName; } }
public string ParentId { get { return parentUniqueId; } }
public bool IsSuite { get { return isSuite; } }
public List<string> Categories { get { return categories; } }
public void Clear()
{
resultStatus = ResultStatus.NotRun;
if (m_OnResultUpdate != null)
m_OnResultUpdate(this);
}
}
}
fileFormatVersion: 2
guid: a04a45bbed9e1714f9902fc9443669b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a04a45bbed9e1714f9902fc9443669b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class TestRunnerUIFilter
{
private int m_PassedCount;
private int m_FailedCount;
private int m_NotRunCount;
private int m_InconclusiveCount;
private int m_SkippedCount;
public int PassedCount { get { return m_PassedCount; } }
public int FailedCount { get { return m_FailedCount + m_InconclusiveCount; } }
public int NotRunCount { get { return m_NotRunCount + m_SkippedCount; } }
[SerializeField]
public bool PassedHidden;
[SerializeField]
public bool FailedHidden;
[SerializeField]
public bool NotRunHidden;
[SerializeField]
private string m_SearchString;
[SerializeField]
private int selectedCategoryMask;
public string[] availableCategories = new string[0];
private GUIContent m_SucceededBtn;
private GUIContent m_FailedBtn;
private GUIContent m_NotRunBtn;
public Action RebuildTestList;
public Action<string> SearchStringChanged;
public Action SearchStringCleared;
public bool IsFiltering
{
get
{
return !string.IsNullOrEmpty(m_SearchString) || PassedHidden || FailedHidden || NotRunHidden ||
selectedCategoryMask != 0;
}
}
public string[] CategoryFilter
{
get
{
var list = new List<string>();
for (int i = 0; i < availableCategories.Length; i++)
{
if ((selectedCategoryMask & (1 << i)) != 0)
{
list.Add(availableCategories[i]);
}
}
return list.ToArray();
}
}
public void UpdateCounters(List<TestRunnerResult> resultList)
{
m_PassedCount = m_FailedCount = m_NotRunCount = m_InconclusiveCount = m_SkippedCount = 0;
foreach (var result in resultList)
{
if (result.isSuite)
continue;
switch (result.resultStatus)
{
case TestRunnerResult.ResultStatus.Passed:
m_PassedCount++;
break;
case TestRunnerResult.ResultStatus.Failed:
m_FailedCount++;
break;
case TestRunnerResult.ResultStatus.Inconclusive:
m_InconclusiveCount++;
break;
case TestRunnerResult.ResultStatus.Skipped:
m_SkippedCount++;
break;
case TestRunnerResult.ResultStatus.NotRun:
default:
m_NotRunCount++;
break;
}
}
var succeededTooltip = string.Format("Show tests that succeeded\n{0} succeeded", m_PassedCount);
m_SucceededBtn = new GUIContent(PassedCount.ToString(), Icons.s_SuccessImg, succeededTooltip);
var failedTooltip = string.Format("Show tests that failed\n{0} failed\n{1} inconclusive", m_FailedCount, m_InconclusiveCount);
m_FailedBtn = new GUIContent(FailedCount.ToString(), Icons.s_FailImg, failedTooltip);
var notRunTooltip = string.Format("Show tests that didn't run\n{0} didn't run\n{1} skipped or ignored", m_NotRunCount, m_SkippedCount);
m_NotRunBtn = new GUIContent(NotRunCount.ToString(), Icons.s_UnknownImg, notRunTooltip);
}
public void Draw()
{
EditorGUI.BeginChangeCheck();
if (m_SearchString == null)
{
m_SearchString = "";
}
m_SearchString = EditorGUILayout.ToolbarSearchField(m_SearchString);
if (EditorGUI.EndChangeCheck() && SearchStringChanged != null)
{
SearchStringChanged(m_SearchString);
if (String.IsNullOrEmpty(m_SearchString))
SearchStringCleared();
}
if (availableCategories != null && availableCategories.Any())
{
EditorGUI.BeginChangeCheck();
selectedCategoryMask = EditorGUILayout.MaskField(selectedCategoryMask, availableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(150));
if (EditorGUI.EndChangeCheck() && RebuildTestList != null)
{
RebuildTestList();
}
}
else
{
EditorGUILayout.Popup(0, new[] { "<No categories available>" }, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(150));
}
EditorGUI.BeginChangeCheck();
if (m_SucceededBtn != null)
{
PassedHidden = !GUILayout.Toggle(!PassedHidden, m_SucceededBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(PassedCount)));
}
if (m_FailedBtn != null)
{
FailedHidden = !GUILayout.Toggle(!FailedHidden, m_FailedBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(FailedCount)));
}
if (m_NotRunBtn != null)
{
NotRunHidden = !GUILayout.Toggle(!NotRunHidden, m_NotRunBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(NotRunCount)));
}
if (EditorGUI.EndChangeCheck() && RebuildTestList != null)
{
RebuildTestList();
}
}
private static int GetMaxWidth(int count)
{
if (count < 10)
return 33;
return count < 100 ? 40 : 47;
}
public void Clear()
{
PassedHidden = false;
FailedHidden = false;
NotRunHidden = false;
selectedCategoryMask = 0;
m_SearchString = "";
if (SearchStringChanged != null)
{
SearchStringChanged(m_SearchString);
}
if (SearchStringCleared != null)
{
SearchStringCleared();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class TestRunnerUIFilter
{
private int m_PassedCount;
private int m_FailedCount;
private int m_NotRunCount;
private int m_InconclusiveCount;
private int m_SkippedCount;
public int PassedCount { get { return m_PassedCount; } }
public int FailedCount { get { return m_FailedCount + m_InconclusiveCount; } }
public int NotRunCount { get { return m_NotRunCount + m_SkippedCount; } }
[SerializeField]
public bool PassedHidden;
[SerializeField]
public bool FailedHidden;
[SerializeField]
public bool NotRunHidden;
[SerializeField]
private string m_SearchString;
[SerializeField]
private int selectedCategoryMask;
public string[] availableCategories = new string[0];
private GUIContent m_SucceededBtn;
private GUIContent m_FailedBtn;
private GUIContent m_NotRunBtn;
public Action RebuildTestList;
public Action<string> SearchStringChanged;
public Action SearchStringCleared;
public bool IsFiltering
{
get
{
return !string.IsNullOrEmpty(m_SearchString) || PassedHidden || FailedHidden || NotRunHidden ||
selectedCategoryMask != 0;
}
}
public string[] CategoryFilter
{
get
{
var list = new List<string>();
for (int i = 0; i < availableCategories.Length; i++)
{
if ((selectedCategoryMask & (1 << i)) != 0)
{
list.Add(availableCategories[i]);
}
}
return list.ToArray();
}
}
public void UpdateCounters(List<TestRunnerResult> resultList)
{
m_PassedCount = m_FailedCount = m_NotRunCount = m_InconclusiveCount = m_SkippedCount = 0;
foreach (var result in resultList)
{
if (result.isSuite)
continue;
switch (result.resultStatus)
{
case TestRunnerResult.ResultStatus.Passed:
m_PassedCount++;
break;
case TestRunnerResult.ResultStatus.Failed:
m_FailedCount++;
break;
case TestRunnerResult.ResultStatus.Inconclusive:
m_InconclusiveCount++;
break;
case TestRunnerResult.ResultStatus.Skipped:
m_SkippedCount++;
break;
case TestRunnerResult.ResultStatus.NotRun:
default:
m_NotRunCount++;
break;
}
}
var succeededTooltip = string.Format("Show tests that succeeded\n{0} succeeded", m_PassedCount);
m_SucceededBtn = new GUIContent(PassedCount.ToString(), Icons.s_SuccessImg, succeededTooltip);
var failedTooltip = string.Format("Show tests that failed\n{0} failed\n{1} inconclusive", m_FailedCount, m_InconclusiveCount);
m_FailedBtn = new GUIContent(FailedCount.ToString(), Icons.s_FailImg, failedTooltip);
var notRunTooltip = string.Format("Show tests that didn't run\n{0} didn't run\n{1} skipped or ignored", m_NotRunCount, m_SkippedCount);
m_NotRunBtn = new GUIContent(NotRunCount.ToString(), Icons.s_UnknownImg, notRunTooltip);
}
public void Draw()
{
EditorGUI.BeginChangeCheck();
if (m_SearchString == null)
{
m_SearchString = "";
}
m_SearchString = EditorGUILayout.ToolbarSearchField(m_SearchString);
if (EditorGUI.EndChangeCheck() && SearchStringChanged != null)
{
SearchStringChanged(m_SearchString);
if (String.IsNullOrEmpty(m_SearchString))
SearchStringCleared();
}
if (availableCategories != null && availableCategories.Any())
{
EditorGUI.BeginChangeCheck();
selectedCategoryMask = EditorGUILayout.MaskField(selectedCategoryMask, availableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(150));
if (EditorGUI.EndChangeCheck() && RebuildTestList != null)
{
RebuildTestList();
}
}
else
{
EditorGUILayout.Popup(0, new[] { "<No categories available>" }, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(150));
}
EditorGUI.BeginChangeCheck();
if (m_SucceededBtn != null)
{
PassedHidden = !GUILayout.Toggle(!PassedHidden, m_SucceededBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(PassedCount)));
}
if (m_FailedBtn != null)
{
FailedHidden = !GUILayout.Toggle(!FailedHidden, m_FailedBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(FailedCount)));
}
if (m_NotRunBtn != null)
{
NotRunHidden = !GUILayout.Toggle(!NotRunHidden, m_NotRunBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(GetMaxWidth(NotRunCount)));
}
if (EditorGUI.EndChangeCheck() && RebuildTestList != null)
{
RebuildTestList();
}
}
private static int GetMaxWidth(int count)
{
if (count < 10)
return 33;
return count < 100 ? 40 : 47;
}
public void Clear()
{
PassedHidden = false;
FailedHidden = false;
NotRunHidden = false;
selectedCategoryMask = 0;
m_SearchString = "";
if (SearchStringChanged != null)
{
SearchStringChanged(m_SearchString);
}
if (SearchStringCleared != null)
{
SearchStringCleared();
}
}
}
}
fileFormatVersion: 2
guid: 15f870c6975ad6449b5b52514b90dc2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 15f870c6975ad6449b5b52514b90dc2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c5535d742ea2e4941850b421f9c70a1f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c5535d742ea2e4941850b421f9c70a1f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class EditModeTestListGUI : TestListGUI
{
public override TestMode TestMode
{
get { return TestMode.EditMode; }
}
public override void RenderNoTestsInfo()
{
if (!TestListGUIHelper.SelectedFolderContainsTestAssembly())
{
var noTestText = "No tests to show";
if (!PlayerSettings.playModeTestRunnerEnabled)
{
const string testsArePulledFromCustomAssemblies =
"EditMode tests can be in Editor only Assemblies, either in the editor special folder or Editor only Assembly Definitions that references the \"nunit.framework.dll\" Assembly Reference or any of the Assembly Definition References \"UnityEngine.TestRunner\" or \"UnityEditor.TestRunner\"..";
noTestText += Environment.NewLine + testsArePulledFromCustomAssemblies;
}
EditorGUILayout.HelpBox(noTestText, MessageType.Info);
if (GUILayout.Button("Create EditMode Test Assembly Folder"))
{
TestListGUIHelper.AddFolderAndAsmDefForTesting(isEditorOnly: true);
}
}
if (!TestListGUIHelper.CanAddEditModeTestScriptAndItWillCompile())
{
UnityEngine.GUI.enabled = false;
EditorGUILayout.HelpBox("EditMode test scripts can only be created in editor test assemblies.", MessageType.Warning);
}
if (GUILayout.Button("Create Test Script in current folder"))
{
TestListGUIHelper.AddTest();
}
UnityEngine.GUI.enabled = true;
}
public override void PrintHeadPanel()
{
base.PrintHeadPanel();
DrawFilters();
}
protected override void RunTests(params TestRunnerFilter[] filters)
{
if (EditorUtility.scriptCompilationFailed)
{
Debug.LogError("Fix compilation issues before running tests");
return;
}
foreach (var filter in filters)
{
filter.ClearResults(newResultList.OfType<TestRunnerFilter.IClearableResult>().ToList());
}
RerunCallbackData.instance.runFilters = filters;
RerunCallbackData.instance.testMode = TestMode.EditMode;
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = filters.Select(filter => new Filter()
{
assemblyNames = filter.assemblyNames,
categoryNames = filter.categoryNames,
groupNames = filter.groupNames,
testMode = TestMode,
testNames = filter.testNames
}).ToArray()
});
}
public override TestPlatform TestPlatform { get { return TestPlatform.EditMode; } }
protected override bool IsBusy()
{
return TestRunnerApi.IsRunActive() || EditorApplication.isCompiling || EditorApplication.isPlaying;
}
}
}
using System;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class EditModeTestListGUI : TestListGUI
{
public override TestMode TestMode
{
get { return TestMode.EditMode; }
}
public override void RenderNoTestsInfo()
{
if (!TestListGUIHelper.SelectedFolderContainsTestAssembly())
{
var noTestText = "No tests to show";
if (!PlayerSettings.playModeTestRunnerEnabled)
{
const string testsArePulledFromCustomAssemblies =
"EditMode tests can be in Editor only Assemblies, either in the editor special folder or Editor only Assembly Definitions that references the \"nunit.framework.dll\" Assembly Reference or any of the Assembly Definition References \"UnityEngine.TestRunner\" or \"UnityEditor.TestRunner\"..";
noTestText += Environment.NewLine + testsArePulledFromCustomAssemblies;
}
EditorGUILayout.HelpBox(noTestText, MessageType.Info);
if (GUILayout.Button("Create EditMode Test Assembly Folder"))
{
TestListGUIHelper.AddFolderAndAsmDefForTesting(isEditorOnly: true);
}
}
if (!TestListGUIHelper.CanAddEditModeTestScriptAndItWillCompile())
{
UnityEngine.GUI.enabled = false;
EditorGUILayout.HelpBox("EditMode test scripts can only be created in editor test assemblies.", MessageType.Warning);
}
if (GUILayout.Button("Create Test Script in current folder"))
{
TestListGUIHelper.AddTest();
}
UnityEngine.GUI.enabled = true;
}
public override void PrintHeadPanel()
{
base.PrintHeadPanel();
DrawFilters();
}
protected override void RunTests(params TestRunnerFilter[] filters)
{
if (EditorUtility.scriptCompilationFailed)
{
Debug.LogError("Fix compilation issues before running tests");
return;
}
foreach (var filter in filters)
{
filter.ClearResults(newResultList.OfType<TestRunnerFilter.IClearableResult>().ToList());
}
RerunCallbackData.instance.runFilters = filters;
RerunCallbackData.instance.testMode = TestMode.EditMode;
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = filters.Select(filter => new Filter()
{
assemblyNames = filter.assemblyNames,
categoryNames = filter.categoryNames,
groupNames = filter.groupNames,
testMode = TestMode,
testNames = filter.testNames
}).ToArray()
});
}
public override TestPlatform TestPlatform { get { return TestPlatform.EditMode; } }
protected override bool IsBusy()
{
return TestRunnerApi.IsRunActive() || EditorApplication.isCompiling || EditorApplication.isPlaying;
}
}
}
fileFormatVersion: 2
guid: 0336a32a79bfaed43a3fd2d88b91e974
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0336a32a79bfaed43a3fd2d88b91e974
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Linq;
using UnityEditor.SceneManagement;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class PlayModeTestListGUI : TestListGUI
{
public override TestMode TestMode
{
get { return TestMode.PlayMode; }
}
public override void PrintHeadPanel()
{
EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
base.PrintHeadPanel();
var runButtonText = EditorUserBuildSettings.installInBuildFolder ? "Export project" : "Run all in player";
if (GUILayout.Button($"{runButtonText} ({EditorUserBuildSettings.activeBuildTarget})", EditorStyles.toolbarButton))
{
RunTestsInPlayer();
}
EditorGUILayout.EndHorizontal();
DrawFilters();
EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
EditorGUILayout.EndHorizontal();
}
public override void RenderNoTestsInfo()
{
if (!TestListGUIHelper.SelectedFolderContainsTestAssembly())
{
var noTestText = "No tests to show";
if (!PlayerSettings.playModeTestRunnerEnabled)
{
const string testsArePulledFromCustomAssemblues = "Test Assemblies are defined by Assembly Definitions that references the \"nunit.framework.dll\" Assembly Reference or the Assembly Definition Reference \"UnityEngine.TestRunner\".";
const string infoTextAboutTestsInAllAssemblies =
"To have tests in all assemblies enable it in the Test Runner window context menu";
noTestText += Environment.NewLine + testsArePulledFromCustomAssemblues + Environment.NewLine +
infoTextAboutTestsInAllAssemblies;
}
EditorGUILayout.HelpBox(noTestText, MessageType.Info);
if (GUILayout.Button("Create PlayMode Test Assembly Folder"))
{
TestListGUIHelper.AddFolderAndAsmDefForTesting();
}
}
if (!TestListGUIHelper.CanAddPlayModeTestScriptAndItWillCompile())
{
UnityEngine.GUI.enabled = false;
EditorGUILayout.HelpBox("PlayMode test scripts can only be created in non editor test assemblies.", MessageType.Warning);
}
if (GUILayout.Button("Create Test Script in current folder"))
{
TestListGUIHelper.AddTest();
}
UnityEngine.GUI.enabled = true;
}
protected override void RunTests(TestRunnerFilter[] filters)
{
foreach (var filter in filters)
{
filter.ClearResults(newResultList.OfType<TestRunnerFilter.IClearableResult>().ToList());
}
RerunCallbackData.instance.runFilters = filters;
RerunCallbackData.instance.testMode = TestMode.PlayMode;
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = filters.Select(filter => new Filter()
{
assemblyNames = filter.assemblyNames,
categoryNames = filter.categoryNames,
groupNames = filter.groupNames,
testMode = TestMode,
testNames = filter.testNames
}).ToArray()
});
}
protected void RunTestsInPlayer()
{
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = new [] { new Filter()
{
testMode = TestMode,
}},
targetPlatform = EditorUserBuildSettings.activeBuildTarget
});
GUIUtility.ExitGUI();
}
public override TestPlatform TestPlatform { get { return TestPlatform.PlayMode; } }
protected override bool IsBusy()
{
return TestRunnerApi.IsRunActive() || PlaymodeLauncher.IsRunning || EditorApplication.isCompiling || EditorApplication.isPlaying;
}
}
}
using System;
using System.Linq;
using UnityEditor.SceneManagement;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.GUI
{
[Serializable]
internal class PlayModeTestListGUI : TestListGUI
{
public override TestMode TestMode
{
get { return TestMode.PlayMode; }
}
public override void PrintHeadPanel()
{
EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
base.PrintHeadPanel();
var runButtonText = EditorUserBuildSettings.installInBuildFolder ? "Export project" : "Run all in player";
if (GUILayout.Button($"{runButtonText} ({EditorUserBuildSettings.activeBuildTarget})", EditorStyles.toolbarButton))
{
RunTestsInPlayer();
}
EditorGUILayout.EndHorizontal();
DrawFilters();
EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
EditorGUILayout.EndHorizontal();
}
public override void RenderNoTestsInfo()
{
if (!TestListGUIHelper.SelectedFolderContainsTestAssembly())
{
var noTestText = "No tests to show";
if (!PlayerSettings.playModeTestRunnerEnabled)
{
const string testsArePulledFromCustomAssemblues = "Test Assemblies are defined by Assembly Definitions that references the \"nunit.framework.dll\" Assembly Reference or the Assembly Definition Reference \"UnityEngine.TestRunner\".";
const string infoTextAboutTestsInAllAssemblies =
"To have tests in all assemblies enable it in the Test Runner window context menu";
noTestText += Environment.NewLine + testsArePulledFromCustomAssemblues + Environment.NewLine +
infoTextAboutTestsInAllAssemblies;
}
EditorGUILayout.HelpBox(noTestText, MessageType.Info);
if (GUILayout.Button("Create PlayMode Test Assembly Folder"))
{
TestListGUIHelper.AddFolderAndAsmDefForTesting();
}
}
if (!TestListGUIHelper.CanAddPlayModeTestScriptAndItWillCompile())
{
UnityEngine.GUI.enabled = false;
EditorGUILayout.HelpBox("PlayMode test scripts can only be created in non editor test assemblies.", MessageType.Warning);
}
if (GUILayout.Button("Create Test Script in current folder"))
{
TestListGUIHelper.AddTest();
}
UnityEngine.GUI.enabled = true;
}
protected override void RunTests(TestRunnerFilter[] filters)
{
foreach (var filter in filters)
{
filter.ClearResults(newResultList.OfType<TestRunnerFilter.IClearableResult>().ToList());
}
RerunCallbackData.instance.runFilters = filters;
RerunCallbackData.instance.testMode = TestMode.PlayMode;
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = filters.Select(filter => new Filter()
{
assemblyNames = filter.assemblyNames,
categoryNames = filter.categoryNames,
groupNames = filter.groupNames,
testMode = TestMode,
testNames = filter.testNames
}).ToArray()
});
}
protected void RunTestsInPlayer()
{
var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
testRunnerApi.Execute(new ExecutionSettings()
{
filters = new [] { new Filter()
{
testMode = TestMode,
}},
targetPlatform = EditorUserBuildSettings.activeBuildTarget
});
GUIUtility.ExitGUI();
}
public override TestPlatform TestPlatform { get { return TestPlatform.PlayMode; } }
protected override bool IsBusy()
{
return TestRunnerApi.IsRunActive() || PlaymodeLauncher.IsRunning || EditorApplication.isCompiling || EditorApplication.isPlaying;
}
}
}
fileFormatVersion: 2
guid: c3efd39f2cfb43a4c830d4fd5689900f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c3efd39f2cfb43a4c830d4fd5689900f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor.IMGUI.Controls;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools.TestRunner.GUI;
using UnityEngine.TestTools;
namespace UnityEditor.TestTools.TestRunner.GUI
{
internal abstract class TestListGUI
{
private static readonly GUIContent s_GUIRunSelectedTests = EditorGUIUtility.TrTextContent("Run Selected", "Run selected test(s)");
private static readonly GUIContent s_GUIRunAllTests = EditorGUIUtility.TrTextContent("Run All", "Run all tests");
private static readonly GUIContent s_GUIRerunFailedTests = EditorGUIUtility.TrTextContent("Rerun Failed", "Rerun all failed tests");
private static readonly GUIContent s_GUIRun = EditorGUIUtility.TrTextContent("Run");
private static readonly GUIContent s_GUIRunUntilFailed = EditorGUIUtility.TrTextContent("Run Until Failed");
private static readonly GUIContent s_GUIRun100Times = EditorGUIUtility.TrTextContent("Run 100 times");
private static readonly GUIContent s_GUIOpenTest = EditorGUIUtility.TrTextContent("Open source code");
private static readonly GUIContent s_GUIOpenErrorLine = EditorGUIUtility.TrTextContent("Open error line");
private static readonly GUIContent s_GUIClearResults = EditorGUIUtility.TrTextContent("Clear Results", "Clear all test results");
[SerializeField]
protected TestRunnerWindow m_Window;
[SerializeField]
public List<TestRunnerResult> newResultList = new List<TestRunnerResult>();
[SerializeField]
private string m_ResultText;
[SerializeField]
private string m_ResultStacktrace;
private TreeViewController m_TestListTree;
[SerializeField]
internal TreeViewState m_TestListState;
[SerializeField]
internal TestRunnerUIFilter m_TestRunnerUIFilter = new TestRunnerUIFilter();
private Vector2 m_TestInfoScroll, m_TestListScroll;
private string m_PreviousProjectPath;
private List<TestRunnerResult> m_QueuedResults = new List<TestRunnerResult>();
protected TestListGUI()
{
MonoCecilHelper = new MonoCecilHelper();
AssetsDatabaseHelper = new AssetsDatabaseHelper();
GuiHelper = new GuiHelper(MonoCecilHelper, AssetsDatabaseHelper);
}
protected IMonoCecilHelper MonoCecilHelper { get; private set; }
protected IAssetsDatabaseHelper AssetsDatabaseHelper { get; private set; }
protected IGuiHelper GuiHelper { get; private set; }
public abstract TestMode TestMode { get; }
public virtual void PrintHeadPanel()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
using (new EditorGUI.DisabledScope(IsBusy()))
{
if (GUILayout.Button(s_GUIRunAllTests, EditorStyles.toolbarButton))
{
var filter = new TestRunnerFilter {categoryNames = m_TestRunnerUIFilter.CategoryFilter};
RunTests(filter);
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(m_TestListTree == null || !m_TestListTree.HasSelection() || IsBusy()))
{
if (GUILayout.Button(s_GUIRunSelectedTests, EditorStyles.toolbarButton))
{
RunTests(GetSelectedTestsAsFilter(m_TestListTree.GetSelection()));
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(m_TestRunnerUIFilter.FailedCount == 0 || IsBusy()))
{
if (GUILayout.Button(s_GUIRerunFailedTests, EditorStyles.toolbarButton))
{
var failedTestnames = new List<string>();
foreach (var result in newResultList)
{
if (result.isSuite)
continue;
if (result.resultStatus == TestRunnerResult.ResultStatus.Failed ||
result.resultStatus == TestRunnerResult.ResultStatus.Inconclusive)
failedTestnames.Add(result.fullName);
}
RunTests(new TestRunnerFilter() {testNames = failedTestnames.ToArray(), categoryNames = m_TestRunnerUIFilter.CategoryFilter});
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(IsBusy()))
{
if (GUILayout.Button(s_GUIClearResults, EditorStyles.toolbarButton))
{
foreach (var result in newResultList)
{
result.Clear();
}
m_TestRunnerUIFilter.UpdateCounters(newResultList);
GUIUtility.ExitGUI();
}
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
protected void DrawFilters()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
m_TestRunnerUIFilter.Draw();
EditorGUILayout.EndHorizontal();
}
public bool HasTreeData()
{
return m_TestListTree != null;
}
public virtual void RenderTestList()
{
if (m_TestListTree == null)
{
GUILayout.Label("Loading...");
return;
}
m_TestListScroll = EditorGUILayout.BeginScrollView(m_TestListScroll,
GUILayout.ExpandWidth(true),
GUILayout.MaxWidth(2000));
if (m_TestListTree.data.root == null || m_TestListTree.data.rowCount == 0 || (!m_TestListTree.isSearching && !m_TestListTree.data.GetItem(0).hasChildren))
{
if (m_TestRunnerUIFilter.IsFiltering)
{
if (GUILayout.Button("Clear filters"))
{
m_TestRunnerUIFilter.Clear();
m_TestListTree.ReloadData();
m_Window.Repaint();
}
}
RenderNoTestsInfo();
}
else
{
var treeRect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
var treeViewKeyboardControlId = GUIUtility.GetControlID(FocusType.Keyboard);
m_TestListTree.OnGUI(treeRect, treeViewKeyboardControlId);
}
EditorGUILayout.EndScrollView();
}
public virtual void RenderNoTestsInfo()
{
EditorGUILayout.HelpBox("No tests to show", MessageType.Info);
}
public void RenderDetails()
{
m_TestInfoScroll = EditorGUILayout.BeginScrollView(m_TestInfoScroll);
var resultTextSize = TestRunnerWindow.Styles.info.CalcSize(new GUIContent(m_ResultText));
EditorGUILayout.SelectableLabel(m_ResultText, TestRunnerWindow.Styles.info,
GUILayout.ExpandHeight(true),
GUILayout.ExpandWidth(true),
GUILayout.MinWidth(resultTextSize.x),
GUILayout.MinHeight(resultTextSize.y));
EditorGUILayout.EndScrollView();
}
public void Reload()
{
if (m_TestListTree != null)
{
m_TestListTree.ReloadData();
UpdateQueuedResults();
}
}
public void Repaint()
{
if (m_TestListTree == null || m_TestListTree.data.root == null)
{
return;
}
m_TestListTree.Repaint();
if (m_TestListTree.data.rowCount == 0)
m_TestListTree.SetSelection(new int[0], false);
TestSelectionCallback(m_TestListState.selectedIDs.ToArray());
}
public void Init(TestRunnerWindow window, ITestAdaptor rootTest)
{
if (m_Window == null)
{
m_Window = window;
}
if (m_TestListTree == null)
{
if (m_TestListState == null)
{
m_TestListState = new TreeViewState();
}
if (m_TestListTree == null)
m_TestListTree = new TreeViewController(m_Window, m_TestListState);
m_TestListTree.deselectOnUnhandledMouseDown = false;
m_TestListTree.selectionChangedCallback += TestSelectionCallback;
m_TestListTree.itemDoubleClickedCallback += TestDoubleClickCallback;
m_TestListTree.contextClickItemCallback += TestContextClickCallback;
var testListTreeViewDataSource = new TestListTreeViewDataSource(m_TestListTree, this, rootTest);
if (!newResultList.Any())
testListTreeViewDataSource.ExpandTreeOnCreation();
m_TestListTree.Init(new Rect(),
testListTreeViewDataSource,
new TestListTreeViewGUI(m_TestListTree),
null);
}
EditorApplication.update += RepaintIfProjectPathChanged;
m_TestRunnerUIFilter.UpdateCounters(newResultList);
m_TestRunnerUIFilter.RebuildTestList = () => m_TestListTree.ReloadData();
m_TestRunnerUIFilter.SearchStringChanged = s => m_TestListTree.searchString = s;
m_TestRunnerUIFilter.SearchStringCleared = () => FrameSelection();
}
public void UpdateResult(TestRunnerResult result)
{
if (!HasTreeData())
{
m_QueuedResults.Add(result);
return;
}
if (newResultList.All(x => x.uniqueId != result.uniqueId))
{
return;
}
var testRunnerResult = newResultList.FirstOrDefault(x => x.uniqueId == result.uniqueId);
if (testRunnerResult != null)
{
testRunnerResult.Update(result);
}
Repaint();
m_Window.Repaint();
}
public void UpdateTestTree(ITestAdaptor test)
{
if (!HasTreeData())
{
return;
}
(m_TestListTree.data as TestListTreeViewDataSource).UpdateRootTest(test);
m_TestListTree.ReloadData();
Repaint();
m_Window.Repaint();
}
private void UpdateQueuedResults()
{
foreach (var testRunnerResult in m_QueuedResults)
{
var existingResult = newResultList.FirstOrDefault(x => x.uniqueId == testRunnerResult.uniqueId);
if (existingResult != null)
{
existingResult.Update(testRunnerResult);
}
}
m_QueuedResults.Clear();
TestSelectionCallback(m_TestListState.selectedIDs.ToArray());
m_TestRunnerUIFilter.UpdateCounters(newResultList);
Repaint();
m_Window.Repaint();
}
internal void TestSelectionCallback(int[] selected)
{
if (m_TestListTree != null && selected.Length == 1)
{
if (m_TestListTree != null)
{
var node = m_TestListTree.FindItem(selected[0]);
if (node is TestTreeViewItem)
{
var test = node as TestTreeViewItem;
m_ResultText = test.GetResultText();
m_ResultStacktrace = test.result.stacktrace;
}
}
}
else if (selected.Length == 0)
{
m_ResultText = "";
}
}
protected virtual void TestDoubleClickCallback(int id)
{
if (IsBusy())
return;
RunTests(GetSelectedTestsAsFilter(new List<int> { id }));
GUIUtility.ExitGUI();
}
protected virtual void RunTests(params TestRunnerFilter[] filters)
{
throw new NotImplementedException();
}
protected virtual void TestContextClickCallback(int id)
{
if (id == 0)
return;
var m = new GenericMenu();
var testFilters = GetSelectedTestsAsFilter(m_TestListState.selectedIDs);
var multilineSelection = m_TestListState.selectedIDs.Count > 1;
if (!multilineSelection)
{
var testNode = GetSelectedTest();
var isNotSuite = !testNode.IsGroupNode;
if (isNotSuite)
{
if (!string.IsNullOrEmpty(m_ResultStacktrace))
{
m.AddItem(s_GUIOpenErrorLine,
false,
data =>
{
if (!GuiHelper.OpenScriptInExternalEditor(m_ResultStacktrace))
{
GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method);
}
},
"");
}
m.AddItem(s_GUIOpenTest,
false,
data => GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method),
"");
m.AddSeparator("");
}
}
if (!IsBusy())
{
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun,
false,
data => RunTests(testFilters),
"");
if (EditorPrefs.GetBool("DeveloperMode", false))
{
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRunUntilFailed,
false,
data =>
{
foreach (var filter in testFilters)
{
filter.testRepetitions = int.MaxValue;
}
RunTests(testFilters);
},
"");
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun100Times,
false,
data =>
{
foreach (var filter in testFilters)
{
filter.testRepetitions = 100;
}
RunTests(testFilters);
},
"");
}
}
else
m.AddDisabledItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun, false);
m.ShowAsContext();
}
private TestRunnerFilter[] GetSelectedTestsAsFilter(IEnumerable<int> selectedIDs)
{
var namesToRun = new List<string>();
var assembliesForNamesToRun = new List<string>();
var exactNamesToRun = new List<string>();
var assembliesToRun = new List<string>();
foreach (var lineId in selectedIDs)
{
var line = m_TestListTree.FindItem(lineId);
if (line is TestTreeViewItem)
{
var testLine = line as TestTreeViewItem;
if (testLine.IsGroupNode && !testLine.FullName.Contains("+"))
{
if (testLine.parent != null && testLine.parent.displayName == "Invisible Root Item")
{
//Root node selected. Use an empty TestRunnerFilter to run every test
return new[] {new TestRunnerFilter()};
}
if (testLine.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
{
assembliesToRun.Add(TestRunnerFilter.AssemblyNameFromPath(testLine.FullName));
}
else
{
namesToRun.Add($"^{Regex.Escape(testLine.FullName)}$");
var assembly = TestRunnerFilter.AssemblyNameFromPath(testLine.GetAssemblyName());
if (!string.IsNullOrEmpty(assembly) && !assembliesForNamesToRun.Contains(assembly))
{
assembliesForNamesToRun.Add(assembly);
}
}
}
else
{
exactNamesToRun.Add(testLine.FullName);
}
}
}
var filters = new List<TestRunnerFilter>();
if (assembliesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
assemblyNames = assembliesToRun.ToArray()
});
}
if (namesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
groupNames = namesToRun.ToArray(),
assemblyNames = assembliesForNamesToRun.ToArray()
});
}
if (exactNamesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
testNames = exactNamesToRun.ToArray()
});
}
if (filters.Count == 0)
{
filters.Add(new TestRunnerFilter());
}
var categories = m_TestRunnerUIFilter.CategoryFilter.ToArray();
if (categories.Length > 0)
{
foreach (var filter in filters)
{
filter.categoryNames = categories;
}
}
return filters.ToArray();
}
private TestTreeViewItem GetSelectedTest()
{
foreach (var lineId in m_TestListState.selectedIDs)
{
var line = m_TestListTree.FindItem(lineId);
if (line is TestTreeViewItem)
{
return line as TestTreeViewItem;
}
}
return null;
}
private void FrameSelection()
{
if (m_TestListTree.HasSelection())
{
var firstClickedID = m_TestListState.selectedIDs.First<int>() == m_TestListState.lastClickedID ? m_TestListState.selectedIDs.Last<int>() : m_TestListState.selectedIDs.First<int>();
m_TestListTree.Frame(firstClickedID, true, false);
}
}
public abstract TestPlatform TestPlatform { get; }
public void RebuildUIFilter()
{
m_TestRunnerUIFilter.UpdateCounters(newResultList);
if (m_TestRunnerUIFilter.IsFiltering)
{
m_TestListTree.ReloadData();
}
}
public void RepaintIfProjectPathChanged()
{
var path = TestListGUIHelper.GetActiveFolderPath();
if (path != m_PreviousProjectPath)
{
m_PreviousProjectPath = path;
TestRunnerWindow.s_Instance.Repaint();
}
EditorApplication.update -= RepaintIfProjectPathChanged;
}
protected abstract bool IsBusy();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor.IMGUI.Controls;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
using UnityEngine.TestTools.TestRunner.GUI;
using UnityEngine.TestTools;
namespace UnityEditor.TestTools.TestRunner.GUI
{
internal abstract class TestListGUI
{
private static readonly GUIContent s_GUIRunSelectedTests = EditorGUIUtility.TrTextContent("Run Selected", "Run selected test(s)");
private static readonly GUIContent s_GUIRunAllTests = EditorGUIUtility.TrTextContent("Run All", "Run all tests");
private static readonly GUIContent s_GUIRerunFailedTests = EditorGUIUtility.TrTextContent("Rerun Failed", "Rerun all failed tests");
private static readonly GUIContent s_GUIRun = EditorGUIUtility.TrTextContent("Run");
private static readonly GUIContent s_GUIRunUntilFailed = EditorGUIUtility.TrTextContent("Run Until Failed");
private static readonly GUIContent s_GUIRun100Times = EditorGUIUtility.TrTextContent("Run 100 times");
private static readonly GUIContent s_GUIOpenTest = EditorGUIUtility.TrTextContent("Open source code");
private static readonly GUIContent s_GUIOpenErrorLine = EditorGUIUtility.TrTextContent("Open error line");
private static readonly GUIContent s_GUIClearResults = EditorGUIUtility.TrTextContent("Clear Results", "Clear all test results");
[SerializeField]
protected TestRunnerWindow m_Window;
[SerializeField]
public List<TestRunnerResult> newResultList = new List<TestRunnerResult>();
[SerializeField]
private string m_ResultText;
[SerializeField]
private string m_ResultStacktrace;
private TreeViewController m_TestListTree;
[SerializeField]
internal TreeViewState m_TestListState;
[SerializeField]
internal TestRunnerUIFilter m_TestRunnerUIFilter = new TestRunnerUIFilter();
private Vector2 m_TestInfoScroll, m_TestListScroll;
private string m_PreviousProjectPath;
private List<TestRunnerResult> m_QueuedResults = new List<TestRunnerResult>();
protected TestListGUI()
{
MonoCecilHelper = new MonoCecilHelper();
AssetsDatabaseHelper = new AssetsDatabaseHelper();
GuiHelper = new GuiHelper(MonoCecilHelper, AssetsDatabaseHelper);
}
protected IMonoCecilHelper MonoCecilHelper { get; private set; }
protected IAssetsDatabaseHelper AssetsDatabaseHelper { get; private set; }
protected IGuiHelper GuiHelper { get; private set; }
public abstract TestMode TestMode { get; }
public virtual void PrintHeadPanel()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
using (new EditorGUI.DisabledScope(IsBusy()))
{
if (GUILayout.Button(s_GUIRunAllTests, EditorStyles.toolbarButton))
{
var filter = new TestRunnerFilter {categoryNames = m_TestRunnerUIFilter.CategoryFilter};
RunTests(filter);
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(m_TestListTree == null || !m_TestListTree.HasSelection() || IsBusy()))
{
if (GUILayout.Button(s_GUIRunSelectedTests, EditorStyles.toolbarButton))
{
RunTests(GetSelectedTestsAsFilter(m_TestListTree.GetSelection()));
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(m_TestRunnerUIFilter.FailedCount == 0 || IsBusy()))
{
if (GUILayout.Button(s_GUIRerunFailedTests, EditorStyles.toolbarButton))
{
var failedTestnames = new List<string>();
foreach (var result in newResultList)
{
if (result.isSuite)
continue;
if (result.resultStatus == TestRunnerResult.ResultStatus.Failed ||
result.resultStatus == TestRunnerResult.ResultStatus.Inconclusive)
failedTestnames.Add(result.fullName);
}
RunTests(new TestRunnerFilter() {testNames = failedTestnames.ToArray(), categoryNames = m_TestRunnerUIFilter.CategoryFilter});
GUIUtility.ExitGUI();
}
}
using (new EditorGUI.DisabledScope(IsBusy()))
{
if (GUILayout.Button(s_GUIClearResults, EditorStyles.toolbarButton))
{
foreach (var result in newResultList)
{
result.Clear();
}
m_TestRunnerUIFilter.UpdateCounters(newResultList);
GUIUtility.ExitGUI();
}
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
protected void DrawFilters()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
m_TestRunnerUIFilter.Draw();
EditorGUILayout.EndHorizontal();
}
public bool HasTreeData()
{
return m_TestListTree != null;
}
public virtual void RenderTestList()
{
if (m_TestListTree == null)
{
GUILayout.Label("Loading...");
return;
}
m_TestListScroll = EditorGUILayout.BeginScrollView(m_TestListScroll,
GUILayout.ExpandWidth(true),
GUILayout.MaxWidth(2000));
if (m_TestListTree.data.root == null || m_TestListTree.data.rowCount == 0 || (!m_TestListTree.isSearching && !m_TestListTree.data.GetItem(0).hasChildren))
{
if (m_TestRunnerUIFilter.IsFiltering)
{
if (GUILayout.Button("Clear filters"))
{
m_TestRunnerUIFilter.Clear();
m_TestListTree.ReloadData();
m_Window.Repaint();
}
}
RenderNoTestsInfo();
}
else
{
var treeRect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
var treeViewKeyboardControlId = GUIUtility.GetControlID(FocusType.Keyboard);
m_TestListTree.OnGUI(treeRect, treeViewKeyboardControlId);
}
EditorGUILayout.EndScrollView();
}
public virtual void RenderNoTestsInfo()
{
EditorGUILayout.HelpBox("No tests to show", MessageType.Info);
}
public void RenderDetails()
{
m_TestInfoScroll = EditorGUILayout.BeginScrollView(m_TestInfoScroll);
var resultTextSize = TestRunnerWindow.Styles.info.CalcSize(new GUIContent(m_ResultText));
EditorGUILayout.SelectableLabel(m_ResultText, TestRunnerWindow.Styles.info,
GUILayout.ExpandHeight(true),
GUILayout.ExpandWidth(true),
GUILayout.MinWidth(resultTextSize.x),
GUILayout.MinHeight(resultTextSize.y));
EditorGUILayout.EndScrollView();
}
public void Reload()
{
if (m_TestListTree != null)
{
m_TestListTree.ReloadData();
UpdateQueuedResults();
}
}
public void Repaint()
{
if (m_TestListTree == null || m_TestListTree.data.root == null)
{
return;
}
m_TestListTree.Repaint();
if (m_TestListTree.data.rowCount == 0)
m_TestListTree.SetSelection(new int[0], false);
TestSelectionCallback(m_TestListState.selectedIDs.ToArray());
}
public void Init(TestRunnerWindow window, ITestAdaptor rootTest)
{
if (m_Window == null)
{
m_Window = window;
}
if (m_TestListTree == null)
{
if (m_TestListState == null)
{
m_TestListState = new TreeViewState();
}
if (m_TestListTree == null)
m_TestListTree = new TreeViewController(m_Window, m_TestListState);
m_TestListTree.deselectOnUnhandledMouseDown = false;
m_TestListTree.selectionChangedCallback += TestSelectionCallback;
m_TestListTree.itemDoubleClickedCallback += TestDoubleClickCallback;
m_TestListTree.contextClickItemCallback += TestContextClickCallback;
var testListTreeViewDataSource = new TestListTreeViewDataSource(m_TestListTree, this, rootTest);
if (!newResultList.Any())
testListTreeViewDataSource.ExpandTreeOnCreation();
m_TestListTree.Init(new Rect(),
testListTreeViewDataSource,
new TestListTreeViewGUI(m_TestListTree),
null);
}
EditorApplication.update += RepaintIfProjectPathChanged;
m_TestRunnerUIFilter.UpdateCounters(newResultList);
m_TestRunnerUIFilter.RebuildTestList = () => m_TestListTree.ReloadData();
m_TestRunnerUIFilter.SearchStringChanged = s => m_TestListTree.searchString = s;
m_TestRunnerUIFilter.SearchStringCleared = () => FrameSelection();
}
public void UpdateResult(TestRunnerResult result)
{
if (!HasTreeData())
{
m_QueuedResults.Add(result);
return;
}
if (newResultList.All(x => x.uniqueId != result.uniqueId))
{
return;
}
var testRunnerResult = newResultList.FirstOrDefault(x => x.uniqueId == result.uniqueId);
if (testRunnerResult != null)
{
testRunnerResult.Update(result);
}
Repaint();
m_Window.Repaint();
}
public void UpdateTestTree(ITestAdaptor test)
{
if (!HasTreeData())
{
return;
}
(m_TestListTree.data as TestListTreeViewDataSource).UpdateRootTest(test);
m_TestListTree.ReloadData();
Repaint();
m_Window.Repaint();
}
private void UpdateQueuedResults()
{
foreach (var testRunnerResult in m_QueuedResults)
{
var existingResult = newResultList.FirstOrDefault(x => x.uniqueId == testRunnerResult.uniqueId);
if (existingResult != null)
{
existingResult.Update(testRunnerResult);
}
}
m_QueuedResults.Clear();
TestSelectionCallback(m_TestListState.selectedIDs.ToArray());
m_TestRunnerUIFilter.UpdateCounters(newResultList);
Repaint();
m_Window.Repaint();
}
internal void TestSelectionCallback(int[] selected)
{
if (m_TestListTree != null && selected.Length == 1)
{
if (m_TestListTree != null)
{
var node = m_TestListTree.FindItem(selected[0]);
if (node is TestTreeViewItem)
{
var test = node as TestTreeViewItem;
m_ResultText = test.GetResultText();
m_ResultStacktrace = test.result.stacktrace;
}
}
}
else if (selected.Length == 0)
{
m_ResultText = "";
}
}
protected virtual void TestDoubleClickCallback(int id)
{
if (IsBusy())
return;
RunTests(GetSelectedTestsAsFilter(new List<int> { id }));
GUIUtility.ExitGUI();
}
protected virtual void RunTests(params TestRunnerFilter[] filters)
{
throw new NotImplementedException();
}
protected virtual void TestContextClickCallback(int id)
{
if (id == 0)
return;
var m = new GenericMenu();
var testFilters = GetSelectedTestsAsFilter(m_TestListState.selectedIDs);
var multilineSelection = m_TestListState.selectedIDs.Count > 1;
if (!multilineSelection)
{
var testNode = GetSelectedTest();
var isNotSuite = !testNode.IsGroupNode;
if (isNotSuite)
{
if (!string.IsNullOrEmpty(m_ResultStacktrace))
{
m.AddItem(s_GUIOpenErrorLine,
false,
data =>
{
if (!GuiHelper.OpenScriptInExternalEditor(m_ResultStacktrace))
{
GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method);
}
},
"");
}
m.AddItem(s_GUIOpenTest,
false,
data => GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method),
"");
m.AddSeparator("");
}
}
if (!IsBusy())
{
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun,
false,
data => RunTests(testFilters),
"");
if (EditorPrefs.GetBool("DeveloperMode", false))
{
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRunUntilFailed,
false,
data =>
{
foreach (var filter in testFilters)
{
filter.testRepetitions = int.MaxValue;
}
RunTests(testFilters);
},
"");
m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun100Times,
false,
data =>
{
foreach (var filter in testFilters)
{
filter.testRepetitions = 100;
}
RunTests(testFilters);
},
"");
}
}
else
m.AddDisabledItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun, false);
m.ShowAsContext();
}
private TestRunnerFilter[] GetSelectedTestsAsFilter(IEnumerable<int> selectedIDs)
{
var namesToRun = new List<string>();
var assembliesForNamesToRun = new List<string>();
var exactNamesToRun = new List<string>();
var assembliesToRun = new List<string>();
foreach (var lineId in selectedIDs)
{
var line = m_TestListTree.FindItem(lineId);
if (line is TestTreeViewItem)
{
var testLine = line as TestTreeViewItem;
if (testLine.IsGroupNode && !testLine.FullName.Contains("+"))
{
if (testLine.parent != null && testLine.parent.displayName == "Invisible Root Item")
{
//Root node selected. Use an empty TestRunnerFilter to run every test
return new[] {new TestRunnerFilter()};
}
if (testLine.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
{
assembliesToRun.Add(TestRunnerFilter.AssemblyNameFromPath(testLine.FullName));
}
else
{
namesToRun.Add($"^{Regex.Escape(testLine.FullName)}$");
var assembly = TestRunnerFilter.AssemblyNameFromPath(testLine.GetAssemblyName());
if (!string.IsNullOrEmpty(assembly) && !assembliesForNamesToRun.Contains(assembly))
{
assembliesForNamesToRun.Add(assembly);
}
}
}
else
{
exactNamesToRun.Add(testLine.FullName);
}
}
}
var filters = new List<TestRunnerFilter>();
if (assembliesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
assemblyNames = assembliesToRun.ToArray()
});
}
if (namesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
groupNames = namesToRun.ToArray(),
assemblyNames = assembliesForNamesToRun.ToArray()
});
}
if (exactNamesToRun.Count > 0)
{
filters.Add(new TestRunnerFilter()
{
testNames = exactNamesToRun.ToArray()
});
}
if (filters.Count == 0)
{
filters.Add(new TestRunnerFilter());
}
var categories = m_TestRunnerUIFilter.CategoryFilter.ToArray();
if (categories.Length > 0)
{
foreach (var filter in filters)
{
filter.categoryNames = categories;
}
}
return filters.ToArray();
}
private TestTreeViewItem GetSelectedTest()
{
foreach (var lineId in m_TestListState.selectedIDs)
{
var line = m_TestListTree.FindItem(lineId);
if (line is TestTreeViewItem)
{
return line as TestTreeViewItem;
}
}
return null;
}
private void FrameSelection()
{
if (m_TestListTree.HasSelection())
{
var firstClickedID = m_TestListState.selectedIDs.First<int>() == m_TestListState.lastClickedID ? m_TestListState.selectedIDs.Last<int>() : m_TestListState.selectedIDs.First<int>();
m_TestListTree.Frame(firstClickedID, true, false);
}
}
public abstract TestPlatform TestPlatform { get; }
public void RebuildUIFilter()
{
m_TestRunnerUIFilter.UpdateCounters(newResultList);
if (m_TestRunnerUIFilter.IsFiltering)
{
m_TestListTree.ReloadData();
}
}
public void RepaintIfProjectPathChanged()
{
var path = TestListGUIHelper.GetActiveFolderPath();
if (path != m_PreviousProjectPath)
{
m_PreviousProjectPath = path;
TestRunnerWindow.s_Instance.Repaint();
}
EditorApplication.update -= RepaintIfProjectPathChanged;
}
protected abstract bool IsBusy();
}
}
fileFormatVersion: 2
guid: b8abb41ceb6f62c45a00197ae59224c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b8abb41ceb6f62c45a00197ae59224c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3f9202a39620f51418046c7754f215f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3f9202a39620f51418046c7754f215f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 96c503bf059df984c86eecf572370347
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 96c503bf059df984c86eecf572370347
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
namespace UnityEditor.TestTools
{
/// <summary>
/// Ignore attributes dedicated to Asset Import Pipeline backend version handling.
/// </summary>
internal static class AssetPipelineIgnore
{
internal enum AssetPipelineBackend
{
V1,
V2
}
/// <summary>
/// Ignore the test when running with the legacy Asset Import Pipeline V1 backend.
/// </summary>
internal class IgnoreInV1 : AssetPipelineIgnoreAttribute
{
public IgnoreInV1(string ignoreReason) : base(AssetPipelineBackend.V1, ignoreReason) {}
}
/// <summary>
/// Ignore the test when running with the latest Asset Import Pipeline V2 backend.
/// </summary>
internal class IgnoreInV2 : AssetPipelineIgnoreAttribute
{
public IgnoreInV2(string ignoreReason) : base(AssetPipelineBackend.V2, ignoreReason) {}
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
internal class AssetPipelineIgnoreAttribute : NUnitAttribute, IApplyToTest
{
readonly string m_IgnoreReason;
readonly AssetPipelineBackend m_IgnoredBackend;
static readonly AssetPipelineBackend k_ActiveBackend = AssetDatabase.IsV2Enabled()
? AssetPipelineBackend.V2
: AssetPipelineBackend.V1;
static string ActiveBackendName = Enum.GetName(typeof(AssetPipelineBackend), k_ActiveBackend);
public AssetPipelineIgnoreAttribute(AssetPipelineBackend backend, string ignoreReason)
{
m_IgnoredBackend = backend;
m_IgnoreReason = ignoreReason;
}
public void ApplyToTest(Test test)
{
if (k_ActiveBackend == m_IgnoredBackend)
{
test.RunState = RunState.Ignored;
var skipReason = string.Format("Not supported by asset pipeline {0} backend {1}", ActiveBackendName, m_IgnoreReason);
test.Properties.Add(PropertyNames.SkipReason, skipReason);
}
}
}
}
}
using System;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
namespace UnityEditor.TestTools
{
/// <summary>
/// Ignore attributes dedicated to Asset Import Pipeline backend version handling.
/// </summary>
internal static class AssetPipelineIgnore
{
internal enum AssetPipelineBackend
{
V1,
V2
}
/// <summary>
/// Ignore the test when running with the legacy Asset Import Pipeline V1 backend.
/// </summary>
internal class IgnoreInV1 : AssetPipelineIgnoreAttribute
{
public IgnoreInV1(string ignoreReason) : base(AssetPipelineBackend.V1, ignoreReason) {}
}
/// <summary>
/// Ignore the test when running with the latest Asset Import Pipeline V2 backend.
/// </summary>
internal class IgnoreInV2 : AssetPipelineIgnoreAttribute
{
public IgnoreInV2(string ignoreReason) : base(AssetPipelineBackend.V2, ignoreReason) {}
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
internal class AssetPipelineIgnoreAttribute : NUnitAttribute, IApplyToTest
{
readonly string m_IgnoreReason;
readonly AssetPipelineBackend m_IgnoredBackend;
static readonly AssetPipelineBackend k_ActiveBackend = AssetDatabase.IsV2Enabled()
? AssetPipelineBackend.V2
: AssetPipelineBackend.V1;
static string ActiveBackendName = Enum.GetName(typeof(AssetPipelineBackend), k_ActiveBackend);
public AssetPipelineIgnoreAttribute(AssetPipelineBackend backend, string ignoreReason)
{
m_IgnoredBackend = backend;
m_IgnoreReason = ignoreReason;
}
public void ApplyToTest(Test test)
{
if (k_ActiveBackend == m_IgnoredBackend)
{
test.RunState = RunState.Ignored;
var skipReason = string.Format("Not supported by asset pipeline {0} backend {1}", ActiveBackendName, m_IgnoreReason);
test.Properties.Add(PropertyNames.SkipReason, skipReason);
}
}
}
}
}
fileFormatVersion: 2
guid: b88caca58e05ee74486d86fb404c48e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b88caca58e05ee74486d86fb404c48e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools
{
public interface ITestPlayerBuildModifier
{
BuildPlayerOptions ModifyOptions(BuildPlayerOptions playerOptions);
}
namespace UnityEditor.TestTools
{
public interface ITestPlayerBuildModifier
{
BuildPlayerOptions ModifyOptions(BuildPlayerOptions playerOptions);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 6d2f47eae5f447748892c46848956d5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6d2f47eae5f447748892c46848956d5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
namespace UnityEditor.TestTools
{
[AttributeUsage(AttributeTargets.Assembly)]
public class TestPlayerBuildModifierAttribute : Attribute
{
private Type m_Type;
public TestPlayerBuildModifierAttribute(Type type)
{
var interfaceType = typeof(ITestPlayerBuildModifier);
if (!interfaceType.IsAssignableFrom(type))
{
throw new ArgumentException(string.Format("Type provided to {0} does not implement {1}", this.GetType().Name, interfaceType.Name));
}
m_Type = type;
}
internal ITestPlayerBuildModifier ConstructModifier()
{
return Activator.CreateInstance(m_Type) as ITestPlayerBuildModifier;
}
}
}
using System;
namespace UnityEditor.TestTools
{
[AttributeUsage(AttributeTargets.Assembly)]
public class TestPlayerBuildModifierAttribute : Attribute
{
private Type m_Type;
public TestPlayerBuildModifierAttribute(Type type)
{
var interfaceType = typeof(ITestPlayerBuildModifier);
if (!interfaceType.IsAssignableFrom(type))
{
throw new ArgumentException(string.Format("Type provided to {0} does not implement {1}", this.GetType().Name, interfaceType.Name));
}
m_Type = type;
}
internal ITestPlayerBuildModifier ConstructModifier()
{
return Activator.CreateInstance(m_Type) as ITestPlayerBuildModifier;
}
}
}
fileFormatVersion: 2
guid: dd57b1176859fc84e93586103d3b5f73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dd57b1176859fc84e93586103d3b5f73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment