initial project folder
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51557afa652635743b264a309f0a5c60
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal class AssemblyLoadProxy : IAssemblyLoadProxy
|
||||
{
|
||||
public IAssemblyWrapper Load(string assemblyString)
|
||||
{
|
||||
return new AssemblyWrapper(Assembly.Load(assemblyString));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb593906b7b6d824087dcaebf6c082e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal class AssemblyWrapper : IAssemblyWrapper
|
||||
{
|
||||
public AssemblyWrapper(Assembly assembly)
|
||||
{
|
||||
Assembly = assembly;
|
||||
}
|
||||
|
||||
public Assembly Assembly { get; }
|
||||
|
||||
public virtual string Location
|
||||
{
|
||||
get
|
||||
{
|
||||
//Some platforms dont support this
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual AssemblyName[] GetReferencedAssemblies()
|
||||
{
|
||||
//Some platforms dont support this
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e3b9bbf2c1a3cd4f88883ca32882ec6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal interface IAssemblyLoadProxy
|
||||
{
|
||||
IAssemblyWrapper Load(string assemblyString);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12dfd4bdbb5c8e6419432fbc54ef25d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal interface IAssemblyWrapper
|
||||
{
|
||||
Assembly Assembly { get; }
|
||||
string Location { get; }
|
||||
AssemblyName[] GetReferencedAssemblies();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c5afe945b715e149a70113a4be7b32a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal interface IScriptingRuntimeProxy
|
||||
{
|
||||
string[] GetAllUserAssemblies();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe4aef60e4ace544c8430da8ef8acba2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
using NUnit.Framework.Interfaces;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal interface ITestAssemblyProvider
|
||||
{
|
||||
ITest GetTestsWithNUnit();
|
||||
IAssemblyWrapper[] GetUserAssemblies();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5acba6181d845c4e92146009bd4480f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using UnityEngine.TestTools.NUnitExtensions;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal class PlayerTestAssemblyProvider
|
||||
{
|
||||
private IAssemblyLoadProxy m_AssemblyLoadProxy;
|
||||
private readonly List<string> m_AssembliesToLoad;
|
||||
|
||||
//Cached until domain reload
|
||||
private static List<IAssemblyWrapper> m_LoadedAssemblies;
|
||||
|
||||
internal PlayerTestAssemblyProvider(IAssemblyLoadProxy assemblyLoadProxy, List<string> assembliesToLoad)
|
||||
{
|
||||
m_AssemblyLoadProxy = assemblyLoadProxy;
|
||||
m_AssembliesToLoad = assembliesToLoad;
|
||||
LoadAssemblies();
|
||||
}
|
||||
|
||||
public ITest GetTestsWithNUnit()
|
||||
{
|
||||
return BuildTests(TestPlatform.PlayMode, m_LoadedAssemblies.ToArray());
|
||||
}
|
||||
|
||||
public List<IAssemblyWrapper> GetUserAssemblies()
|
||||
{
|
||||
return m_LoadedAssemblies;
|
||||
}
|
||||
|
||||
protected static ITest BuildTests(TestPlatform testPlatform, IAssemblyWrapper[] assemblies)
|
||||
{
|
||||
var settings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(testPlatform);
|
||||
var builder = new UnityTestAssemblyBuilder();
|
||||
return builder.Build(assemblies.Select(a => a.Assembly).ToArray(), settings);
|
||||
}
|
||||
|
||||
private void LoadAssemblies()
|
||||
{
|
||||
if (m_LoadedAssemblies != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_LoadedAssemblies = new List<IAssemblyWrapper>();
|
||||
|
||||
foreach (var userAssembly in m_AssembliesToLoad)
|
||||
{
|
||||
IAssemblyWrapper a;
|
||||
try
|
||||
{
|
||||
a = m_AssemblyLoadProxy.Load(userAssembly);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (a != null)
|
||||
m_LoadedAssemblies.Add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43a3aec217baa9644a7cf34b5f93fed9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal class ScriptingRuntimeProxy : IScriptingRuntimeProxy
|
||||
{
|
||||
public string[] GetAllUserAssemblies()
|
||||
{
|
||||
return ScriptingRuntime.GetAllUserAssemblies();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3a361a6ad1aff14ba8f48976e94ad76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
internal static class AttributeHelper
|
||||
{
|
||||
internal static Type GetTargetClassFromName(string targetClassName, Type attributeInterface)
|
||||
{
|
||||
Type targetClass = null;
|
||||
foreach (var assemblyName in ScriptingRuntime.GetAllUserAssemblies())
|
||||
{
|
||||
// we need to pass the assembly name without the .dll extension, so removing that first
|
||||
var name = Path.GetFileNameWithoutExtension(assemblyName);
|
||||
targetClass = Type.GetType(targetClassName + "," + name);
|
||||
if (targetClass != null)
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetClass == null)
|
||||
{
|
||||
Debug.LogWarningFormat("Class type not found: " + targetClassName);
|
||||
return null;
|
||||
}
|
||||
|
||||
ValidateTargetClass(targetClass, attributeInterface);
|
||||
return targetClass;
|
||||
}
|
||||
|
||||
private static void ValidateTargetClass(Type targetClass, Type attributeInterface)
|
||||
{
|
||||
var constructorInfos = targetClass.GetConstructors();
|
||||
if (constructorInfos.All(constructor => constructor.GetParameters().Length != 0))
|
||||
{
|
||||
Debug.LogWarningFormat("{0} does not implement default constructor", targetClass.Name);
|
||||
}
|
||||
|
||||
if (!attributeInterface.IsAssignableFrom(targetClass))
|
||||
{
|
||||
Debug.LogWarningFormat("{0} does not implement {1}", targetClass.Name, attributeInterface.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae8ce3ffe04ac2c42945fd27e0291fc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class ColorEqualityComparer : IEqualityComparer<Color>
|
||||
{
|
||||
private const float k_DefaultError = 0.01f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
|
||||
private static readonly ColorEqualityComparer m_Instance = new ColorEqualityComparer();
|
||||
public static ColorEqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
private ColorEqualityComparer() : this(k_DefaultError)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorEqualityComparer(float error)
|
||||
{
|
||||
this.AllowedError = error;
|
||||
}
|
||||
|
||||
public bool Equals(Color expected, Color actual)
|
||||
{
|
||||
return Utils.AreFloatsEqualAbsoluteError(expected.r, actual.r, AllowedError) &&
|
||||
Utils.AreFloatsEqualAbsoluteError(expected.g, actual.g, AllowedError) &&
|
||||
Utils.AreFloatsEqualAbsoluteError(expected.b, actual.b, AllowedError) &&
|
||||
Utils.AreFloatsEqualAbsoluteError(expected.a, actual.a, AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(Color color)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6105bc8cf5ce544487daca4cbc62583
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NUnit.Framework.Internal;
|
||||
using UnityEngine.TestRunner.NUnitExtensions.Runner;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal class CoroutineRunner
|
||||
{
|
||||
private bool m_Running;
|
||||
private bool m_TestFailed;
|
||||
private bool m_Timeout;
|
||||
private readonly MonoBehaviour m_Controller;
|
||||
private readonly UnityTestExecutionContext m_Context;
|
||||
private Coroutine m_TimeOutCoroutine;
|
||||
private IEnumerator m_TestCoroutine;
|
||||
|
||||
internal const int k_DefaultTimeout = 1000 * 180;
|
||||
|
||||
public CoroutineRunner(MonoBehaviour playmodeTestsController, UnityTestExecutionContext context)
|
||||
{
|
||||
m_Controller = playmodeTestsController;
|
||||
m_Context = context;
|
||||
}
|
||||
|
||||
public IEnumerator HandleEnumerableTest(IEnumerator testEnumerator)
|
||||
{
|
||||
if (m_Context.TestCaseTimeout == 0)
|
||||
{
|
||||
m_Context.TestCaseTimeout = k_DefaultTimeout;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (!m_Running)
|
||||
{
|
||||
m_Running = true;
|
||||
m_TestCoroutine = ExMethod(testEnumerator, m_Context.TestCaseTimeout);
|
||||
m_Controller.StartCoroutine(m_TestCoroutine);
|
||||
}
|
||||
if (m_TestFailed)
|
||||
{
|
||||
StopAllRunningCoroutines();
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (m_Context.ExecutionStatus == TestExecutionStatus.StopRequested || m_Context.ExecutionStatus == TestExecutionStatus.AbortRequested)
|
||||
{
|
||||
StopAllRunningCoroutines();
|
||||
yield break;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
while (m_Running);
|
||||
}
|
||||
|
||||
private void StopAllRunningCoroutines()
|
||||
{
|
||||
if (m_TimeOutCoroutine != null)
|
||||
{
|
||||
m_Controller.StopCoroutine(m_TimeOutCoroutine);
|
||||
}
|
||||
|
||||
if (m_TestCoroutine != null)
|
||||
{
|
||||
m_Controller.StopCoroutine(m_TestCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ExMethod(IEnumerator e, int timeout)
|
||||
{
|
||||
m_TimeOutCoroutine = m_Controller.StartCoroutine(StartTimer(e, timeout,
|
||||
() =>
|
||||
{
|
||||
m_TestFailed = true;
|
||||
m_Timeout = true;
|
||||
m_Running = false;
|
||||
}));
|
||||
|
||||
yield return m_Controller.StartCoroutine(e);
|
||||
m_Controller.StopCoroutine(m_TimeOutCoroutine);
|
||||
m_Running = false;
|
||||
}
|
||||
|
||||
private IEnumerator StartTimer(IEnumerator coroutineToBeKilled, int timeout, Action onTimeout)
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(timeout / 1000f);
|
||||
if (coroutineToBeKilled != null)
|
||||
m_Controller.StopCoroutine(coroutineToBeKilled);
|
||||
if (onTimeout != null)
|
||||
onTimeout();
|
||||
}
|
||||
|
||||
public bool HasFailedWithTimeout()
|
||||
{
|
||||
return m_Timeout;
|
||||
}
|
||||
|
||||
public int GetDefaultTimeout()
|
||||
{
|
||||
return k_DefaultTimeout;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24a158219395ebf44a60547b97784ddc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class FloatEqualityComparer : IEqualityComparer<float>
|
||||
{
|
||||
private const float k_DefaultError = 0.0001f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
private static readonly FloatEqualityComparer m_Instance = new FloatEqualityComparer();
|
||||
public static FloatEqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
private FloatEqualityComparer() : this(k_DefaultError) {}
|
||||
|
||||
public FloatEqualityComparer(float allowedError)
|
||||
{
|
||||
this.AllowedError = allowedError;
|
||||
}
|
||||
|
||||
public bool Equals(float expected, float actual)
|
||||
{
|
||||
return Utils.AreFloatsEqual(expected, actual, AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(float value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af5042802f06c804c8abddd544b77a4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using NUnit.Framework.Interfaces;
|
||||
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
/// <summary>
|
||||
/// When implemented by an attribute, this interface implemented to provide actions to execute before setup and after teardown of tests.
|
||||
/// </summary>
|
||||
public interface IOuterUnityTestAction
|
||||
{
|
||||
/// <summary>Executed before each test is run</summary>
|
||||
/// <param name="test">The test that is going to be run.</param>
|
||||
IEnumerator BeforeTest(ITest test);
|
||||
|
||||
/// <summary>Executed after each test is run</summary>
|
||||
/// <param name="test">The test that has just been run.</param>
|
||||
IEnumerator AfterTest(ITest test);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9c2a6302985d3846b7b9f6fd9e2da9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
public interface IPostBuildCleanup
|
||||
{
|
||||
void Cleanup();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff67c526455160f4690a44f74dee4cbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
public interface IPrebuildSetup
|
||||
{
|
||||
void Setup();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acc16f0c684508f44813662a300c574b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce8da628f68c7594b8b9a597fa52db7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
public interface IMonoBehaviourTest
|
||||
{
|
||||
bool IsTestFinished {get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a002d3737b873954395b7cf862873ab8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,23 @@
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
public class MonoBehaviourTest<T> : CustomYieldInstruction where T : MonoBehaviour, IMonoBehaviourTest
|
||||
{
|
||||
public T component { get; }
|
||||
public GameObject gameObject { get { return component.gameObject; } }
|
||||
|
||||
public MonoBehaviourTest(bool dontDestroyOnLoad = true)
|
||||
{
|
||||
var go = new GameObject("MonoBehaviourTest: " + typeof(T).FullName);
|
||||
component = go.AddComponent<T>();
|
||||
if (dontDestroyOnLoad)
|
||||
{
|
||||
Object.DontDestroyOnLoad(go);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool keepWaiting
|
||||
{
|
||||
get { return !component.IsTestFinished; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 164c9b1458eaab743a4b45c37a4d720d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class PostBuildCleanupAttribute : Attribute
|
||||
{
|
||||
public PostBuildCleanupAttribute(Type targetClass)
|
||||
{
|
||||
TargetClass = targetClass;
|
||||
}
|
||||
|
||||
public PostBuildCleanupAttribute(string targetClassName)
|
||||
{
|
||||
TargetClass = AttributeHelper.GetTargetClassFromName(targetClassName, typeof(IPostBuildCleanup));
|
||||
}
|
||||
|
||||
internal Type TargetClass { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 621fd19bcb071b64aa1d68f0271aa780
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEngine.TestTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class PrebuildSetupAttribute : Attribute
|
||||
{
|
||||
public PrebuildSetupAttribute(Type targetClass)
|
||||
{
|
||||
TargetClass = targetClass;
|
||||
}
|
||||
|
||||
public PrebuildSetupAttribute(string targetClassName)
|
||||
{
|
||||
TargetClass = AttributeHelper.GetTargetClassFromName(targetClassName, typeof(IPrebuildSetup));
|
||||
}
|
||||
|
||||
internal Type TargetClass { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1b7ce919aa8864409412e809073cf96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class QuaternionEqualityComparer : IEqualityComparer<Quaternion>
|
||||
{
|
||||
private const float k_DefaultError = 0.00001f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
private static readonly QuaternionEqualityComparer m_Instance = new QuaternionEqualityComparer();
|
||||
public static QuaternionEqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
|
||||
private QuaternionEqualityComparer() : this(k_DefaultError) {}
|
||||
|
||||
public QuaternionEqualityComparer(float allowedError)
|
||||
{
|
||||
AllowedError = allowedError;
|
||||
}
|
||||
|
||||
public bool Equals(Quaternion expected, Quaternion actual)
|
||||
{
|
||||
return Mathf.Abs(Quaternion.Dot(expected, actual)) > (1.0f - AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(Quaternion quaternion)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b28913f21577de429da928d6d05219f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,43 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
internal static class StackTraceFilter
|
||||
{
|
||||
private static readonly string[] s_FilteredLogMessages =
|
||||
{
|
||||
@"UnityEngine.DebugLogHandler:Internal_Log",
|
||||
@"UnityEngine.DebugLogHandler:Log",
|
||||
@"UnityEngine.Logger:Log",
|
||||
@"UnityEngine.Debug"
|
||||
};
|
||||
|
||||
private static readonly string[] s_LastMessages =
|
||||
{
|
||||
@"System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)",
|
||||
@"UnityEditor.TestTools.TestRunner.EditModeRunner:InvokeDelegator"
|
||||
};
|
||||
|
||||
public static string Filter(string inputStackTrace)
|
||||
{
|
||||
int idx;
|
||||
foreach (var lastMessage in s_LastMessages)
|
||||
{
|
||||
idx = inputStackTrace.IndexOf(lastMessage);
|
||||
if (idx != -1)
|
||||
inputStackTrace = inputStackTrace.Substring(0, idx);
|
||||
}
|
||||
|
||||
var inputStackTraceLines = inputStackTrace.Split('\n');
|
||||
var result = new StringBuilder();
|
||||
foreach (var line in inputStackTraceLines)
|
||||
{
|
||||
if (s_FilteredLogMessages.Any(s => line.StartsWith(s)))
|
||||
continue;
|
||||
result.AppendLine(line);
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc748d99f1f0d484a811a566fc7915ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static bool AreFloatsEqual(float expected, float actual, float epsilon)
|
||||
{
|
||||
// special case for infinity
|
||||
if (expected == Mathf.Infinity || actual == Mathf.Infinity || expected == Mathf.NegativeInfinity || actual == Mathf.NegativeInfinity)
|
||||
return expected == actual;
|
||||
|
||||
// we cover both relative and absolute tolerance with this check
|
||||
// which is better than just relative in case of small (in abs value) args
|
||||
// please note that "usually" approximation is used [i.e. abs(x)+abs(y)+1]
|
||||
// but we speak about test code so we dont care that much about performance
|
||||
// but we do care about checks being more precise
|
||||
return Math.Abs(actual - expected) <= epsilon * Mathf.Max(Mathf.Max(Mathf.Abs(actual), Mathf.Abs(expected)), 1.0f);
|
||||
}
|
||||
|
||||
public static bool AreFloatsEqualAbsoluteError(float expected, float actual, float allowedAbsoluteError)
|
||||
{
|
||||
return Math.Abs(actual - expected) <= allowedAbsoluteError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Analogous to GameObject.CreatePrimitive, but creates a primitive mesh renderer with fast shader instead of a default builtin shader.
|
||||
/// Optimized for testing performance.
|
||||
/// </summary>
|
||||
/// <returns>A GameObject with primitive mesh renderer and collider.</returns>
|
||||
public static GameObject CreatePrimitive(PrimitiveType type)
|
||||
{
|
||||
var prim = GameObject.CreatePrimitive(type);
|
||||
var renderer = prim.GetComponent<Renderer>();
|
||||
if (renderer)
|
||||
renderer.sharedMaterial = new Material(Shader.Find("VertexLit"));
|
||||
return prim;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9502550ba4785e3499d6c9251fa2114b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector2ComparerWithEqualsOperator : IEqualityComparer<Vector2>
|
||||
{
|
||||
private static readonly Vector2ComparerWithEqualsOperator m_Instance = new Vector2ComparerWithEqualsOperator();
|
||||
public static Vector2ComparerWithEqualsOperator Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector2ComparerWithEqualsOperator() {}
|
||||
|
||||
public bool Equals(Vector2 expected, Vector2 actual)
|
||||
{
|
||||
return expected == actual;
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector2 vec2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65701ebe8bada6b4785e9c7afe7f5bee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector2EqualityComparer : IEqualityComparer<Vector2>
|
||||
{
|
||||
private const float k_DefaultError = 0.0001f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
private static readonly Vector2EqualityComparer m_Instance = new Vector2EqualityComparer();
|
||||
public static Vector2EqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector2EqualityComparer() : this(k_DefaultError)
|
||||
{
|
||||
}
|
||||
|
||||
public Vector2EqualityComparer(float error)
|
||||
{
|
||||
this.AllowedError = error;
|
||||
}
|
||||
|
||||
public bool Equals(Vector2 expected, Vector2 actual)
|
||||
{
|
||||
return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.y, actual.y, AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector2 vec2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58ad09607a0d62d458a78d7174665566
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector3ComparerWithEqualsOperator : IEqualityComparer<Vector3>
|
||||
{
|
||||
private static readonly Vector3ComparerWithEqualsOperator m_Instance = new Vector3ComparerWithEqualsOperator();
|
||||
public static Vector3ComparerWithEqualsOperator Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector3ComparerWithEqualsOperator() {}
|
||||
|
||||
public bool Equals(Vector3 expected, Vector3 actual)
|
||||
{
|
||||
return expected == actual;
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector3 vec3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b994928117e3db418da69c821da7e19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector3EqualityComparer : IEqualityComparer<Vector3>
|
||||
{
|
||||
private const float k_DefaultError = 0.0001f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
private static readonly Vector3EqualityComparer m_Instance = new Vector3EqualityComparer();
|
||||
public static Vector3EqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector3EqualityComparer() : this(k_DefaultError) {}
|
||||
public Vector3EqualityComparer(float allowedError)
|
||||
{
|
||||
this.AllowedError = allowedError;
|
||||
}
|
||||
|
||||
public bool Equals(Vector3 expected, Vector3 actual)
|
||||
{
|
||||
return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.y, actual.y, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.z, actual.z, AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector3 vec3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bd2bc28ff24d5c488844851cb785db0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector4ComparerWithEqualsOperator : IEqualityComparer<Vector4>
|
||||
{
|
||||
private static readonly Vector4ComparerWithEqualsOperator m_Instance = new Vector4ComparerWithEqualsOperator();
|
||||
public static Vector4ComparerWithEqualsOperator Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector4ComparerWithEqualsOperator() {}
|
||||
|
||||
public bool Equals(Vector4 expected, Vector4 actual)
|
||||
{
|
||||
return expected == actual;
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector4 vec4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44100f5f60f351348b9719b46d46cebe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.TestTools.Utils
|
||||
{
|
||||
public class Vector4EqualityComparer : IEqualityComparer<Vector4>
|
||||
{
|
||||
private const float k_DefaultError = 0.0001f;
|
||||
private readonly float AllowedError;
|
||||
|
||||
private static readonly Vector4EqualityComparer m_Instance = new Vector4EqualityComparer();
|
||||
public static Vector4EqualityComparer Instance { get { return m_Instance; } }
|
||||
|
||||
private Vector4EqualityComparer() : this(k_DefaultError) {}
|
||||
public Vector4EqualityComparer(float allowedError)
|
||||
{
|
||||
this.AllowedError = allowedError;
|
||||
}
|
||||
|
||||
public bool Equals(Vector4 expected, Vector4 actual)
|
||||
{
|
||||
return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.y, actual.y, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.z, actual.z, AllowedError) &&
|
||||
Utils.AreFloatsEqual(expected.w, actual.w, AllowedError);
|
||||
}
|
||||
|
||||
public int GetHashCode(Vector4 vec4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32da81683c22faf458026716a2b821aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user