Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests TouchHoldTriggerTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TouchHoldTriggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TouchHoldTriggerTests | Initializes a new instance of the TouchHoldTriggerTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
Create | ||
CreateFromAttributes | ||
HoldOnRectangle | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
IsHovering | ||
PessingInTheSamePositionWillMakeTriggerHover | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
SetUp |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void HoldOnRectangle() { var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f); new FilledRect(drawArea, Color.Blue); var trigger = new TouchHoldTrigger(drawArea); var counter = 0; var text = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.25f))); new Command(() => text.Text = "TouchHold Triggered " + ++counter + " times.").Add(trigger); }
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.5f); Assert.AreEqual(Rectangle.One, trigger.HoldArea); Assert.AreEqual(0.5f, trigger.HoldTime); }
[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