A game about forced loneliness, made by TACStudios
at master 47 lines 1.6 kB view raw
1using NUnit.Framework; 2using UnityEngine; 3using UnityEditor.EventSystems; 4using UnityEngine.EventSystems; 5 6[TestFixture] 7public class InputModuleTests 8{ 9 private EventSystem m_EventSystem; 10 11 [SetUp] 12 public void Setup() 13 { 14 m_EventSystem = new GameObject("EventSystem").AddComponent<EventSystem>(); 15 } 16 17 [TearDown] 18 public void TearDown() 19 { 20 Object.DestroyImmediate(m_EventSystem.gameObject); 21 } 22 23 [Test] 24 public void InputModuleComponentFactory_AddComponent_CanBeOverriden() 25 { 26 // First call creates a StandaloneInputModule 27 var inputModule = InputModuleComponentFactory.AddInputModule(m_EventSystem.gameObject); 28 Assert.IsInstanceOf<StandaloneInputModule>(inputModule); 29 Object.DestroyImmediate(inputModule); 30 31 // After setting the override to a custom type, further calls use the custom type 32 InputModuleComponentFactory.SetInputModuleComponentOverride(go => go.AddComponent<TestInputModule>()); 33 inputModule = InputModuleComponentFactory.AddInputModule(m_EventSystem.gameObject); 34 Assert.IsInstanceOf<TestInputModule>(inputModule); 35 Object.DestroyImmediate(inputModule); 36 37 // After setting the override to null, further calls use the StandaloneInputModule again 38 InputModuleComponentFactory.SetInputModuleComponentOverride(null); 39 inputModule = InputModuleComponentFactory.AddInputModule(m_EventSystem.gameObject); 40 Assert.IsInstanceOf<StandaloneInputModule>(inputModule); 41 } 42 43 public class TestInputModule : BaseInputModule 44 { 45 public override void Process() { } 46 } 47}