1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-19 17:40:08 +08:00

Add failing test case

This commit is contained in:
Salman Alshamrani
2025-08-05 11:31:49 +03:00
Unverified
parent 1da4b1ba93
commit 5aa186c987
@@ -9,6 +9,7 @@ using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Visual;
@@ -284,5 +285,70 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
&& Precision.AlmostEquals(composer.GridLineRotation.Value, 0.09, 0.01);
});
}
[Test]
public void TestGridPlacementCommittedByDragSelection()
{
AddStep("add circle", () => EditorBeatmap.Add(new HitCircle
{
Position = new Vector2(64, 64),
StartTime = EditorClock.CurrentTime,
}));
AddStep("select circle tool", () => InputManager.Key(Key.Number2));
AddStep("select grid tool", () => InputManager.Key(Key.Number5));
AddStep("move cursor to centre", () => InputManager.MoveMouseTo(Editor));
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("move cursor to (-1, -1)", () =>
{
var composer = Editor.ChildrenOfType<RectangularPositionSnapGrid>().Single();
InputManager.MoveMouseTo(composer.ToScreenSpace(new Vector2(-1, -1)));
});
AddStep("drag to center", () =>
{
InputManager.PressButton(MouseButton.Left);
InputManager.MoveMouseTo(Editor);
});
AddStep("release left", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("one selection", () => Editor.ChildrenOfType<OsuSelectionHandler>().Single().SelectedBlueprints, () => Has.One.Items);
AddAssert("selection is circle", () => Editor.ChildrenOfType<OsuSelectionHandler>().Single().SelectedBlueprints.Single(), Is.TypeOf<HitCircleSelectionBlueprint>);
AddStep("move cursor to slider", () =>
{
var composer = Editor.ChildrenOfType<RectangularPositionSnapGrid>().Single();
InputManager.MoveMouseTo(composer.ToScreenSpace(((Slider)EditorBeatmap.HitObjects.ElementAt(1)).EndPosition + new Vector2(1, 1)));
});
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddAssert("one selection", () => Editor.ChildrenOfType<OsuSelectionHandler>().Single().SelectedBlueprints, () => Has.One.Items);
AddAssert("selection is slider", () => Editor.ChildrenOfType<OsuSelectionHandler>().Single().SelectedBlueprints.Single(), Is.TypeOf<SliderSelectionBlueprint>);
}
[Test]
public void TestGridPlacementRevertsToLastTool()
{
AddStep("select circle tool", () => InputManager.Key(Key.Number2));
AddStep("select grid tool", () => InputManager.Key(Key.Number5));
AddStep("move cursor to centre", () => InputManager.MoveMouseTo(Editor));
AddStep("start grid placement", () => InputManager.Click(MouseButton.Left));
AddStep("end grid placement", () => InputManager.Click(MouseButton.Left));
AddAssert("tool reverted to circle", () => getComposer().BlueprintContainer.CurrentTool, Is.TypeOf<HitCircleCompositionTool>);
HitObjectComposer getComposer() => Editor.ChildrenOfType<HitObjectComposer>().Single();
}
[Test]
public void TestGridPlacementDoesNotOverrideToolChange()
{
AddStep("select circle tool", () => InputManager.Key(Key.Number2));
AddStep("select grid tool", () => InputManager.Key(Key.Number5));
AddStep("move cursor to centre", () => InputManager.MoveMouseTo(Editor));
AddStep("start grid placement", () => InputManager.Click(MouseButton.Left));
AddStep("select circle tool again", () => InputManager.Key(Key.Number2));
AddAssert("circle tool selected", () => getComposer().BlueprintContainer.CurrentTool, Is.TypeOf<HitCircleCompositionTool>);
HitObjectComposer getComposer() => Editor.ChildrenOfType<HitObjectComposer>().Single();
}
}
}