Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests TouchFlickTriggerTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TouchFlickTriggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TouchFlickTriggerTests | Initializes a new instance of the TouchFlickTriggerTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
Creation | ||
FlickDetection | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
ShowRedCircleOnFlick |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void ShowRedCircleOnFlick() { new FontText(Font.Default, "Flick screen to show red circle", Rectangle.One); var ellipse = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red); new Command(() => ellipse.Center = Vector2D.Half).Add(new TouchFlickTrigger()); new Command(() => ellipse.Center = Vector2D.Zero).Add(new TouchPressTrigger(State.Released)); }
[Test, CloseAfterFirstFrame] public void FlickDetection() { var trigger = new TouchFlickTrigger(); var touch = Resolve<Touch>() as MockTouch; if (touch == null) return; //ncrunch: no coverage bool flickHappened = false; trigger.Invoked += () => flickHappened = true; AdvanceTouchTick(touch, State.Pressing, new Vector2D(0.5f, 0.5f), trigger); Assert.IsFalse(flickHappened); Assert.AreEqual(0, trigger.PressTime); AdvanceTouchTick(touch, State.Pressed, new Vector2D(0.52f, 0.5f), trigger); Assert.IsFalse(flickHappened); AdvanceTouchTick(touch, State.Releasing, new Vector2D(0.6f, 0.5f), trigger); Assert.IsTrue(flickHappened); Assert.AreEqual(new Vector2D(0.5f, 0.5f), trigger.StartPosition); }
[Test, CloseAfterFirstFrame] public void Creation() { Assert.DoesNotThrow(() => new TouchFlickTrigger()); Assert.Throws<TouchFlickTrigger.TouchFlickTriggerHasNoParameters>( () => new TouchFlickTrigger(new Dictionary<string, string> { { "Button", "Left" } })); }
See Also