osu/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs

78 lines
2.9 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using System;
using System.Collections.Generic;
2020-03-18 19:04:38 +00:00
using NUnit.Framework;
2018-04-13 09:19:50 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2018-11-06 09:28:22 +00:00
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
2018-11-20 07:51:59 +00:00
using osuTK;
2018-04-13 09:19:50 +00:00
2019-03-24 16:02:36 +00:00
namespace osu.Game.Tests.Visual.Editor
2018-04-13 09:19:50 +00:00
{
2020-03-18 19:04:38 +00:00
public class TestSceneBeatDivisorControl : ManualInputManagerTestScene
2018-04-13 09:19:50 +00:00
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BindableBeatDivisor) };
2020-03-18 19:04:38 +00:00
private BeatDivisorControl beatDivisorControl;
private BindableBeatDivisor bindableBeatDivisor;
2018-04-13 09:19:50 +00:00
[BackgroundDependencyLoader]
private void load()
{
2020-03-18 19:04:38 +00:00
Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor())
2018-04-13 09:19:50 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(90, 90)
};
}
2020-03-18 19:04:38 +00:00
[Test]
public void TestBindableBeatDivisor()
{
AddStep("Reset", () => reset());
AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4);
AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4);
AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3);
AddAssert("Position at 12", () => bindableBeatDivisor.Value == 12);
}
[Test]
public void TestMouseInput()
{
AddStep("Reset", () => reset());
AddStep("Move to marker", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18));
InputManager.PressButton(osuTK.Input.MouseButton.Left);
});
AddStep("Mote to divisor 8", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18));
InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
});
AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8);
AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); });
AddStep("Trigger marker jump", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18));
});
AddStep("Move to divisor ~10", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18));
InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
});
AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8);
}
private void reset()
{
bindableBeatDivisor.Value = 16;
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(beatDivisorControl.Width, beatDivisorControl.Height));
}
2018-04-13 09:19:50 +00:00
}
}