Skip to content

Commit 272c7df

Browse files
committed
Adds touch-test structure
1 parent 33cdb67 commit 272c7df

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

NUnitTests/NUnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<Reference Include="System.Xml" />
6161
</ItemGroup>
6262
<ItemGroup>
63+
<Compile Include="TouchTests.cs" />
6364
<Compile Include="MouseTests.cs" />
6465
<Compile Include="PadTests.cs" />
6566
<Compile Include="KeyTests.cs" />

NUnitTests/TouchTests.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// ***************************************************************************
2+
// This is free and unencumbered software released into the public domain.
3+
//
4+
// Anyone is free to copy, modify, publish, use, compile, sell, or
5+
// distribute this software, either in source code form or as a compiled
6+
// binary, for any purpose, commercial or non-commercial, and by any
7+
// means.
8+
//
9+
// In jurisdictions that recognize copyright laws, the author or authors
10+
// of this software dedicate any and all copyright interest in the
11+
// software to the public domain. We make this dedication for the benefit
12+
// of the public at large and to the detriment of our heirs and
13+
// successors. We intend this dedication to be an overt act of
14+
// relinquishment in perpetuity of all present and future rights to this
15+
// software under copyright law.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
//
25+
// For more information, please refer to <http://unlicense.org>
26+
// ***************************************************************************
27+
28+
using System;
29+
using InputStateManager;
30+
using InputStateManager.Inputs.InputProviders.Interfaces;
31+
using Microsoft.Xna.Framework;
32+
using Microsoft.Xna.Framework.Input.Touch;
33+
using Moq;
34+
using NUnit.Framework;
35+
36+
namespace NUnitTests
37+
{
38+
[TestFixture]
39+
[Category("InputStateManager.Mouse")]
40+
public class TouchTests
41+
{
42+
private InputManager input;
43+
private Mock<ITouchInputProvider> providerMock;
44+
45+
[SetUp]
46+
public void Setup()
47+
{
48+
providerMock = new Mock<ITouchInputProvider>();
49+
input = new InputManager(null, null, null, providerMock.Object);
50+
}
51+
52+
[Test]
53+
public void MouseTests()
54+
{
55+
providerMock.SetupSequence(o => o.GetState())
56+
.Returns(new TouchCollection());
57+
providerMock.SetupSequence(o => o.GetDisplayOrientation())
58+
.Returns(DisplayOrientation.Default);
59+
providerMock.SetupSequence(o => o.GetDisplayHeight())
60+
.Returns(780);
61+
providerMock.SetupSequence(o => o.GetDisplayWidth())
62+
.Returns(1280);
63+
providerMock.SetupSequence(o => o.GetEnableMouseGestures())
64+
.Returns(true);
65+
providerMock.SetupSequence(o => o.GetEnableMouseTouchPoint())
66+
.Returns(true);
67+
providerMock.SetupSequence(o => o.GetEnabledGestures())
68+
.Returns(GestureType.FreeDrag | GestureType.Flick);
69+
providerMock.SetupSequence(o => o.GetIsGestureAvailable())
70+
.Returns(true);
71+
providerMock.SetupSequence(o => o.ReadGesture())
72+
.Returns(new GestureSample(GestureType.Hold, TimeSpan.FromMilliseconds(12), Vector2.Zero, Vector2.Zero,
73+
Vector2.Zero, Vector2.Zero));
74+
input.Update();
75+
Assert.IsTrue(input.Touch.IsGestureAvailable);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)