1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 13:22:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Editing/TestSceneTimelineHitObjectBlueprint.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
4.1 KiB
C#
Raw Normal View History

2021-01-22 05:09:42 +08: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;
2021-01-22 00:54:26 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
2022-05-29 20:22:23 +08:00
using osu.Framework.Graphics.UserInterface;
2021-01-22 04:14:24 +08:00
using osu.Framework.Testing;
2022-05-29 20:22:23 +08:00
using osu.Game.Graphics.UserInterface;
2021-01-22 05:07:08 +08:00
using osu.Game.Rulesets.Objects.Types;
2021-01-22 00:54:26 +08:00
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK;
2021-01-22 04:14:24 +08:00
using osuTK.Input;
using static osu.Game.Screens.Edit.Compose.Components.Timeline.TimelineHitObjectBlueprint;
2021-01-22 00:54:26 +08:00
namespace osu.Game.Tests.Visual.Editing
{
public partial class TestSceneTimelineHitObjectBlueprint : TimelineTestScene
{
2021-01-22 05:07:08 +08:00
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer(Composer);
2021-01-22 00:54:26 +08:00
2022-05-29 20:22:23 +08:00
[Test]
public void TestContextMenu()
{
2022-05-29 22:06:01 +08:00
TimelineHitObjectBlueprint blueprint;
2022-05-29 20:22:23 +08:00
AddStep("add object", () =>
{
EditorBeatmap.Clear();
EditorBeatmap.Add(new HitCircle { StartTime = 3000 });
});
AddStep("click object", () =>
{
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
InputManager.MoveMouseTo(blueprint);
InputManager.Click(MouseButton.Left);
});
AddStep("right click", () => InputManager.Click(MouseButton.Right));
AddAssert("context menu open", () => this.ChildrenOfType<OsuContextMenu>().SingleOrDefault()?.State == MenuState.Open);
}
2021-01-22 05:07:08 +08:00
[Test]
public void TestDisallowZeroDurationObjects()
2021-01-22 00:54:26 +08:00
{
DragArea dragArea;
2021-01-22 00:54:26 +08:00
2021-01-22 05:07:08 +08:00
AddStep("add spinner", () =>
{
EditorBeatmap.Clear();
EditorBeatmap.Add(new Spinner
{
Position = new Vector2(256, 256),
StartTime = 2700,
2021-01-22 05:07:08 +08:00
Duration = 500
});
});
2021-01-22 00:54:26 +08:00
2021-01-22 05:07:08 +08:00
AddStep("hold down drag bar", () =>
2021-01-22 04:14:24 +08:00
{
2021-01-22 05:07:08 +08:00
// distinguishes between the actual drag bar and its "underlay shadow".
dragArea = this.ChildrenOfType<DragArea>().Single(bar => bar.HandlePositionalInput);
InputManager.MoveMouseTo(dragArea);
2021-01-22 04:14:24 +08:00
InputManager.PressButton(MouseButton.Left);
2021-01-22 05:07:08 +08:00
});
AddStep("try to drag bar past start", () =>
{
var blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
InputManager.MoveMouseTo(blueprint.SelectionQuad.TopLeft - new Vector2(100, 0));
2021-01-22 04:14:24 +08:00
InputManager.ReleaseButton(MouseButton.Left);
});
2021-01-22 05:07:08 +08:00
AddAssert("object has non-zero duration", () => EditorBeatmap.HitObjects.OfType<IHasDuration>().Single().Duration > 0);
2021-01-22 00:54:26 +08:00
}
2023-05-01 21:56:23 +08:00
[Test]
public void TestDisallowRepeatsOnZeroDurationObjects()
{
DragArea dragArea;
AddStep("add zero length slider", () =>
{
EditorBeatmap.Clear();
EditorBeatmap.Add(new Slider
{
Position = new Vector2(256, 256),
StartTime = 2700
});
});
AddStep("hold down drag bar", () =>
{
// distinguishes between the actual drag bar and its "underlay shadow".
dragArea = this.ChildrenOfType<DragArea>().Single(bar => bar.HandlePositionalInput);
InputManager.MoveMouseTo(dragArea);
InputManager.PressButton(MouseButton.Left);
});
AddStep("try to extend drag bar", () =>
{
var blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
InputManager.MoveMouseTo(blueprint.SelectionQuad.TopLeft + new Vector2(100, 0));
});
2023-05-02 12:12:08 +08:00
AddStep("release button", () => InputManager.PressButton(MouseButton.Left));
2023-05-01 21:56:23 +08:00
AddAssert("object has zero repeats", () => EditorBeatmap.HitObjects.OfType<IHasRepeats>().Single().RepeatCount == 0);
}
2021-01-22 00:54:26 +08:00
}
}