2024-04-04 09:20:51 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2024-05-14 13:56:00 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-04-04 09:20:51 +00:00
|
|
|
using osu.Framework.Input;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
2024-05-14 13:56:00 +00:00
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
2024-04-04 09:20:51 +00:00
|
|
|
{
|
2024-05-14 13:56:00 +00:00
|
|
|
public partial class TestSceneManiaTouchInputArea : PlayerTestScene
|
2024-04-04 09:20:51 +00:00
|
|
|
{
|
|
|
|
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
|
|
|
|
|
|
|
[Test]
|
2024-05-14 13:56:00 +00:00
|
|
|
public void TestTouchAreaNotInitiallyVisible()
|
2024-04-04 09:20:51 +00:00
|
|
|
{
|
2024-05-14 13:56:00 +00:00
|
|
|
AddAssert("touch area not visible", () => getTouchOverlay()?.State.Value == Visibility.Hidden);
|
|
|
|
}
|
2024-04-04 09:20:51 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestPressReceptors()
|
|
|
|
{
|
2024-05-14 13:56:00 +00:00
|
|
|
AddAssert("touch area not visible", () => getTouchOverlay()?.State.Value == Visibility.Hidden);
|
2024-04-04 09:20:51 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
int index = i;
|
|
|
|
|
|
|
|
AddStep($"touch receptor {index}", () => InputManager.BeginTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
|
|
|
|
|
|
|
|
AddAssert("action sent",
|
|
|
|
() => this.ChildrenOfType<ManiaInputManager>().SelectMany(m => m.KeyBindingContainer.PressedActions),
|
|
|
|
() => Does.Contain(getReceptor(index).Action.Value));
|
|
|
|
|
|
|
|
AddStep($"release receptor {index}", () => InputManager.EndTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
|
2024-05-14 13:56:00 +00:00
|
|
|
|
|
|
|
AddAssert("touch area visible", () => getTouchOverlay()?.State.Value == Visibility.Visible);
|
2024-04-04 09:20:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-14 11:28:14 +00:00
|
|
|
private ManiaTouchInputArea? getTouchOverlay() => this.ChildrenOfType<ManiaTouchInputArea>().SingleOrDefault();
|
2024-04-04 09:20:51 +00:00
|
|
|
|
2024-05-14 11:28:14 +00:00
|
|
|
private ManiaTouchInputArea.ColumnInputReceptor getReceptor(int index) => this.ChildrenOfType<ManiaTouchInputArea.ColumnInputReceptor>().ElementAt(index);
|
2024-04-04 09:20:51 +00:00
|
|
|
}
|
|
|
|
}
|