mirror of https://github.com/ppy/osu
fix tests
This commit is contained in:
parent
b24bfa2908
commit
956bdbca50
|
@ -353,7 +353,7 @@ private partial class TestSliderBlueprint : SliderSelectionBlueprint
|
|||
{
|
||||
public new SliderBodyPiece BodyPiece => base.BodyPiece;
|
||||
public new TestSliderCircleOverlay HeadOverlay => (TestSliderCircleOverlay)base.HeadOverlay;
|
||||
public new TestSliderTailPiece TailPiece => (TestSliderTailPiece)base.TailPiece;
|
||||
public new TestSliderCircleOverlay TailOverlay => (TestSliderCircleOverlay)base.TailOverlay;
|
||||
public new PathControlPointVisualiser<Slider> ControlPointVisualiser => base.ControlPointVisualiser;
|
||||
|
||||
public TestSliderBlueprint(Slider slider)
|
||||
|
@ -362,7 +362,6 @@ public TestSliderBlueprint(Slider slider)
|
|||
}
|
||||
|
||||
protected override SliderCircleOverlay CreateCircleOverlay(Slider slider, SliderPosition position) => new TestSliderCircleOverlay(slider, position);
|
||||
protected override SliderTailPiece CreateTailPiece(Slider slider, SliderPosition position) => new TestSliderTailPiece(slider, position);
|
||||
}
|
||||
|
||||
private partial class TestSliderCircleOverlay : SliderCircleOverlay
|
||||
|
@ -374,15 +373,5 @@ public TestSliderCircleOverlay(Slider slider, SliderPosition position)
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
private partial class TestSliderTailPiece : SliderTailPiece
|
||||
{
|
||||
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
||||
|
||||
public TestSliderTailPiece(Slider slider, SliderPosition position)
|
||||
: base(slider, position)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
|
@ -164,51 +165,29 @@ public void TestMultipleControlPointDeselectionViaClickOutside()
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void TestDragSliderTail()
|
||||
public void TestAdjustDistance()
|
||||
{
|
||||
AddStep("move mouse to slider tail", () =>
|
||||
{
|
||||
Vector2 position = slider.EndPosition + new Vector2(10, 0);
|
||||
InputManager.MoveMouseTo(drawableObject.Parent!.ToScreenSpace(position));
|
||||
});
|
||||
AddStep("shift + drag", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ShiftLeft);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
AddStep("start adjust length",
|
||||
() => blueprint.ContextMenuItems.Single(o => o.Text.Value == "Adjust length").Action.Value());
|
||||
moveMouseToControlPoint(1);
|
||||
AddStep("release", () =>
|
||||
{
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
InputManager.ReleaseKey(Key.ShiftLeft);
|
||||
});
|
||||
|
||||
AddStep("end adjust length", () => InputManager.Click(MouseButton.Right));
|
||||
AddAssert("expected distance halved",
|
||||
() => Precision.AlmostEquals(slider.Path.Distance, 172.2, 0.1));
|
||||
|
||||
AddStep("move mouse to slider tail", () =>
|
||||
{
|
||||
Vector2 position = slider.EndPosition + new Vector2(10, 0);
|
||||
InputManager.MoveMouseTo(drawableObject.Parent!.ToScreenSpace(position));
|
||||
});
|
||||
AddStep("shift + drag", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ShiftLeft);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
AddStep("start adjust length",
|
||||
() => blueprint.ContextMenuItems.Single(o => o.Text.Value == "Adjust length").Action.Value());
|
||||
AddStep("move mouse beyond last control point", () =>
|
||||
{
|
||||
Vector2 position = slider.Position + slider.Path.ControlPoints[2].Position + new Vector2(50, 0);
|
||||
InputManager.MoveMouseTo(drawableObject.Parent!.ToScreenSpace(position));
|
||||
});
|
||||
AddStep("release", () =>
|
||||
{
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
InputManager.ReleaseKey(Key.ShiftLeft);
|
||||
});
|
||||
|
||||
AddStep("end adjust length", () => InputManager.Click(MouseButton.Right));
|
||||
AddAssert("expected distance is calculated distance",
|
||||
() => Precision.AlmostEquals(slider.Path.Distance, slider.Path.CalculatedDistance, 0.1));
|
||||
|
||||
moveMouseToControlPoint(1);
|
||||
AddAssert("expected distance is unchanged",
|
||||
() => Precision.AlmostEquals(slider.Path.Distance, slider.Path.CalculatedDistance, 0.1));
|
||||
}
|
||||
|
||||
private void moveHitObject()
|
||||
|
@ -227,7 +206,7 @@ private void checkPositions()
|
|||
() => Precision.AlmostEquals(blueprint.HeadOverlay.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
|
||||
|
||||
AddAssert("tail positioned correctly",
|
||||
() => Precision.AlmostEquals(blueprint.TailPiece.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.TailCircle.ScreenSpaceDrawQuad.Centre));
|
||||
() => Precision.AlmostEquals(blueprint.TailOverlay.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.TailCircle.ScreenSpaceDrawQuad.Centre));
|
||||
}
|
||||
|
||||
private void moveMouseToControlPoint(int index)
|
||||
|
@ -246,7 +225,7 @@ private partial class TestSliderBlueprint : SliderSelectionBlueprint
|
|||
{
|
||||
public new SliderBodyPiece BodyPiece => base.BodyPiece;
|
||||
public new TestSliderCircleOverlay HeadOverlay => (TestSliderCircleOverlay)base.HeadOverlay;
|
||||
public new TestSliderTailPiece TailPiece => (TestSliderTailPiece)base.TailPiece;
|
||||
public new TestSliderCircleOverlay TailOverlay => (TestSliderCircleOverlay)base.TailOverlay;
|
||||
public new PathControlPointVisualiser<Slider> ControlPointVisualiser => base.ControlPointVisualiser;
|
||||
|
||||
public TestSliderBlueprint(Slider slider)
|
||||
|
@ -255,7 +234,6 @@ public TestSliderBlueprint(Slider slider)
|
|||
}
|
||||
|
||||
protected override SliderCircleOverlay CreateCircleOverlay(Slider slider, SliderPosition position) => new TestSliderCircleOverlay(slider, position);
|
||||
protected override SliderTailPiece CreateTailPiece(Slider slider, SliderPosition position) => new TestSliderTailPiece(slider, position);
|
||||
}
|
||||
|
||||
private partial class TestSliderCircleOverlay : SliderCircleOverlay
|
||||
|
@ -267,15 +245,5 @@ public TestSliderCircleOverlay(Slider slider, SliderPosition position)
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
private partial class TestSliderTailPiece : SliderTailPiece
|
||||
{
|
||||
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
||||
|
||||
public TestSliderTailPiece(Slider slider, SliderPosition position)
|
||||
: base(slider, position)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public partial class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
|||
|
||||
protected SliderBodyPiece BodyPiece { get; private set; }
|
||||
protected SliderCircleOverlay HeadOverlay { get; private set; }
|
||||
protected SliderCircleOverlay TailPiece { get; private set; }
|
||||
protected SliderCircleOverlay TailOverlay { get; private set; }
|
||||
|
||||
[CanBeNull]
|
||||
protected PathControlPointVisualiser<Slider> ControlPointVisualiser { get; private set; }
|
||||
|
@ -77,7 +77,7 @@ private void load()
|
|||
{
|
||||
BodyPiece = new SliderBodyPiece(),
|
||||
HeadOverlay = CreateCircleOverlay(HitObject, SliderPosition.Start),
|
||||
TailPiece = CreateCircleOverlay(HitObject, SliderPosition.End),
|
||||
TailOverlay = CreateCircleOverlay(HitObject, SliderPosition.End),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue