Пример #1
0
        public virtual void TearDown()
        {
            try
            {
                // Destroy any GameObject in the current scene that isn't hidden and isn't the
                // test runner object. Do this first so that any cleanup finds the system in the
                // state it expects.
                var scene = SceneManager.GetActiveScene();
                foreach (var go in scene.GetRootGameObjects())
                {
                    if (go.hideFlags != 0 || go.name.Contains("tests runner"))
                    {
                        continue;
                    }
                    Object.DestroyImmediate(go);
                }

                InputSystem.Restore();
                testRuntime.Dispose();

                // Re-enable input debugger.
                #if UNITY_EDITOR
                InputDebuggerWindow.Enable();
                #endif
            }
            catch (Exception exception)
            {
                Debug.LogError("Failed to shut down and restore input system after test " + TestContext.CurrentContext.Test.Name);
                Debug.LogException(exception);
                throw exception;
            }
        }
Пример #2
0
        public virtual void TearDown()
        {
            ////REVIEW: What's the right thing to do here? ATM InputSystem.Restore() will not disable
            ////        actions and readding devices we refresh all enabled actions. That means that when
            ////        we restore, the action above will get refreshed and not find a 'test' interaction
            ////        registered in the system. Should we force-disable all actions on Restore()?
            InputSystem.DisableAllEnabledActions();

            if (testRuntime.m_DeviceCommandCallbacks != null)
            {
                testRuntime.m_DeviceCommandCallbacks.Clear();
            }

            testRuntime.Dispose();

            InputSystem.Restore();

            // Re-enable input debugger.
            #if UNITY_EDITOR
            InputDebuggerWindow.Enable();
            #endif
        }
Пример #3
0
        public virtual void TearDown()
        {
            // Destroy any GameObject in the current scene that isn't hidden and isn't the
            // test runner object. Do this first so that any cleanup finds the system in the
            // state it expects.
            var scene = SceneManager.GetActiveScene();

            foreach (var go in scene.GetRootGameObjects())
            {
                if (go.hideFlags != 0 || go.name.Contains("tests runner"))
                {
                    continue;
                }
                Object.DestroyImmediate(go);
            }

            ////REVIEW: What's the right thing to do here? ATM InputSystem.Restore() will not disable
            ////        actions and readding devices we refresh all enabled actions. That means that when
            ////        we restore, the action above will get refreshed and not find a 'test' interaction
            ////        registered in the system. Should we force-disable all actions on Restore()?
            InputSystem.DisableAllEnabledActions();

            if (testRuntime.m_DeviceCommandCallbacks != null)
            {
                testRuntime.m_DeviceCommandCallbacks.Clear();
            }

            testRuntime.Dispose();

            InputSystem.Restore();

            // Re-enable input debugger.
            #if UNITY_EDITOR
            InputDebuggerWindow.Enable();
            #endif
        }