Removing XR test interface from tests repo (#26)
* moved out interface * update docs * update to fedback
This commit is contained in:
Родитель
0d1fa2f83c
Коммит
678dac0fc7
|
@ -7,7 +7,7 @@ Here we provide XR automated test projects for both AR and VR functional testing
|
|||
-- Including test projects for CrossPlatform and Windows Mixed Reality
|
||||
|
||||
## Target XR Displays or XR Assemblies
|
||||
*Currently only VR project has the Test Interface scripts (XRDisplay & Assembly) implemented for the Functional Tests*
|
||||
*Test Interface for fitlering XRDisplay & Assemblies*
|
||||
The attributes to target either XR Displays or Assemblies can be used to both support or exclude certain targets in order for tests, class, methods, or assemblies. This can be used to have only certain tests run on certain platforms while allowing a simple cross platform test matrix to exist.
|
||||
|
||||
### Target a XR Display
|
||||
|
|
|
@ -3,8 +3,8 @@ using NUnit.Framework;
|
|||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.XR;
|
||||
using static IXRDisplayInterface;
|
||||
using static IAssemblyInterface;
|
||||
using Unity.XRTesting;
|
||||
|
||||
#if XR_SDK
|
||||
using UnityEngine.XR.Management;
|
||||
#endif //XR_SDK
|
||||
|
@ -103,7 +103,7 @@ public class XrDeviceTests : XrFunctionalTestBase
|
|||
Assert.GreaterOrEqual(refreshRate, 60, "Refresh rate returned to lower than expected");
|
||||
#else
|
||||
#if OPENXR_SDK
|
||||
if(OpenXRUtilities.IsRunningMockRuntime())
|
||||
if(XRTestContext.Adapter.IsFeatureEnabled("mockruntime"))
|
||||
{
|
||||
Assert.GreaterOrEqual(refreshRate, 59, "Refresh rate returned to lower than expected");
|
||||
}else{
|
||||
|
|
|
@ -5,8 +5,7 @@ using NUnit.Framework;
|
|||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.XR;
|
||||
using static IXRDisplayInterface;
|
||||
using static IAssemblyInterface;
|
||||
using Unity.XRTesting;
|
||||
|
||||
public class XrDisplayTests : XrFunctionalTestBase
|
||||
{
|
||||
|
@ -79,7 +78,7 @@ public class XrDisplayTests : XrFunctionalTestBase
|
|||
#else
|
||||
Assert.IsTrue(gotrate);
|
||||
#if OPENXR_SDK
|
||||
if(OpenXRUtilities.IsRunningMockRuntime())
|
||||
if(XRTestContext.Adapter.IsFeatureEnabled("mockruntime"))
|
||||
{
|
||||
Assert.GreaterOrEqual(rate, 59, "Refresh rate returned to lower than expected");
|
||||
}else{
|
||||
|
|
|
@ -5,8 +5,7 @@ using System.Collections;
|
|||
using UnityEngine.XR;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static IXRDisplayInterface;
|
||||
using static IAssemblyInterface;
|
||||
using Unity.XRTesting;
|
||||
|
||||
[ConditionalAssembly(exclude = new []{"Unity.XR.MockHMD"/*, "Unity.XR.Management" */})]
|
||||
internal class XrInputTrackingTests : XrFunctionalTestBase
|
||||
|
|
|
@ -6,7 +6,8 @@ using UnityEngine;
|
|||
using UnityEngine.Rendering;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.XR;
|
||||
using static IXRDisplayInterface;
|
||||
using Unity.XRTesting;
|
||||
|
||||
#if XR_SDK
|
||||
using UnityEngine.XR.Management;
|
||||
#endif //XR_SDK
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"com.unity.test.metadata-manager",
|
||||
"Unity.XR.Management",
|
||||
"Unity.RenderPipelines.Universal.Runtime",
|
||||
"Unity.XR.OpenXR"
|
||||
"Unity.XR.OpenXR",
|
||||
"Unity.XRTesting"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd725458115325747bb2cefff9f22419
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,55 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IAssemblyInterface
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class ConditionalAssembly : NUnitAttribute, IApplyToTest
|
||||
{
|
||||
public string[] include { get; set; }
|
||||
public string[] exclude { get; set; }
|
||||
private string skippedReason;
|
||||
|
||||
public ConditionalAssembly()
|
||||
{
|
||||
include = new List<string>().ToArray();
|
||||
exclude = new List<string>().ToArray();
|
||||
}
|
||||
|
||||
public void ApplyToTest(Test test)
|
||||
{
|
||||
var playerAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
foreach (var playerAssembly in playerAssemblies)
|
||||
{
|
||||
var assembly = playerAssembly.FullName.Substring(0, playerAssembly.FullName.IndexOf(","));
|
||||
if (!IsAssemblySupported(assembly))
|
||||
{
|
||||
test.RunState = RunState.Skipped;
|
||||
test.Properties.Add(PropertyNames.SkipReason, skippedReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsAssemblySupported(string assembly)
|
||||
{
|
||||
if (include.Any() && !include.Any(x => x == assembly))
|
||||
{
|
||||
skippedReason = string.Format("Only supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exclude.Any(x => x == assembly))
|
||||
{
|
||||
skippedReason = string.Format("Test not supported on {0}", string.Join(", ", exclude.Select(x => x.ToString()).ToArray()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a90ba810bc1d2df4ca4c54612a6c6b7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,22 +0,0 @@
|
|||
#if OPENXR_SDK
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
//Adding here for now. Should be moved to XR Test framework
|
||||
public static class OpenXRUtilities
|
||||
{
|
||||
private static OpenXRFeature[] GetFeatures()
|
||||
{
|
||||
return OpenXRSettings.ActiveBuildTargetInstance.GetFeatures();
|
||||
}
|
||||
|
||||
public static bool IsRunningMockRuntime(){
|
||||
|
||||
var features = GetFeatures();
|
||||
return features.Any(f => f.GetType().Name.ToLower() == "mockruntime" && f.enabled == true);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ed0fe014536e7ab4fa31630e03349a86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,65 +0,0 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
public interface IXRDisplayInterface
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class TargetXrDisplays :NUnitAttribute, IApplyToTest
|
||||
{
|
||||
|
||||
public string[] include { get; set; }
|
||||
public string[] exclude { get; set; }
|
||||
private string skippedReason;
|
||||
private List<XRDisplaySubsystem> displays { get; set; }
|
||||
|
||||
public TargetXrDisplays()
|
||||
{
|
||||
include = new List<string>().ToArray();
|
||||
exclude = new List<string>().ToArray();
|
||||
}
|
||||
|
||||
public TargetXrDisplays(params string[] include)
|
||||
{
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
public void ApplyToTest(Test test)
|
||||
{
|
||||
displays = new List<XRDisplaySubsystem>();
|
||||
SubsystemManager.GetInstances(displays);
|
||||
|
||||
foreach (var display in displays)
|
||||
{
|
||||
if (VerifyIsXrDisplaySupported(display.subsystemDescriptor.id) && display.running)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
test.RunState = RunState.Skipped;
|
||||
test.Properties.Add(PropertyNames.SkipReason, skippedReason);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool VerifyIsXrDisplaySupported(string testTargetXrDisplay)
|
||||
{
|
||||
if (include.Any() && !include.Any(x => x == testTargetXrDisplay))
|
||||
{
|
||||
skippedReason = string.Format("Only supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exclude.Any(x => x == testTargetXrDisplay))
|
||||
{
|
||||
skippedReason = string.Format("Test not supported on {0}", string.Join(", ", exclude.Select(x => x.ToString()).ToArray()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 74ae7a44d2a28c847aeb658f881a9842
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Загрузка…
Ссылка в новой задаче