tangled
alpha
login
or
join now
keii.dev
/
osu-framework
0
fork
atom
A game framework written with osu! in mind.
0
fork
atom
overview
issues
pulls
pipelines
Add test coverage for tablet button passthrough
Bartłomiej Dach
5 years ago
79e8dc28
55df7541
+30
2 changed files
expand all
collapse all
unified
split
osu.Framework
Testing
Input
ManualInputManager.cs
osu.Framework.Tests
Visual
Input
TestScenePassThroughInputManager.cs
+24
osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs
···
215
215
AddAssert("pass-through handled mouse", () => testInputManager.CurrentState.Mouse.Buttons.Single() == MouseButton.Left);
216
216
}
217
217
218
218
+
[Test]
219
219
+
public void TestTabletButtonInput()
220
220
+
{
221
221
+
addTestInputManagerStep();
222
222
+
223
223
+
AddStep("press primary pen button", () => InputManager.PressTabletPenButton(TabletPenButton.Primary));
224
224
+
AddStep("press auxiliary button 4", () => InputManager.PressTabletAuxiliaryButton(TabletAuxiliaryButton.Button4));
225
225
+
226
226
+
AddStep("UseParentInput = false", () => testInputManager.UseParentInput = false);
227
227
+
228
228
+
AddStep("release primary pen button", () => InputManager.ReleaseTabletPenButton(TabletPenButton.Primary));
229
229
+
AddStep("press tertiary pen button", () => InputManager.PressTabletPenButton(TabletPenButton.Tertiary));
230
230
+
AddStep("release auxiliary button 4", () => InputManager.ReleaseTabletAuxiliaryButton(TabletAuxiliaryButton.Button4));
231
231
+
AddStep("press auxiliary button 2", () => InputManager.PressTabletAuxiliaryButton(TabletAuxiliaryButton.Button2));
232
232
+
233
233
+
AddStep("UseParentInput = true", () => testInputManager.UseParentInput = true);
234
234
+
AddAssert("pen buttons synced properly", () =>
235
235
+
!testInputManager.CurrentState.Tablet.PenButtons.Contains(TabletPenButton.Primary)
236
236
+
&& testInputManager.CurrentState.Tablet.PenButtons.Contains(TabletPenButton.Tertiary));
237
237
+
AddAssert("auxiliary buttons synced properly", () =>
238
238
+
!testInputManager.CurrentState.Tablet.AuxiliaryButtons.Contains(TabletAuxiliaryButton.Button4)
239
239
+
&& testInputManager.CurrentState.Tablet.AuxiliaryButtons.Contains(TabletAuxiliaryButton.Button2));
240
240
+
}
241
241
+
218
242
public class TestInputManager : ManualInputManager
219
243
{
220
244
public readonly TestSceneInputManager.ContainingInputManagerStatusText Status;
+6
osu.Framework/Testing/Input/ManualInputManager.cs
···
127
127
public void PressMidiKey(MidiKey key, byte velocity) => Input(new MidiKeyInput(key, velocity, true));
128
128
public void ReleaseMidiKey(MidiKey key, byte velocity) => Input(new MidiKeyInput(key, velocity, false));
129
129
130
130
+
public void PressTabletPenButton(TabletPenButton penButton) => Input(new TabletPenButtonInput(penButton, true));
131
131
+
public void ReleaseTabletPenButton(TabletPenButton penButton) => Input(new TabletPenButtonInput(penButton, false));
132
132
+
133
133
+
public void PressTabletAuxiliaryButton(TabletAuxiliaryButton auxiliaryButton) => Input(new TabletAuxiliaryButtonInput(auxiliaryButton, true));
134
134
+
public void ReleaseTabletAuxiliaryButton(TabletAuxiliaryButton auxiliaryButton) => Input(new TabletAuxiliaryButtonInput(auxiliaryButton, false));
135
135
+
130
136
private class ManualInputHandler : InputHandler
131
137
{
132
138
public override bool Initialize(GameHost host) => true;