Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Tests: DeltaEngine.Input.Tests.TouchHoldTriggerTests
3 unit tests call DeltaEngine.Input.TouchHoldTrigger.IsHovering
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Return Value
Type: BooleanRemarks
Examples
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new TouchHoldTrigger(new Dictionary<string, string> { { "HoldArea", "0.1, 0.2, 0.3, 0.4" }, { "HoldTime", "10.4" } }); Assert.AreEqual(new Rectangle(0.1f, 0.2f, 0.3f, 0.4f), trigger.HoldArea); Assert.AreEqual(10.4f, trigger.HoldTime); } [Test, CloseAfterFirstFrame] public void IsHovering() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.5f); Assert.IsFalse(trigger.IsHovering()); trigger.Elapsed = 1f; Assert.IsFalse(trigger.IsHovering()); } [Test, CloseAfterFirstFrame] public void PessingInTheSamePositionWillMakeTriggerHover() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.0001f); new Command(() => { }).Add(trigger); SetTouchState(State.Pressing, Vector2D.Half); SetTouchState(State.Pressed, Vector2D.Half); SetTouchState(State.Releasing, Vector2D.Half); Assert.IsTrue(trigger.IsHovering()); } private void SetTouchState(State state, Vector2D position) { if (touch == null) return; //ncrunch: no coverage touch.SetTouchState(0, state, position); AdvanceTimeAndUpdateEntities(); } }
[Test, CloseAfterFirstFrame] public void IsHovering() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.5f); Assert.IsFalse(trigger.IsHovering()); trigger.Elapsed = 1f; Assert.IsFalse(trigger.IsHovering()); }
[Test, CloseAfterFirstFrame] public void PessingInTheSamePositionWillMakeTriggerHover() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.0001f); new Command(() => { }).Add(trigger); SetTouchState(State.Pressing, Vector2D.Half); SetTouchState(State.Pressed, Vector2D.Half); SetTouchState(State.Releasing, Vector2D.Half); Assert.IsTrue(trigger.IsHovering()); }
See Also