Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework.Interfaces;
using UnityEngine.TestTools;
using UnityEngine.TestTools.NUnitExtensions;
namespace UnityEditor.TestTools.TestRunner
{
internal class TestListProvider : ITestListProvider
{
private readonly EditorLoadedTestAssemblyProvider m_AssemblyProvider;
private readonly UnityTestAssemblyBuilder m_AssemblyBuilder;
public TestListProvider(EditorLoadedTestAssemblyProvider assemblyProvider, UnityTestAssemblyBuilder assemblyBuilder)
{
m_AssemblyProvider = assemblyProvider;
m_AssemblyBuilder = assemblyBuilder;
}
public IEnumerator<ITest> GetTestListAsync(TestPlatform platform)
{
var assembliesTask = m_AssemblyProvider.GetAssembliesGroupedByTypeAsync(platform);
while (assembliesTask.MoveNext())
{
yield return null;
}
var assemblies = assembliesTask.Current.Where(pair => platform.IsFlagIncluded(pair.Key))
.SelectMany(pair => pair.Value.Select(assemblyInfo => Tuple.Create(assemblyInfo.Assembly, pair.Key))).ToArray();
var settings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(platform);
var test = m_AssemblyBuilder.BuildAsync(assemblies.Select(a => a.Item1).ToArray(), assemblies.Select(a => a.Item2).ToArray(), settings);
while (test.MoveNext())
{
yield return null;
}
yield return test.Current;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework.Interfaces;
using UnityEngine.TestTools;
using UnityEngine.TestTools.NUnitExtensions;
namespace UnityEditor.TestTools.TestRunner
{
internal class TestListProvider : ITestListProvider
{
private readonly EditorLoadedTestAssemblyProvider m_AssemblyProvider;
private readonly UnityTestAssemblyBuilder m_AssemblyBuilder;
public TestListProvider(EditorLoadedTestAssemblyProvider assemblyProvider, UnityTestAssemblyBuilder assemblyBuilder)
{
m_AssemblyProvider = assemblyProvider;
m_AssemblyBuilder = assemblyBuilder;
}
public IEnumerator<ITest> GetTestListAsync(TestPlatform platform)
{
var assembliesTask = m_AssemblyProvider.GetAssembliesGroupedByTypeAsync(platform);
while (assembliesTask.MoveNext())
{
yield return null;
}
var assemblies = assembliesTask.Current.Where(pair => platform.IsFlagIncluded(pair.Key))
.SelectMany(pair => pair.Value.Select(assemblyInfo => Tuple.Create(assemblyInfo.Assembly, pair.Key))).ToArray();
var settings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(platform);
var test = m_AssemblyBuilder.BuildAsync(assemblies.Select(a => a.Item1).ToArray(), assemblies.Select(a => a.Item2).ToArray(), settings);
while (test.MoveNext())
{
yield return null;
}
yield return test.Current;
}
}
}
fileFormatVersion: 2
guid: f15cbb987069826429540d0ea0937442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f15cbb987069826429540d0ea0937442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using UnityEditor.Callbacks;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.GUI;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner
{
[Serializable]
internal class TestRunnerWindow : EditorWindow, IHasCustomMenu
{
internal static class Styles
{
public static GUIStyle info;
public static GUIStyle testList;
static Styles()
{
info = new GUIStyle(EditorStyles.wordWrappedLabel);
info.wordWrap = false;
info.stretchHeight = true;
info.margin.right = 15;
testList = new GUIStyle("CN Box");
testList.margin.top = 0;
testList.padding.left = 3;
}
}
private readonly GUIContent m_GUIHorizontalSplit = EditorGUIUtility.TrTextContent("Horizontal layout");
private readonly GUIContent m_GUIVerticalSplit = EditorGUIUtility.TrTextContent("Vertical layout");
private readonly GUIContent m_GUIEnableaPlaymodeTestsRunner = EditorGUIUtility.TrTextContent("Enable playmode tests for all assemblies");
private readonly GUIContent m_GUIDisablePlaymodeTestsRunner = EditorGUIUtility.TrTextContent("Disable playmode tests for all assemblies");
private readonly GUIContent m_GUIRunPlayModeTestAsEditModeTests = EditorGUIUtility.TrTextContent("Run playmode tests as editmode tests");
internal static TestRunnerWindow s_Instance;
private bool m_IsBuilding;
[NonSerialized]
private bool m_Enabled;
public TestFilterSettings filterSettings;
[SerializeField]
private SplitterState m_Spl = new SplitterState(new float[] { 75, 25 }, new[] { 32, 32 }, null);
private TestRunnerWindowSettings m_Settings;
private enum TestRunnerMenuLabels
{
PlayMode = 0,
EditMode = 1
}
[SerializeField]
private int m_TestTypeToolbarIndex = (int)TestRunnerMenuLabels.EditMode;
[SerializeField]
private PlayModeTestListGUI m_PlayModeTestListGUI;
[SerializeField]
private EditModeTestListGUI m_EditModeTestListGUI;
internal TestListGUI m_SelectedTestTypes;
private ITestRunnerApi m_testRunnerApi;
private WindowResultUpdater m_WindowResultUpdater;
[MenuItem("Window/General/Test Runner", false, 201, false)]
public static void ShowPlaymodeTestsRunnerWindowCodeBased()
{
s_Instance = GetWindow<TestRunnerWindow>("Test Runner");
s_Instance.Show();
}
static TestRunnerWindow()
{
InitBackgroundRunners();
}
private static void InitBackgroundRunners()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
[DidReloadScripts]
private static void CompilationCallback()
{
UpdateWindow();
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (s_Instance && state == PlayModeStateChange.EnteredEditMode && s_Instance.m_SelectedTestTypes.HasTreeData())
{
//repaint message details after exit playmode
s_Instance.m_SelectedTestTypes.TestSelectionCallback(s_Instance.m_SelectedTestTypes.m_TestListState.selectedIDs.ToArray());
s_Instance.Repaint();
}
}
public void OnDestroy()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
}
private void OnEnable()
{
s_Instance = this;
SelectTestListGUI(m_TestTypeToolbarIndex);
m_testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
m_WindowResultUpdater = new WindowResultUpdater();
m_testRunnerApi.RegisterCallbacks(m_WindowResultUpdater);
}
private void Enable()
{
m_Settings = new TestRunnerWindowSettings("UnityEditor.PlaymodeTestsRunnerWindow");
filterSettings = new TestFilterSettings("UnityTest.IntegrationTestsRunnerWindow");
if (m_SelectedTestTypes == null)
{
SelectTestListGUI(m_TestTypeToolbarIndex);
}
StartRetrieveTestList();
m_SelectedTestTypes.Reload();
m_Enabled = true;
}
private void SelectTestListGUI(int testTypeToolbarIndex)
{
if (testTypeToolbarIndex == (int)TestRunnerMenuLabels.PlayMode)
{
if (m_PlayModeTestListGUI == null)
{
m_PlayModeTestListGUI = new PlayModeTestListGUI();
}
m_SelectedTestTypes = m_PlayModeTestListGUI;
}
else if (testTypeToolbarIndex == (int)TestRunnerMenuLabels.EditMode)
{
if (m_EditModeTestListGUI == null)
{
m_EditModeTestListGUI = new EditModeTestListGUI();
}
m_SelectedTestTypes = m_EditModeTestListGUI;
}
}
private void StartRetrieveTestList()
{
if (!m_SelectedTestTypes.HasTreeData())
{
m_testRunnerApi.RetrieveTestList(m_SelectedTestTypes.TestMode, (rootTest) =>
{
m_SelectedTestTypes.Init(this, rootTest);
m_SelectedTestTypes.Reload();
});
}
}
public void OnGUI()
{
if (!m_Enabled)
{
Enable();
}
if (BuildPipeline.isBuildingPlayer)
{
m_IsBuilding = true;
}
else if (m_IsBuilding)
{
m_IsBuilding = false;
Repaint();
}
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
var selectedIndex = m_TestTypeToolbarIndex;
m_TestTypeToolbarIndex = GUILayout.Toolbar(m_TestTypeToolbarIndex, Enum.GetNames(typeof(TestRunnerMenuLabels)), "LargeButton", UnityEngine.GUI.ToolbarButtonSize.FitToContents);
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
if (selectedIndex != m_TestTypeToolbarIndex)
{
SelectTestListGUI(m_TestTypeToolbarIndex);
StartRetrieveTestList();
}
EditorGUILayout.BeginVertical();
using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
{
m_SelectedTestTypes.PrintHeadPanel();
}
EditorGUILayout.EndVertical();
if (m_Settings.verticalSplit)
SplitterGUILayout.BeginVerticalSplit(m_Spl);
else
SplitterGUILayout.BeginHorizontalSplit(m_Spl);
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginVertical(Styles.testList);
m_SelectedTestTypes.RenderTestList();
EditorGUILayout.EndVertical();
EditorGUILayout.EndVertical();
m_SelectedTestTypes.RenderDetails();
if (m_Settings.verticalSplit)
SplitterGUILayout.EndVerticalSplit();
else
SplitterGUILayout.EndHorizontalSplit();
}
public void AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(m_GUIVerticalSplit, m_Settings.verticalSplit, m_Settings.ToggleVerticalSplit);
menu.AddItem(m_GUIHorizontalSplit, !m_Settings.verticalSplit, m_Settings.ToggleVerticalSplit);
menu.AddSeparator(null);
var playModeTestRunnerEnabled = PlayerSettings.playModeTestRunnerEnabled;
var currentActive = playModeTestRunnerEnabled ? m_GUIDisablePlaymodeTestsRunner : m_GUIEnableaPlaymodeTestsRunner;
if (EditorPrefs.GetBool("InternalMode", false))
{
menu.AddItem(m_GUIRunPlayModeTestAsEditModeTests, PlayerSettings.runPlayModeTestAsEditModeTest, () =>
{
PlayerSettings.runPlayModeTestAsEditModeTest = !PlayerSettings.runPlayModeTestAsEditModeTest;
});
}
menu.AddItem(currentActive, false, () =>
{
PlayerSettings.playModeTestRunnerEnabled = !playModeTestRunnerEnabled;
EditorUtility.DisplayDialog(currentActive.text, "You need to restart the editor now", "Ok");
});
}
public void RebuildUIFilter()
{
if (m_SelectedTestTypes != null && m_SelectedTestTypes.HasTreeData())
{
m_SelectedTestTypes.RebuildUIFilter();
}
}
public static void UpdateWindow()
{
if (s_Instance != null && s_Instance.m_SelectedTestTypes != null)
{
s_Instance.m_SelectedTestTypes.Repaint();
s_Instance.Repaint();
}
}
}
}
using System;
using UnityEditor.Callbacks;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.GUI;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner
{
[Serializable]
internal class TestRunnerWindow : EditorWindow, IHasCustomMenu
{
internal static class Styles
{
public static GUIStyle info;
public static GUIStyle testList;
static Styles()
{
info = new GUIStyle(EditorStyles.wordWrappedLabel);
info.wordWrap = false;
info.stretchHeight = true;
info.margin.right = 15;
testList = new GUIStyle("CN Box");
testList.margin.top = 0;
testList.padding.left = 3;
}
}
private readonly GUIContent m_GUIHorizontalSplit = EditorGUIUtility.TrTextContent("Horizontal layout");
private readonly GUIContent m_GUIVerticalSplit = EditorGUIUtility.TrTextContent("Vertical layout");
private readonly GUIContent m_GUIEnableaPlaymodeTestsRunner = EditorGUIUtility.TrTextContent("Enable playmode tests for all assemblies");
private readonly GUIContent m_GUIDisablePlaymodeTestsRunner = EditorGUIUtility.TrTextContent("Disable playmode tests for all assemblies");
private readonly GUIContent m_GUIRunPlayModeTestAsEditModeTests = EditorGUIUtility.TrTextContent("Run playmode tests as editmode tests");
internal static TestRunnerWindow s_Instance;
private bool m_IsBuilding;
[NonSerialized]
private bool m_Enabled;
public TestFilterSettings filterSettings;
[SerializeField]
private SplitterState m_Spl = new SplitterState(new float[] { 75, 25 }, new[] { 32, 32 }, null);
private TestRunnerWindowSettings m_Settings;
private enum TestRunnerMenuLabels
{
PlayMode = 0,
EditMode = 1
}
[SerializeField]
private int m_TestTypeToolbarIndex = (int)TestRunnerMenuLabels.EditMode;
[SerializeField]
private PlayModeTestListGUI m_PlayModeTestListGUI;
[SerializeField]
private EditModeTestListGUI m_EditModeTestListGUI;
internal TestListGUI m_SelectedTestTypes;
private ITestRunnerApi m_testRunnerApi;
private WindowResultUpdater m_WindowResultUpdater;
[MenuItem("Window/General/Test Runner", false, 201, false)]
public static void ShowPlaymodeTestsRunnerWindowCodeBased()
{
s_Instance = GetWindow<TestRunnerWindow>("Test Runner");
s_Instance.Show();
}
static TestRunnerWindow()
{
InitBackgroundRunners();
}
private static void InitBackgroundRunners()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
[DidReloadScripts]
private static void CompilationCallback()
{
UpdateWindow();
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (s_Instance && state == PlayModeStateChange.EnteredEditMode && s_Instance.m_SelectedTestTypes.HasTreeData())
{
//repaint message details after exit playmode
s_Instance.m_SelectedTestTypes.TestSelectionCallback(s_Instance.m_SelectedTestTypes.m_TestListState.selectedIDs.ToArray());
s_Instance.Repaint();
}
}
public void OnDestroy()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
}
private void OnEnable()
{
s_Instance = this;
SelectTestListGUI(m_TestTypeToolbarIndex);
m_testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
m_WindowResultUpdater = new WindowResultUpdater();
m_testRunnerApi.RegisterCallbacks(m_WindowResultUpdater);
}
private void Enable()
{
m_Settings = new TestRunnerWindowSettings("UnityEditor.PlaymodeTestsRunnerWindow");
filterSettings = new TestFilterSettings("UnityTest.IntegrationTestsRunnerWindow");
if (m_SelectedTestTypes == null)
{
SelectTestListGUI(m_TestTypeToolbarIndex);
}
StartRetrieveTestList();
m_SelectedTestTypes.Reload();
m_Enabled = true;
}
private void SelectTestListGUI(int testTypeToolbarIndex)
{
if (testTypeToolbarIndex == (int)TestRunnerMenuLabels.PlayMode)
{
if (m_PlayModeTestListGUI == null)
{
m_PlayModeTestListGUI = new PlayModeTestListGUI();
}
m_SelectedTestTypes = m_PlayModeTestListGUI;
}
else if (testTypeToolbarIndex == (int)TestRunnerMenuLabels.EditMode)
{
if (m_EditModeTestListGUI == null)
{
m_EditModeTestListGUI = new EditModeTestListGUI();
}
m_SelectedTestTypes = m_EditModeTestListGUI;
}
}
private void StartRetrieveTestList()
{
if (!m_SelectedTestTypes.HasTreeData())
{
m_testRunnerApi.RetrieveTestList(m_SelectedTestTypes.TestMode, (rootTest) =>
{
m_SelectedTestTypes.Init(this, rootTest);
m_SelectedTestTypes.Reload();
});
}
}
public void OnGUI()
{
if (!m_Enabled)
{
Enable();
}
if (BuildPipeline.isBuildingPlayer)
{
m_IsBuilding = true;
}
else if (m_IsBuilding)
{
m_IsBuilding = false;
Repaint();
}
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
var selectedIndex = m_TestTypeToolbarIndex;
m_TestTypeToolbarIndex = GUILayout.Toolbar(m_TestTypeToolbarIndex, Enum.GetNames(typeof(TestRunnerMenuLabels)), "LargeButton", UnityEngine.GUI.ToolbarButtonSize.FitToContents);
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
if (selectedIndex != m_TestTypeToolbarIndex)
{
SelectTestListGUI(m_TestTypeToolbarIndex);
StartRetrieveTestList();
}
EditorGUILayout.BeginVertical();
using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
{
m_SelectedTestTypes.PrintHeadPanel();
}
EditorGUILayout.EndVertical();
if (m_Settings.verticalSplit)
SplitterGUILayout.BeginVerticalSplit(m_Spl);
else
SplitterGUILayout.BeginHorizontalSplit(m_Spl);
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginVertical(Styles.testList);
m_SelectedTestTypes.RenderTestList();
EditorGUILayout.EndVertical();
EditorGUILayout.EndVertical();
m_SelectedTestTypes.RenderDetails();
if (m_Settings.verticalSplit)
SplitterGUILayout.EndVerticalSplit();
else
SplitterGUILayout.EndHorizontalSplit();
}
public void AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(m_GUIVerticalSplit, m_Settings.verticalSplit, m_Settings.ToggleVerticalSplit);
menu.AddItem(m_GUIHorizontalSplit, !m_Settings.verticalSplit, m_Settings.ToggleVerticalSplit);
menu.AddSeparator(null);
var playModeTestRunnerEnabled = PlayerSettings.playModeTestRunnerEnabled;
var currentActive = playModeTestRunnerEnabled ? m_GUIDisablePlaymodeTestsRunner : m_GUIEnableaPlaymodeTestsRunner;
if (EditorPrefs.GetBool("InternalMode", false))
{
menu.AddItem(m_GUIRunPlayModeTestAsEditModeTests, PlayerSettings.runPlayModeTestAsEditModeTest, () =>
{
PlayerSettings.runPlayModeTestAsEditModeTest = !PlayerSettings.runPlayModeTestAsEditModeTest;
});
}
menu.AddItem(currentActive, false, () =>
{
PlayerSettings.playModeTestRunnerEnabled = !playModeTestRunnerEnabled;
EditorUtility.DisplayDialog(currentActive.text, "You need to restart the editor now", "Ok");
});
}
public void RebuildUIFilter()
{
if (m_SelectedTestTypes != null && m_SelectedTestTypes.HasTreeData())
{
m_SelectedTestTypes.RebuildUIFilter();
}
}
public static void UpdateWindow()
{
if (s_Instance != null && s_Instance.m_SelectedTestTypes != null)
{
s_Instance.m_SelectedTestTypes.Repaint();
s_Instance.Repaint();
}
}
}
}
fileFormatVersion: 2
guid: 4dfcd3a631f61d248b7cc0b845d40345
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 4dfcd3a631f61d248b7cc0b845d40345
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools.TestRunner
{
internal class TestRunnerWindowSettings
{
public bool verticalSplit;
private readonly string m_PrefsKey;
public TestRunnerWindowSettings(string prefsKey)
{
m_PrefsKey = prefsKey;
verticalSplit = EditorPrefs.GetBool(m_PrefsKey + ".verticalSplit", true);
}
public void ToggleVerticalSplit()
{
verticalSplit = !verticalSplit;
Save();
}
private void Save()
{
EditorPrefs.SetBool(m_PrefsKey + ".verticalSplit", verticalSplit);
}
}
}
namespace UnityEditor.TestTools.TestRunner
{
internal class TestRunnerWindowSettings
{
public bool verticalSplit;
private readonly string m_PrefsKey;
public TestRunnerWindowSettings(string prefsKey)
{
m_PrefsKey = prefsKey;
verticalSplit = EditorPrefs.GetBool(m_PrefsKey + ".verticalSplit", true);
}
public void ToggleVerticalSplit()
{
verticalSplit = !verticalSplit;
Save();
}
private void Save()
{
EditorPrefs.SetBool(m_PrefsKey + ".verticalSplit", verticalSplit);
}
}
}
fileFormatVersion: 2
guid: 2b301b727225f1941974d69e61a55620
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2b301b727225f1941974d69e61a55620
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 95b719082a664ea45bb56759eed1f271
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 95b719082a664ea45bb56759eed1f271
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
namespace UnityEditor.TestTools.TestRunner
{
internal interface ITestSettings : IDisposable
{
ScriptingImplementation? scriptingBackend { get; set; }
string Architecture { get; set; }
ApiCompatibilityLevel? apiProfile { get; set; }
bool? appleEnableAutomaticSigning { get; set; }
string appleDeveloperTeamID { get; set; }
ProvisioningProfileType? iOSManualProvisioningProfileType { get; set; }
string iOSManualProvisioningProfileID { get; set; }
ProvisioningProfileType? tvOSManualProvisioningProfileType { get; set; }
string tvOSManualProvisioningProfileID { get; set; }
void SetupProjectParameters();
}
}
using System;
namespace UnityEditor.TestTools.TestRunner
{
internal interface ITestSettings : IDisposable
{
ScriptingImplementation? scriptingBackend { get; set; }
string Architecture { get; set; }
ApiCompatibilityLevel? apiProfile { get; set; }
bool? appleEnableAutomaticSigning { get; set; }
string appleDeveloperTeamID { get; set; }
ProvisioningProfileType? iOSManualProvisioningProfileType { get; set; }
string iOSManualProvisioningProfileID { get; set; }
ProvisioningProfileType? tvOSManualProvisioningProfileType { get; set; }
string tvOSManualProvisioningProfileID { get; set; }
void SetupProjectParameters();
}
}
fileFormatVersion: 2
guid: 83eda34b7da01e04aa894f268158b0c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 83eda34b7da01e04aa894f268158b0c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools.TestRunner
{
interface ITestSettingsDeserializer
{
ITestSettings GetSettingsFromJsonFile(string jsonFilePath);
}
}
namespace UnityEditor.TestTools.TestRunner
{
interface ITestSettingsDeserializer
{
ITestSettings GetSettingsFromJsonFile(string jsonFilePath);
}
}
fileFormatVersion: 2
guid: d208a1684f8aa6a40ad91d6aa9600c14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d208a1684f8aa6a40ad91d6aa9600c14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
namespace UnityEditor.TestTools.TestRunner
{
internal class TestSettings : ITestSettings
{
private readonly TestSetting[] m_Settings =
{
new TestSetting<ScriptingImplementation?>(
settings => settings.scriptingBackend,
() => PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.activeBuildTargetGroup),
implementation => PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.activeBuildTargetGroup, implementation.Value)),
new TestSetting<string>(
settings => settings.Architecture,
() => EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ? PlayerSettings.Android.targetArchitectures.ToString() : null,
architecture =>
{
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
{
if (!string.IsNullOrEmpty(architecture))
{
var targetArchitectures = (AndroidArchitecture)Enum.Parse(typeof(AndroidArchitecture), architecture, true);
PlayerSettings.Android.targetArchitectures = targetArchitectures;
}
}
}),
new TestSetting<ApiCompatibilityLevel?>(
settings => settings.apiProfile,
() => PlayerSettings.GetApiCompatibilityLevel(EditorUserBuildSettings.activeBuildTargetGroup),
implementation =>
{
if (Enum.IsDefined(typeof(ApiCompatibilityLevel), implementation.Value))
{
PlayerSettings.SetApiCompatibilityLevel(EditorUserBuildSettings.activeBuildTargetGroup,
implementation.Value);
}
}),
new TestSetting<bool?>(
settings => settings.appleEnableAutomaticSigning,
() => PlayerSettings.iOS.appleEnableAutomaticSigning,
enableAutomaticSigning =>
{
if (enableAutomaticSigning != null)
PlayerSettings.iOS.appleEnableAutomaticSigning = enableAutomaticSigning.Value;
}),
new TestSetting<string>(
settings => settings.appleDeveloperTeamID,
() => PlayerSettings.iOS.appleDeveloperTeamID,
developerTeam =>
{
if (developerTeam != null)
PlayerSettings.iOS.appleDeveloperTeamID = developerTeam;
}),
new TestSetting<ProvisioningProfileType?>(
settings => settings.iOSManualProvisioningProfileType,
() => PlayerSettings.iOS.iOSManualProvisioningProfileType,
profileType =>
{
if (profileType != null)
PlayerSettings.iOS.iOSManualProvisioningProfileType = profileType.Value;
}),
new TestSetting<string>(
settings => settings.iOSManualProvisioningProfileID,
() => PlayerSettings.iOS.iOSManualProvisioningProfileID,
provisioningUUID =>
{
if (provisioningUUID != null)
PlayerSettings.iOS.iOSManualProvisioningProfileID = provisioningUUID;
}),
new TestSetting<ProvisioningProfileType?>(
settings => settings.tvOSManualProvisioningProfileType,
() => PlayerSettings.iOS.tvOSManualProvisioningProfileType,
profileType =>
{
if (profileType != null)
PlayerSettings.iOS.tvOSManualProvisioningProfileType = profileType.Value;
}),
new TestSetting<string>(
settings => settings.tvOSManualProvisioningProfileID,
() => PlayerSettings.iOS.tvOSManualProvisioningProfileID,
provisioningUUID =>
{
if (provisioningUUID != null)
PlayerSettings.iOS.tvOSManualProvisioningProfileID = provisioningUUID;
}),
};
private bool m_Disposed;
public ScriptingImplementation? scriptingBackend { get; set; }
public string Architecture { get; set; }
public ApiCompatibilityLevel? apiProfile { get; set; }
public bool? appleEnableAutomaticSigning { get; set; }
public string appleDeveloperTeamID { get; set; }
public ProvisioningProfileType? iOSManualProvisioningProfileType { get; set; }
public string iOSManualProvisioningProfileID { get; set; }
public ProvisioningProfileType? tvOSManualProvisioningProfileType { get; set; }
public string tvOSManualProvisioningProfileID { get; set; }
public void Dispose()
{
if (!m_Disposed)
{
foreach (var testSetting in m_Settings)
{
testSetting.Cleanup();
}
m_Disposed = true;
}
}
public void SetupProjectParameters()
{
foreach (var testSetting in m_Settings)
{
testSetting.Setup(this);
}
}
private abstract class TestSetting
{
public abstract void Setup(TestSettings settings);
public abstract void Cleanup();
}
private class TestSetting<T> : TestSetting
{
private T m_ValueBeforeSetup;
private Func<TestSettings, T> m_GetFromSettings;
private Func<T> m_GetCurrentValue;
private Action<T> m_SetValue;
public TestSetting(Func<TestSettings, T> getFromSettings, Func<T> getCurrentValue, Action<T> setValue)
{
m_GetFromSettings = getFromSettings;
m_GetCurrentValue = getCurrentValue;
m_SetValue = setValue;
}
public override void Setup(TestSettings settings)
{
m_ValueBeforeSetup = m_GetCurrentValue();
var newValue = m_GetFromSettings(settings);
if (newValue != null)
{
m_SetValue(newValue);
}
}
public override void Cleanup()
{
m_SetValue(m_ValueBeforeSetup);
}
}
}
}
using System;
namespace UnityEditor.TestTools.TestRunner
{
internal class TestSettings : ITestSettings
{
private readonly TestSetting[] m_Settings =
{
new TestSetting<ScriptingImplementation?>(
settings => settings.scriptingBackend,
() => PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.activeBuildTargetGroup),
implementation => PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.activeBuildTargetGroup, implementation.Value)),
new TestSetting<string>(
settings => settings.Architecture,
() => EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ? PlayerSettings.Android.targetArchitectures.ToString() : null,
architecture =>
{
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
{
if (!string.IsNullOrEmpty(architecture))
{
var targetArchitectures = (AndroidArchitecture)Enum.Parse(typeof(AndroidArchitecture), architecture, true);
PlayerSettings.Android.targetArchitectures = targetArchitectures;
}
}
}),
new TestSetting<ApiCompatibilityLevel?>(
settings => settings.apiProfile,
() => PlayerSettings.GetApiCompatibilityLevel(EditorUserBuildSettings.activeBuildTargetGroup),
implementation =>
{
if (Enum.IsDefined(typeof(ApiCompatibilityLevel), implementation.Value))
{
PlayerSettings.SetApiCompatibilityLevel(EditorUserBuildSettings.activeBuildTargetGroup,
implementation.Value);
}
}),
new TestSetting<bool?>(
settings => settings.appleEnableAutomaticSigning,
() => PlayerSettings.iOS.appleEnableAutomaticSigning,
enableAutomaticSigning =>
{
if (enableAutomaticSigning != null)
PlayerSettings.iOS.appleEnableAutomaticSigning = enableAutomaticSigning.Value;
}),
new TestSetting<string>(
settings => settings.appleDeveloperTeamID,
() => PlayerSettings.iOS.appleDeveloperTeamID,
developerTeam =>
{
if (developerTeam != null)
PlayerSettings.iOS.appleDeveloperTeamID = developerTeam;
}),
new TestSetting<ProvisioningProfileType?>(
settings => settings.iOSManualProvisioningProfileType,
() => PlayerSettings.iOS.iOSManualProvisioningProfileType,
profileType =>
{
if (profileType != null)
PlayerSettings.iOS.iOSManualProvisioningProfileType = profileType.Value;
}),
new TestSetting<string>(
settings => settings.iOSManualProvisioningProfileID,
() => PlayerSettings.iOS.iOSManualProvisioningProfileID,
provisioningUUID =>
{
if (provisioningUUID != null)
PlayerSettings.iOS.iOSManualProvisioningProfileID = provisioningUUID;
}),
new TestSetting<ProvisioningProfileType?>(
settings => settings.tvOSManualProvisioningProfileType,
() => PlayerSettings.iOS.tvOSManualProvisioningProfileType,
profileType =>
{
if (profileType != null)
PlayerSettings.iOS.tvOSManualProvisioningProfileType = profileType.Value;
}),
new TestSetting<string>(
settings => settings.tvOSManualProvisioningProfileID,
() => PlayerSettings.iOS.tvOSManualProvisioningProfileID,
provisioningUUID =>
{
if (provisioningUUID != null)
PlayerSettings.iOS.tvOSManualProvisioningProfileID = provisioningUUID;
}),
};
private bool m_Disposed;
public ScriptingImplementation? scriptingBackend { get; set; }
public string Architecture { get; set; }
public ApiCompatibilityLevel? apiProfile { get; set; }
public bool? appleEnableAutomaticSigning { get; set; }
public string appleDeveloperTeamID { get; set; }
public ProvisioningProfileType? iOSManualProvisioningProfileType { get; set; }
public string iOSManualProvisioningProfileID { get; set; }
public ProvisioningProfileType? tvOSManualProvisioningProfileType { get; set; }
public string tvOSManualProvisioningProfileID { get; set; }
public void Dispose()
{
if (!m_Disposed)
{
foreach (var testSetting in m_Settings)
{
testSetting.Cleanup();
}
m_Disposed = true;
}
}
public void SetupProjectParameters()
{
foreach (var testSetting in m_Settings)
{
testSetting.Setup(this);
}
}
private abstract class TestSetting
{
public abstract void Setup(TestSettings settings);
public abstract void Cleanup();
}
private class TestSetting<T> : TestSetting
{
private T m_ValueBeforeSetup;
private Func<TestSettings, T> m_GetFromSettings;
private Func<T> m_GetCurrentValue;
private Action<T> m_SetValue;
public TestSetting(Func<TestSettings, T> getFromSettings, Func<T> getCurrentValue, Action<T> setValue)
{
m_GetFromSettings = getFromSettings;
m_GetCurrentValue = getCurrentValue;
m_SetValue = setValue;
}
public override void Setup(TestSettings settings)
{
m_ValueBeforeSetup = m_GetCurrentValue();
var newValue = m_GetFromSettings(settings);
if (newValue != null)
{
m_SetValue(newValue);
}
}
public override void Cleanup()
{
m_SetValue(m_ValueBeforeSetup);
}
}
}
}
fileFormatVersion: 2
guid: 6b32b6725087a0d4bb1670818d26996e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6b32b6725087a0d4bb1670818d26996e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner
{
/// <summary>
/// Handles deserialization of TestSettings from a provided json file path.
/// </summary>
internal class TestSettingsDeserializer : ITestSettingsDeserializer
{
private static readonly SettingsMap[] s_SettingsMapping =
{
new SettingsMap<ScriptingImplementation>("scriptingBackend", (settings, value) => settings.scriptingBackend = value),
new SettingsMap<string>("architecture", (settings, value) => settings.Architecture = value),
new SettingsMap<ApiCompatibilityLevel>("apiProfile", (settings, value) => settings.apiProfile = value),
new SettingsMap<bool>("appleEnableAutomaticSigning", (settings, value) => settings.appleEnableAutomaticSigning = value),
new SettingsMap<string>("appleDeveloperTeamID", (settings, value) => settings.appleDeveloperTeamID = value),
new SettingsMap<ProvisioningProfileType>("iOSManualProvisioningProfileType", (settings, value) => settings.iOSManualProvisioningProfileType = value),
new SettingsMap<string>("iOSManualProvisioningProfileID", (settings, value) => settings.iOSManualProvisioningProfileID = value),
new SettingsMap<ProvisioningProfileType>("tvOSManualProvisioningProfileType", (settings, value) => settings.tvOSManualProvisioningProfileType = value),
new SettingsMap<string>("tvOSManualProvisioningProfileID", (settings, value) => settings.tvOSManualProvisioningProfileID = value),
};
private readonly Func<ITestSettings> m_TestSettingsFactory;
public TestSettingsDeserializer(Func<ITestSettings> testSettingsFactory)
{
m_TestSettingsFactory = testSettingsFactory;
}
public ITestSettings GetSettingsFromJsonFile(string jsonFilePath)
{
var text = File.ReadAllText(jsonFilePath);
var settingsDictionary = Json.Deserialize(text) as Dictionary<string, object>;
var testSettings = m_TestSettingsFactory();
if (settingsDictionary == null)
{
return testSettings;
}
foreach (var settingsMap in s_SettingsMapping)
{
if (!settingsDictionary.ContainsKey(settingsMap.Key))
{
continue;
}
if (settingsMap.Type.IsEnum)
{
SetEnumValue(settingsMap.Key, settingsDictionary[settingsMap.Key], settingsMap.Type, value => settingsMap.ApplyToSettings(testSettings, value));
}
else
{
SetValue(settingsMap.Key, settingsDictionary[settingsMap.Key], settingsMap.Type, value => settingsMap.ApplyToSettings(testSettings, value));
}
}
return testSettings;
}
private abstract class SettingsMap
{
public string Key { get; }
public Type Type { get; }
protected SettingsMap(string key, Type type)
{
Key = key;
Type = type;
}
public abstract void ApplyToSettings(ITestSettings settings, object value);
}
private class SettingsMap<T> : SettingsMap
{
private Action<ITestSettings, T> m_Setter;
public SettingsMap(string key, Action<ITestSettings, T> setter) : base(key, typeof(T))
{
m_Setter = setter;
}
public override void ApplyToSettings(ITestSettings settings, object value)
{
m_Setter(settings, (T)value);
}
}
private static void SetEnumValue(string key, object value, Type type, Action<object> setter)
{
object enumValue;
if (TryGetEnum(value as string, type, out enumValue))
{
setter(enumValue);
return;
}
var acceptedValues = string.Join(", ", Enum.GetValues(type).OfType<object>().Select(val => val.ToString()).ToArray());
Debug.LogFormat("Could not convert '{0}' argument '{1}' to a valid {2}. Accepted values: {3}.", key, value, type.Name, acceptedValues);
}
private static bool TryGetEnum(string value, Type type, out object enumValue)
{
try
{
enumValue = Enum.Parse(type, value, true);
return true;
}
catch (Exception)
{
enumValue = null;
return false;
}
}
private static void SetValue(string key, object value, Type type, Action<object> setter)
{
if (type.IsInstanceOfType(value))
{
setter(value);
return;
}
Debug.LogFormat("Could not convert '{0}' argument '{1}' to a valid {2}.", key, value, type.Name);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner
{
/// <summary>
/// Handles deserialization of TestSettings from a provided json file path.
/// </summary>
internal class TestSettingsDeserializer : ITestSettingsDeserializer
{
private static readonly SettingsMap[] s_SettingsMapping =
{
new SettingsMap<ScriptingImplementation>("scriptingBackend", (settings, value) => settings.scriptingBackend = value),
new SettingsMap<string>("architecture", (settings, value) => settings.Architecture = value),
new SettingsMap<ApiCompatibilityLevel>("apiProfile", (settings, value) => settings.apiProfile = value),
new SettingsMap<bool>("appleEnableAutomaticSigning", (settings, value) => settings.appleEnableAutomaticSigning = value),
new SettingsMap<string>("appleDeveloperTeamID", (settings, value) => settings.appleDeveloperTeamID = value),
new SettingsMap<ProvisioningProfileType>("iOSManualProvisioningProfileType", (settings, value) => settings.iOSManualProvisioningProfileType = value),
new SettingsMap<string>("iOSManualProvisioningProfileID", (settings, value) => settings.iOSManualProvisioningProfileID = value),
new SettingsMap<ProvisioningProfileType>("tvOSManualProvisioningProfileType", (settings, value) => settings.tvOSManualProvisioningProfileType = value),
new SettingsMap<string>("tvOSManualProvisioningProfileID", (settings, value) => settings.tvOSManualProvisioningProfileID = value),
};
private readonly Func<ITestSettings> m_TestSettingsFactory;
public TestSettingsDeserializer(Func<ITestSettings> testSettingsFactory)
{
m_TestSettingsFactory = testSettingsFactory;
}
public ITestSettings GetSettingsFromJsonFile(string jsonFilePath)
{
var text = File.ReadAllText(jsonFilePath);
var settingsDictionary = Json.Deserialize(text) as Dictionary<string, object>;
var testSettings = m_TestSettingsFactory();
if (settingsDictionary == null)
{
return testSettings;
}
foreach (var settingsMap in s_SettingsMapping)
{
if (!settingsDictionary.ContainsKey(settingsMap.Key))
{
continue;
}
if (settingsMap.Type.IsEnum)
{
SetEnumValue(settingsMap.Key, settingsDictionary[settingsMap.Key], settingsMap.Type, value => settingsMap.ApplyToSettings(testSettings, value));
}
else
{
SetValue(settingsMap.Key, settingsDictionary[settingsMap.Key], settingsMap.Type, value => settingsMap.ApplyToSettings(testSettings, value));
}
}
return testSettings;
}
private abstract class SettingsMap
{
public string Key { get; }
public Type Type { get; }
protected SettingsMap(string key, Type type)
{
Key = key;
Type = type;
}
public abstract void ApplyToSettings(ITestSettings settings, object value);
}
private class SettingsMap<T> : SettingsMap
{
private Action<ITestSettings, T> m_Setter;
public SettingsMap(string key, Action<ITestSettings, T> setter) : base(key, typeof(T))
{
m_Setter = setter;
}
public override void ApplyToSettings(ITestSettings settings, object value)
{
m_Setter(settings, (T)value);
}
}
private static void SetEnumValue(string key, object value, Type type, Action<object> setter)
{
object enumValue;
if (TryGetEnum(value as string, type, out enumValue))
{
setter(enumValue);
return;
}
var acceptedValues = string.Join(", ", Enum.GetValues(type).OfType<object>().Select(val => val.ToString()).ToArray());
Debug.LogFormat("Could not convert '{0}' argument '{1}' to a valid {2}. Accepted values: {3}.", key, value, type.Name, acceptedValues);
}
private static bool TryGetEnum(string value, Type type, out object enumValue)
{
try
{
enumValue = Enum.Parse(type, value, true);
return true;
}
catch (Exception)
{
enumValue = null;
return false;
}
}
private static void SetValue(string key, object value, Type type, Action<object> setter)
{
if (type.IsInstanceOfType(value))
{
setter(value);
return;
}
Debug.LogFormat("Could not convert '{0}' argument '{1}' to a valid {2}.", key, value, type.Name);
}
}
}
fileFormatVersion: 2
guid: 75e7d7a9a57458841a85fe42d9c9141f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 75e7d7a9a57458841a85fe42d9c9141f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "UnityEditor.TestRunner",
"references": [
"UnityEngine.TestRunner"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"Mono.Cecil.dll",
"Mono.Cecil.Pdb.dll",
"Mono.Cecil.Mdb.dll",
"Mono.Cecil.Rocks.dll"
],
"autoReferenced": false,
"defineConstraints": []
{
"name": "UnityEditor.TestRunner",
"references": [
"UnityEngine.TestRunner"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"Mono.Cecil.dll",
"Mono.Cecil.Pdb.dll",
"Mono.Cecil.Mdb.dll",
"Mono.Cecil.Rocks.dll"
],
"autoReferenced": false,
"defineConstraints": []
}
\ No newline at end of file
fileFormatVersion: 2
guid: 0acc523941302664db1f4e527237feb3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0acc523941302664db1f4e527237feb3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 936c6340f3468444ebb1785b4c311126
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 936c6340f3468444ebb1785b4c311126
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class AssemblyCompilationErrorsMessage : Message
{
public string assembly;
public string[] errors;
public AssemblyCompilationErrorsMessage()
{
type = "AssemblyCompilationErrors";
}
}
}
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class AssemblyCompilationErrorsMessage : Message
{
public string assembly;
public string[] errors;
public AssemblyCompilationErrorsMessage()
{
type = "AssemblyCompilationErrors";
}
}
}
fileFormatVersion: 2
guid: c346a7445959bba46a96de0747e77c2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c346a7445959bba46a96de0747e77c2a
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