コード例 #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 Setup()
        {
            try
            {
                // Disable input debugger so we don't waste time responding to all the
                // input system activity from the tests.
                #if UNITY_EDITOR
                InputDebuggerWindow.Disable();
                #endif

                testRuntime = new InputTestRuntime();

                // Push current input system state on stack.
                InputSystem.SaveAndReset(enableRemoting: false, runtime: testRuntime);

                #if UNITY_EDITOR
                // Make sure we're not affected by the user giving focus away from the
                // game view.
                InputConfiguration.LockInputToGame = true;
                #endif
            }
            catch (Exception exception)
            {
                Debug.LogError("Failed to set up input system for test " + TestContext.CurrentContext.Test.Name);
                Debug.LogException(exception);
                throw exception;
            }

            if (InputSystem.devices.Count > 0)
            {
                Assert.Fail("Input system should not have devices after reset");
            }
        }
コード例 #3
0
        public virtual void Setup()
        {
            // Disable input debugger so we don't waste time responding to all the
            // input system activity from the tests.
            #if UNITY_EDITOR
            InputDebuggerWindow.Disable();
            #endif

            // Push current input system state on stack.
            InputSystem.Save();

            // Put system in a blank state where it has all the layouts but has
            // none of the native devices.
            InputSystem.Reset();

            // Replace native input runtime with test runtime.
            testRuntime = new InputTestRuntime();
            InputSystem.s_Manager.InstallRuntime(testRuntime);
            InputSystem.s_Manager.InstallGlobals();

            #if UNITY_EDITOR
            // Make sure we're not affected by the user giving focus away from the
            // game view.
            InputConfiguration.LockInputToGame = true;
            #endif

            if (InputSystem.devices.Count > 0)
            {
                Assert.Fail("Input system should not have devices after reset");
            }
        }
コード例 #4
0
        static void Init()
        {
            // Get existing open window or if none, make a new one:
            InputDebuggerWindow window = (InputDebuggerWindow)EditorWindow.GetWindow(typeof(InputDebuggerWindow));

            window.Show();
            window.titleContent = new GUIContent("Input Debug");
        }
コード例 #5
0
        public virtual void Setup()
        {
            try
            {
                // Disable input debugger so we don't waste time responding to all the
                // input system activity from the tests.
                #if UNITY_EDITOR
                InputDebuggerWindow.Disable();
                #endif

                runtime = new InputTestRuntime();

                // Push current input system state on stack.
                InputSystem.SaveAndReset(enableRemoting: false, runtime: runtime);

                #if UNITY_EDITOR
                // Make sure we're not affected by the user giving focus away from the
                // game view.
                InputEditorUserSettings.lockInputToGameView = true;
                #endif

                var testProperties = TestContext.CurrentContext.Test.Properties;
                if (testProperties.ContainsKey("TimesliceEvents") && testProperties["TimesliceEvents"][0].Equals("Off"))
                {
                    InputSystem.settings.timesliceEvents = false;
                }
            }
            catch (Exception exception)
            {
                Debug.LogError("Failed to set up input system for test " + TestContext.CurrentContext.Test.Name);
                Debug.LogException(exception);
                throw exception;
            }

            if (InputSystem.devices.Count > 0)
            {
                Assert.Fail("Input system should not have devices after reset");
            }
        }
コード例 #6
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
        }
コード例 #7
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
        }