public IEnumerator LossPendingCausesRestart()
        {
            bool lossPendingReceived = false;

            MockRuntime.Instance.TestCallback = (methodName, param) =>
            {
                switch (methodName)
                {
                case nameof(OpenXRFeature.OnSessionLossPending):
                    lossPendingReceived = true;
                    break;
                }

                return(true);
            };

            InitializeAndStart();

            yield return(new WaitForXrFrame(1));

            Assert.IsTrue(MockRuntime.TransitionToState(XrSessionState.LossPending, true), "Failed to transition to loss pending state");

            yield return(new WaitForLoaderRestart());

            Assert.IsTrue(lossPendingReceived);
        }
        public IEnumerator UserPresence()
        {
            List <InputDevice> hmdDevices = new List <InputDevice>();

            InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, hmdDevices);
            Assert.That(hmdDevices.Count == 0, Is.True);

            InitializeAndStart();

            // Wait two frames to let the input catch up with the renderer
            yield return(new WaitForXrFrame(2));

            InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, hmdDevices);
            Assert.That(hmdDevices.Count > 0, Is.True);

            bool hasValue = hmdDevices[0].TryGetFeatureValue(CommonUsages.userPresence, out bool isUserPresent);

            Assert.That(hasValue, Is.True);
            Assert.That(isUserPresent, Is.True);

            MockRuntime.TransitionToState(XrSessionState.Visible, true);

            // State transition doesnt happen immediately so make doubly sure it has happened before we try to get the new feature value
            yield return(new WaitForXrFrame(2));

            hasValue = hmdDevices[0].TryGetFeatureValue(CommonUsages.userPresence, out isUserPresent);
            Assert.That(hasValue, Is.True);
            Assert.That(isUserPresent, Is.False);
        }
Exemplo n.º 3
0
        public IEnumerator TransitionToState()
        {
            InitializeAndStart();
            yield return(new WaitForXrFrame());

            Assert.AreEqual(MockRuntime.sessionState, XrSessionState.Focused, "MockRuntime must be in focused state for this test to work correctly");
            Assert.IsTrue(MockRuntime.TransitionToState(XrSessionState.Visible, false), "Failed to transition to visible state");

            Assert.AreEqual(MockRuntime.sessionState, XrSessionState.Visible);
        }
Exemplo n.º 4
0
        public IEnumerator TransitionToStateForced()
        {
            InitializeAndStart();
            yield return(new WaitForXrFrame());

            Assert.IsFalse(MockRuntime.TransitionToState(XrSessionState.Synchronized, false), "Synchronized state must be an invalid transition for this test to be valid");
            Assert.IsTrue(MockRuntime.TransitionToState(XrSessionState.Synchronized, true), "Force state transition should not return false");

            yield return(new WaitForXrFrame());

            Assert.IsTrue(MockRuntime.sessionState == XrSessionState.Synchronized);
        }
        public IEnumerator FirstPersonObserverRestartWhileActive()
        {
            base.InitializeAndStart();

            MockRuntime.ActivateSecondaryView(XrViewConfigurationType.SecondaryMonoFirstPersonObserver, true);
            yield return(new WaitForXrFrame(1));

            MockRuntime.GetEndFrameStats(out var primaryLayerCount, out var secondaryLayerCount);
            Assert.IsTrue(secondaryLayerCount == 1);

            // Transition to ready, which was causing a crash.
            MockRuntime.TransitionToState(XrSessionState.Visible, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Synchronized, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Stopping, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Idle, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Ready, false);
            yield return(null);

            // Check that secondary layer is still there
            MockRuntime.GetEndFrameStats(out primaryLayerCount, out secondaryLayerCount);
            Assert.IsTrue(secondaryLayerCount == 1);

            // Transition back to focused
            MockRuntime.TransitionToState(XrSessionState.Synchronized, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Visible, false);
            yield return(null);

            MockRuntime.TransitionToState(XrSessionState.Focused, false);
            yield return(null);

            yield return(new WaitForXrFrame(2));

            // Verify secondary layer is still up and running
            MockRuntime.GetEndFrameStats(out primaryLayerCount, out secondaryLayerCount);
            Assert.IsTrue(secondaryLayerCount == 1);

            // Make sure we can turn it off
            MockRuntime.ActivateSecondaryView(XrViewConfigurationType.SecondaryMonoFirstPersonObserver, false);
            yield return(new WaitForXrFrame(2));

            MockRuntime.GetEndFrameStats(out primaryLayerCount, out secondaryLayerCount);
            Assert.IsTrue(secondaryLayerCount == 0);
        }
        public IEnumerator WantsToRestartFalse()
        {
            OpenXRRuntime.wantsToRestart += () => true;
            OpenXRRuntime.wantsToRestart += () => false;
            OpenXRRuntime.wantsToRestart += () => true;

            InitializeAndStart();
            yield return(new WaitForXrFrame(2));

            MockRuntime.TransitionToState(XrSessionState.LossPending, true);

            yield return(new WaitForLoaderShutdown());
        }