Esempio n. 1
0
        public IEnumerator TestLossPendingCausesSessionDestroyAndRestart()
        {
            bool lossPendingReceived = false;
            bool sessionDestroyed    = false;
            bool sessionCreated      = false;

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

                case nameof(OpenXRFeature.OnSessionDestroy):
                    sessionDestroyed = true;
                    sessionCreated   = false;
                    break;

                case nameof(OpenXRFeature.OnSessionCreate):
                    sessionCreated = true;
                    break;
                }

                return(true);
            };

            AddExtension(MockRuntime.XR_UNITY_mock_test);

            base.InitializeAndStart();

            yield return(null);

            Assert.AreEqual(10, MockRuntime.Instance.XrInstance);

            var wait = new WaitForLoaderRestart(Loader);

            var ret = MockDriver.TransitionToState(MockRuntime.Instance.XrSession, XrSessionState.LossPending, true) == XrResult.Success;

            yield return(wait);

            Assert.IsTrue(lossPendingReceived);
            Assert.IsTrue(sessionDestroyed);
            Assert.IsTrue(sessionCreated);
        }
Esempio n. 2
0
        public IEnumerator CheckDisplayRestartAfterStopSendRestartEvent()
        {
            AddExtension(MockRuntime.XR_UNITY_mock_test);

            bool onBeginSessionAfterEndSessionCalled = false;
            bool onEndSessionCalled = false;

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

                case nameof(OpenXRFeature.OnSessionBegin):
                    onBeginSessionAfterEndSessionCalled = onEndSessionCalled;
                    break;
                }
                return(true);
            };

            base.InitializeAndStart();
            yield return(null);

            base.Stop();
            yield return(null);

            Assert.IsTrue(onEndSessionCalled);
            Assert.IsFalse(onBeginSessionAfterEndSessionCalled);

            var waiter = new WaitForLoaderRestart(loader);

            loader.displaySubsystem.Start();

            yield return(waiter);

            Assert.IsTrue(onEndSessionCalled);
            Assert.IsTrue(onBeginSessionAfterEndSessionCalled);
        }