TouchDoubleTapTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Input.Tests TouchDoubleTapTriggerTests

Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class TouchDoubleTapTriggerTests : TestWithMocksOrVisually

The TouchDoubleTapTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodTouchDoubleTapTriggerTests
Initializes a new instance of the TouchDoubleTapTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreate
Public methodCreateFromAttributes
Public methodCreateWithAttributes
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodInvokeDoubleTap
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodShowRedCircleOnTouch
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void ShowRedCircleOnTouch()
{
    new FontText(Font.Default, "Touch 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 TouchDoubleTapTrigger());
    new Command(() => ellipse.Center = Vector2D.Zero).Add(new TouchPressTrigger(State.Released));
}
[Test, CloseAfterFirstFrame]
public void Create()
{
    Assert.DoesNotThrow(() => new TouchDoubleTapTrigger());
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    Assert.DoesNotThrow(() => new TouchDoubleTapTrigger(new Dictionary<string, string>()));
    Assert.Throws<TouchDoubleTapTrigger.TouchDoubleTapTriggerHasNoParameters>(
        () => new TouchDoubleTapTrigger(new Dictionary<string, string> { { "Button", "Right" } }));
}
[Test]
public void InvokeDoubleTap()
{
    var touch = Resolve<Touch>() as MockTouch;
    if (touch == null)
        return; //ncrunch: no coverage 
    var trigger = new TouchDoubleTapTrigger();
    bool wasInvoked = false;
    new Command(() => wasInvoked = true).Add(trigger);
    touch.SetTouchState(0, State.Pressing, Vector2D.Half);
    AdvanceTimeAndUpdateEntities();
    touch.SetTouchState(0, State.Releasing, Vector2D.Half);
    AdvanceTimeAndUpdateEntities();
    touch.SetTouchState(0, State.Pressing, Vector2D.Half);
    AdvanceTimeAndUpdateEntities();
    touch.SetTouchState(0, State.Releasing, Vector2D.Half);
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(wasInvoked);
}
[Test, CloseAfterFirstFrame]
public void CreateWithAttributes()
{
    Assert.DoesNotThrow(() => new TouchDoubleTapTrigger(new Dictionary<string, string>()));
    Assert.Throws<TouchDoubleTapTrigger.TouchDoubleTapTriggerHasNoParameters>(
        () => new TouchDoubleTapTrigger(new Dictionary<string, string> { { "a", "b" } }));
}
See Also