1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00
osu-lazer/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs

69 lines
2.6 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 17:19:50 +08:00
using System;
using System.Collections.Generic;
2020-03-19 03:04:38 +08:00
using NUnit.Framework;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
2018-11-06 17:28:22 +08:00
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Input;
2018-04-13 17:19:50 +08:00
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Editor
2018-04-13 17:19:50 +08:00
{
2020-03-19 03:04:38 +08:00
public class TestSceneBeatDivisorControl : ManualInputManagerTestScene
2018-04-13 17:19:50 +08:00
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BindableBeatDivisor) };
2020-03-19 03:04:38 +08:00
private BeatDivisorControl beatDivisorControl;
private BindableBeatDivisor bindableBeatDivisor;
2018-04-13 17:19:50 +08:00
2020-03-19 04:54:17 +08:00
[SetUp]
public void SetUp() => Schedule(() =>
2018-04-13 17:19:50 +08:00
{
2020-03-19 04:54:17 +08:00
Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor(16))
2018-04-13 17:19:50 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(90, 90)
};
2020-03-19 04:54:17 +08:00
});
2020-03-19 03:04:38 +08:00
[Test]
public void TestBindableBeatDivisor()
{
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("Move to marker", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18));
InputManager.PressButton(MouseButton.Left);
2020-03-19 03:04:38 +08:00
});
AddStep("Mote to divisor 8", () =>
{
InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18));
InputManager.ReleaseButton(MouseButton.Left);
2020-03-19 03:04:38 +08:00
});
AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8);
AddStep("Prepare to move marker", () => { InputManager.PressButton(MouseButton.Left); });
2020-03-19 03:04:38 +08:00
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(MouseButton.Left);
2020-03-19 03:04:38 +08:00
});
AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8);
}
2018-04-13 17:19:50 +08:00
}
}