public void BasicTest() { var listener = new TestInputListener(); inputActionHandler.Propagator.Listeners.Add(listener); SimulateFewSteps(); inputs.PushKey(KeyboardKey.KEY_A); SimulateFewSteps(); Assert.IsTrue(listener.ReceivedPress); Assert.IsFalse(listener.ReceivedRelease); inputs.ReleaseKey(KeyboardKey.KEY_A); SimulateFewSteps(); Assert.IsFalse(listener.ReceivedRelease); SimulateFewSteps(); listener.HandledActions.Add(TestAction.Action1); inputs.PushKey(KeyboardKey.KEY_A); SimulateFewSteps(); Assert.IsFalse(listener.ReceivedRelease); inputs.ReleaseKey(KeyboardKey.KEY_A); SimulateFewSteps(); Assert.IsTrue(listener.ReceivedRelease); inputActionHandler.Propagator.Listeners.Remove(listener); SimulateFewSteps(); }
public void Test() { actionHandler.Update(); Assert.AreEqual(0, actionHandler.ActiveInputActions.Count); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); inputs.PushKey(KeyboardKey.KEY_A); actionHandler.Update(); Assert.IsTrue(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); Assert.AreEqual(1, actionHandler.ActiveInputActions.Count); inputs.ReleaseKey(KeyboardKey.KEY_A); actionHandler.Update(); Assert.AreEqual(0, actionHandler.ActiveInputActions.Count); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); inputs.PushKey(KeyboardKey.KEY_LEFT_CONTROL); actionHandler.Update(); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); Assert.AreEqual(0, actionHandler.ActiveInputActions.Count); inputs.PushKey(KeyboardKey.KEY_S); actionHandler.Update(); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsTrue(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); Assert.AreEqual(1, actionHandler.ActiveInputActions.Count); inputs.ReleaseKey(KeyboardKey.KEY_LEFT_CONTROL); actionHandler.Update(); Assert.AreEqual(0, actionHandler.ActiveInputActions.Count); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action1)); Assert.IsFalse(actionHandler.AreAllKeysPressedForAction(TestAction.Action2)); }
public void NextComponentActionTest() { var inputs = new FakeInputs(); var inputActionHandler = new TestInputActionHandler(inputs); inputActionHandler.Propagator.Listeners.Add(interfaceInputManager); interfaceInputManager.NextComponentAction = TestAction.Action1; Assert.IsEmpty(interfaceInputManager.FocusedComponents); inputs.PushKey(KeyboardKey.KEY_A); inputActionHandler.Update(); inputs.ReleaseKey(KeyboardKey.KEY_A); inputActionHandler.Update(); AssertContains(component1, interfaceInputManager.FocusedComponents); }