mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
add visual test
This commit is contained in:
parent
2d2bfac5e9
commit
16fee7ac1c
@ -168,6 +168,99 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
AddAssert("spinner not merged", () => EditorBeatmap.HitObjects.Contains(spinner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSimpleMergeHitSound()
|
||||
{
|
||||
HitCircle? circle1 = null;
|
||||
HitCircle? circle2 = null;
|
||||
double sliderStartTime = 0;
|
||||
|
||||
AddStep("select first two circles", () =>
|
||||
{
|
||||
circle1 = (HitCircle)EditorBeatmap.HitObjects.First(h => h is HitCircle);
|
||||
circle2 = (HitCircle)EditorBeatmap.HitObjects.First(h => h is HitCircle && h != circle1);
|
||||
EditorClock.Seek(circle1.StartTime);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle1);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||
sliderStartTime = circle1.StartTime;
|
||||
});
|
||||
|
||||
mergeSelection();
|
||||
|
||||
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
|
||||
(pos: circle1.Position, pathType: PathType.Linear),
|
||||
(pos: circle2.Position, pathType: null)));
|
||||
|
||||
AddStep("start editor clock", () =>
|
||||
{
|
||||
EditorClock.Seek(sliderStartTime);
|
||||
EditorClock.Start();
|
||||
});
|
||||
|
||||
AddStep("stop editor clock", () =>
|
||||
{
|
||||
EditorClock.Stop();
|
||||
});
|
||||
|
||||
AddStep("undo", () => Editor.Undo());
|
||||
AddAssert("merged objects restored", () => circle1 is not null && circle2 is not null && objectsRestored(circle1, circle2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMergeCircleSliderHitsound()
|
||||
{
|
||||
HitCircle? circle1 = null;
|
||||
Slider? slider = null;
|
||||
HitCircle? circle2 = null;
|
||||
double sliderStartTime = 0;
|
||||
|
||||
AddStep("select a circle, slider, circle", () =>
|
||||
{
|
||||
circle1 = (HitCircle)EditorBeatmap.HitObjects.First(h => h is HitCircle);
|
||||
slider = (Slider)EditorBeatmap.HitObjects.First(h => h is Slider && h.StartTime > circle1.StartTime);
|
||||
circle2 = (HitCircle)EditorBeatmap.HitObjects.First(h => h is HitCircle && h.StartTime > slider.StartTime);
|
||||
EditorClock.Seek(circle1.StartTime);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle1);
|
||||
EditorBeatmap.SelectedHitObjects.Add(slider);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||
sliderStartTime = circle1.StartTime;
|
||||
});
|
||||
|
||||
mergeSelection();
|
||||
|
||||
AddAssert("slider created", () =>
|
||||
{
|
||||
if (circle1 is null || circle2 is null || slider is null)
|
||||
return false;
|
||||
|
||||
var controlPoints = slider.Path.ControlPoints;
|
||||
(Vector2, PathType?)[] args = new (Vector2, PathType?)[controlPoints.Count + 2];
|
||||
args[0] = (circle1.Position, PathType.Linear);
|
||||
|
||||
for (int i = 0; i < controlPoints.Count; i++)
|
||||
{
|
||||
args[i + 1] = (controlPoints[i].Position + slider.Position, i == controlPoints.Count - 1 ? PathType.Linear : controlPoints[i].Type);
|
||||
}
|
||||
|
||||
args[^1] = (circle2.Position, null);
|
||||
return sliderCreatedFor(args);
|
||||
});
|
||||
|
||||
AddStep("start editor clock", () =>
|
||||
{
|
||||
EditorClock.Seek(sliderStartTime);
|
||||
EditorClock.Start();
|
||||
});
|
||||
|
||||
AddStep("stop editor clock", () =>
|
||||
{
|
||||
EditorClock.Stop();
|
||||
});
|
||||
|
||||
AddStep("undo", () => Editor.Undo());
|
||||
AddAssert("merged objects restored", () => circle1 is not null && circle2 is not null && objectsRestored(circle1, circle2));
|
||||
}
|
||||
|
||||
private void mergeSelection()
|
||||
{
|
||||
AddStep("merge selection", () =>
|
||||
|
Loading…
Reference in New Issue
Block a user