public IEnumerator TestOverrideFocusDetails() { PlayModeTestUtilities.Setup(); var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); yield return(null); var focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider; var pointer = new TestPointer(); Assert.IsFalse(focusProvider.TryGetFocusDetails(pointer, out var focusDetails)); Assert.IsFalse(focusProvider.TryOverrideFocusDetails(pointer, new Physics.FocusDetails())); focusProvider.RegisterPointer(pointer); yield return(null); Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails)); Assert.IsNull(focusDetails.Object); var newFocusDetails = new Physics.FocusDetails(); newFocusDetails.Object = cube; newFocusDetails.RayDistance = 10; newFocusDetails.Point = new Vector3(1, 2, 3); Assert.IsTrue(focusProvider.TryOverrideFocusDetails(pointer, newFocusDetails)); Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails)); Assert.AreEqual(newFocusDetails.Object, focusDetails.Object); Assert.AreEqual(newFocusDetails.RayDistance, focusDetails.RayDistance); Assert.AreEqual(newFocusDetails.Point, focusDetails.Point); Assert.AreEqual(newFocusDetails.Object, focusProvider.GetFocusedObject(pointer)); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.PushHandSimulationProfile(); TestUtilities.PlayspaceToOriginLookingForward(); yield return(null); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.EnsureInputModule(); inputSim = PlayModeTestUtilities.GetInputSimulationService(); Assert.NotNull(inputSim); Assert.NotNull(CoreServices.InputSystem); GameObject lightObj = new GameObject("Light"); lightObj.transform.rotation = Quaternion.FromToRotation(Vector3.forward, new Vector3(1, -4, 2)); Light light = lightObj.AddComponent <Light>(); light.type = LightType.Directional; var shader = StandardShaderUtility.MrtkStandardShader; idleMaterial = new Material(shader); idleMaterial.color = Color.yellow; pokeMaterial = new Material(shader); pokeMaterial.color = Color.green; yield return(null); }
public IEnumerator SetUp() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToArbitraryPose(); // Target frame rate is set to 50 to match the physics // tick rate. The rest of the test code needs to wait on a frame to have // passed, and this is a rough way of ensuring that each WaitForFixedUpdate() // will roughly wait for frame to also pass. Application.targetFrameRate = 50; // Add a second cube in the background, sometimes physics checks fail with just one collider // in scene GameObject backgroundCube = GameObject.CreatePrimitive(PrimitiveType.Cube); backgroundCube.transform.position = Vector3.forward * 30; TestUtilities.PlaceRelativeToPlayspace(backgroundCube.transform); cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.localPosition = new Vector3(0, 0, 2); cube.transform.localScale = new Vector3(.2f, .2f, .2f); TestUtilities.PlaceRelativeToPlayspace(cube.transform); var collider = cube.GetComponentInChildren <Collider>(); Assert.IsNotNull(collider); yield return(null); }
public void Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.EnsureInputModule(); inputSim = PlayModeTestUtilities.GetInputSimulationService(); Assert.NotNull(inputSim); Assert.IsTrue(MixedRealityServiceRegistry.TryGetService <IMixedRealityInputSystem>(out inputSystem)); Assert.NotNull(inputSystem); GameObject lightObj = new GameObject("Light"); lightObj.transform.rotation = Quaternion.FromToRotation(Vector3.forward, new Vector3(1, -4, 2)); Light light = lightObj.AddComponent <Light>(); light.type = LightType.Directional; var shader = StandardShaderUtility.MrtkStandardShader; idleMaterial = new Material(shader); idleMaterial.color = Color.yellow; pokeMaterial = new Material(shader); pokeMaterial.color = Color.green; }
public IEnumerator Setup() { var riggedHandProfile = ScriptableObjectExtensions.GetAllInstances <MixedRealityToolkitConfigurationProfile>() .FirstOrDefault(x => x.name.Equals(RiggedHandProfileName)); PlayModeTestUtilities.Setup(riggedHandProfile); yield return(null); }
public void Setup() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToOriginLookingForward(); cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = new Vector3(1, 0, 1); interactable = cube.AddComponent <Interactable>(); Assert.NotNull(interactable, "Failed to add interactable to cube"); }
public void SetupFocusProviderRaycastTests() { PlayModeTestUtilities.Setup(); focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider; pointer = new TestPointer(); focusProvider.RegisterPointer(pointer); GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath("dc3b0cf66c0615e4c81d979f35d51eaa")); raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab); }
public void SetupFocusProviderRaycastTests() { PlayModeTestUtilities.Setup(); focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider; pointer = new TestPointer(); focusProvider.RegisterPointer(pointer); GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(Path.Combine("Assets", "MixedRealityToolkit.Tests", "PlayModeTests", "Prefabs", "FocusProviderRaycastTest.prefab")); raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab); }
public IEnumerator TestDefaultProfile() { PlayModeTestUtilities.Setup(); TestHand hand = new TestHand(Handedness.Right); yield return(hand.Show(Vector3.forward)); var allPointers = GetAllPointers(); // https://nunit.org/docs/2.5.5/collectionConstraints.html Assert.That(allPointers, Has.No.InstanceOf(typeof(GGVPointer))); Assert.That(allPointers, Has.Some.InstanceOf(typeof(ShellHandRayPointer))); }
public IEnumerator TestRaysCustomMediator() { // MRTK has already been created by SetUp prior to calling this, // we have to shut it down to re-init with the custom input profile which // replaces the default pointer mediator. PlayModeTestUtilities.TearDown(); yield return(null); var profile = TestUtilities.GetDefaultMixedRealityProfile <MixedRealityToolkitConfigurationProfile>(); profile.InputSystemProfile.PointerProfile = AssetDatabase.LoadAssetAtPath <MixedRealityPointerProfile>(ProfilePath); PlayModeTestUtilities.Setup(profile); yield return(null); yield return(TestRaysWorker()); }
public IEnumerator TestEditorProfile() { PlayModeTestUtilities.Setup(); InputSimulationService inputSimulationService = PlayModeTestUtilities.GetInputSimulationService(); inputSimulationService.UserInputEnabled = true; yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); var allPointers = GetAllPointers(); // https://nunit.org/docs/2.5.5/collectionConstraints.html Assert.That(allPointers, Has.Some.InstanceOf(typeof(GGVPointer))); Assert.That(allPointers, Has.No.InstanceOf(typeof(ShellHandRayPointer))); }
public void SetUp() { PlayModeTestUtilities.Setup(); float centerZ = 2.0f; float scale = 0.2f; var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.localPosition = new Vector3(0, 0, centerZ); cube.transform.localScale = Vector3.one * scale; colliderSurfaceZ = centerZ - scale * 0.5f; var collider = cube.GetComponentInChildren <Collider>(); Assert.IsNotNull(collider); }
public void SetUp() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToOriginLookingForward(); // Target frame rate is set to 50 to match the physics // tick rate. The rest of the test code needs to wait on a frame to have // passed, and this is a rough way of ensuring that each WaitForFixedUpdate() // will roughly wait for frame to also pass. Application.targetFrameRate = 50; var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.localPosition = new Vector3(0, 0, 2); cube.transform.localScale = new Vector3(.2f, .2f, .2f); var collider = cube.GetComponentInChildren <Collider>(); Assert.IsNotNull(collider); handler = collider.gameObject.AddComponent <PointerHandler>(); }
public IEnumerator TestGazeProviderDestroyed() { PlayModeTestUtilities.Setup(); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); // remove the gaze provider and it's components from the scene GazeProvider gazeProvider = CoreServices.InputSystem.GazeProvider.GameObjectReference.GetComponent <GazeProvider>(); gazeProvider.GazePointer.BaseCursor.Destroy(); DebugUtilities.LogVerbose("Application was playing, destroyed the gaze pointer's BaseCursor"); UnityObjectExtensions.DestroyObject(gazeProvider as Component); gazeProvider = null; // Ensure that the input system and it's related input sources are able to be reinitialized without issue. yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); PlayModeTestUtilities.GetInputSystem().Initialize(); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(null); }
public IEnumerator TestTeleportAndContentOffset() { var iss = PlayModeTestUtilities.GetInputSimulationService(); ExperienceScale originalExperienceScale; float originalProfileContentOffset; float contentOffset = 1.3f; // MRTK has already been created by SetUp prior to calling this, // we have to shut it down to re-init with the custom input profile which // has our contentOffset value set PlayModeTestUtilities.TearDown(); yield return(null); // Initialize a profile with the appropriate contentOffset var profile = TestUtilities.GetDefaultMixedRealityProfile <MixedRealityToolkitConfigurationProfile>(); originalProfileContentOffset = profile.ExperienceSettingsProfile.ContentOffset; originalExperienceScale = profile.ExperienceSettingsProfile.TargetExperienceScale; profile.ExperienceSettingsProfile.ContentOffset = contentOffset; profile.ExperienceSettingsProfile.TargetExperienceScale = ExperienceScale.Room; PlayModeTestUtilities.Setup(profile); yield return(new WaitForSeconds(0.5f)); // Ensure that the SceneContent object is contentOffset units above the origin Assert.AreEqual(GameObject.Find("MixedRealitySceneContent").transform.position.y, contentOffset, 0.005f); // Create a floor and make sure it's below the camera var floor = GameObject.CreatePrimitive(PrimitiveType.Plane); floor.transform.position = -0.5f * Vector3.up; // Test Right Hand Teleport TestUtilities.PlayspaceToOriginLookingForward(); float initialForwardPosition = MixedRealityPlayspace.Position.z; TestHand leftHand = new TestHand(Handedness.Left); TestHand rightHand = new TestHand(Handedness.Right); // Make sure the hand is in front of the camera yield return(rightHand.Show(Vector3.forward * 0.6f)); rightHand.SetRotation(Quaternion.identity); yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.TeleportStart)); // Wait for the hand to animate yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(new WaitForSeconds(1.0f / iss.InputSimulationProfile.HandGestureAnimationSpeed + 0.1f)); yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.TeleportEnd)); // Wait for the hand to animate yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(new WaitForSeconds(1.0f / iss.InputSimulationProfile.HandGestureAnimationSpeed + 0.1f)); // We should have teleported in the forward direction after the teleport Assert.IsTrue(MixedRealityPlayspace.Position.z > initialForwardPosition); rightHand.Hide(); // Test Left Hand Teleport TestUtilities.PlayspaceToOriginLookingForward(); // Make sure the hand is in front of the camera yield return(leftHand.Show(Vector3.forward * 0.6f)); yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.TeleportStart)); // Wait for the hand to animate yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(new WaitForSeconds(1.0f / iss.InputSimulationProfile.HandGestureAnimationSpeed + 0.1f)); yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.TeleportEnd)); // Wait for the hand to animate yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(new WaitForSeconds(1.0f / iss.InputSimulationProfile.HandGestureAnimationSpeed + 0.1f)); // We should have teleported in the forward direction after the teleport Assert.IsTrue(MixedRealityPlayspace.Position.z > initialForwardPosition); // Reset the profile's settings to it's original value profile.ExperienceSettingsProfile.TargetExperienceScale = originalExperienceScale; profile.ExperienceSettingsProfile.ContentOffset = originalProfileContentOffset; leftHand.Hide(); }
public void Setup() { PlayModeTestUtilities.Setup(); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.EnsureInputModule(); yield return(null); }
public void Setup() { PlayModeTestUtilities.Setup(); asyncCoroutineRunner = new GameObject("AsyncCoroutineRunner").AddComponent <AsyncCoroutineRunner>(); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); asyncCoroutineRunner = new GameObject("AsyncCoroutineRunner").AddComponent <AsyncCoroutineRunner>(); yield return(null); }
public IEnumerator SetUp() { PlayModeTestUtilities.Setup(); yield return(null); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToOriginLookingForward(); yield return(null); }
public void Setup() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToOriginLookingForward(); }
public IEnumerator Setup() { PlayModeTestUtilities.Setup(); TestUtilities.PlayspaceToArbitraryPose(); yield return(null); }
public void Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.PushHandSimulationProfile(); TestUtilities.PlayspaceToOriginLookingForward(); }
public void Setup() { PlayModeTestUtilities.Setup(); PlayModeTestUtilities.EnsureInputModule(); }