1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 19:02:56 +08:00
osu-lazer/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs

254 lines
7.4 KiB
C#
Raw Normal View History

2024-03-27 19:22:51 +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.
2024-03-28 17:05:26 +08:00
using System.Collections.Generic;
2024-03-27 19:22:51 +08:00
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Beatmaps;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Catch.Tests.Editor
{
[TestFixture]
public partial class TestSceneCatchReverseSelection : TestSceneEditor
{
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
[Test]
public void TestReverseSelectionTwoFruits()
{
2024-03-28 17:05:26 +08:00
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
2024-03-27 19:22:51 +08:00
addObjects([
new Fruit
{
StartTime = 200,
2024-03-28 17:05:26 +08:00
X = 0,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 400,
2024-03-28 17:05:26 +08:00
X = 20,
2024-03-27 19:22:51 +08:00
}
]);
2024-03-28 17:05:26 +08:00
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
2024-03-27 19:22:51 +08:00
selectEverything();
reverseSelection();
2024-03-28 17:05:26 +08:00
AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
2024-03-27 19:22:51 +08:00
}
[Test]
public void TestReverseSelectionThreeFruits()
{
2024-03-28 17:05:26 +08:00
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
2024-03-27 19:22:51 +08:00
addObjects([
new Fruit
{
StartTime = 200,
2024-03-28 17:05:26 +08:00
X = 0,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 400,
2024-03-28 17:05:26 +08:00
X = 20,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 600,
2024-03-28 17:05:26 +08:00
X = 40,
2024-03-27 19:22:51 +08:00
}
]);
2024-03-28 17:05:26 +08:00
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
2024-03-27 19:22:51 +08:00
selectEverything();
reverseSelection();
2024-03-28 17:05:26 +08:00
AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
2024-03-27 19:22:51 +08:00
}
[Test]
public void TestReverseSelectionFruitAndJuiceStream()
{
2024-03-28 17:05:26 +08:00
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
2024-03-27 19:22:51 +08:00
addObjects([
new Fruit
{
StartTime = 200,
X = 0,
},
new JuiceStream
{
StartTime = 400,
X = 20,
Path = new SliderPath
{
ControlPoints =
{
new PathControlPoint(),
new PathControlPoint(new Vector2(50))
}
}
}
]);
2024-03-28 17:05:26 +08:00
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
2024-03-27 19:22:51 +08:00
selectEverything();
reverseSelection();
2024-03-28 17:05:26 +08:00
AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
2024-03-27 19:22:51 +08:00
}
[Test]
public void TestReverseSelectionTwoFruitsAndJuiceStream()
{
2024-03-28 17:05:26 +08:00
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
2024-03-27 19:22:51 +08:00
addObjects([
new Fruit
{
StartTime = 200,
X = 0,
},
new Fruit
{
StartTime = 400,
X = 20,
},
new JuiceStream
{
StartTime = 600,
X = 40,
Path = new SliderPath
{
ControlPoints =
{
new PathControlPoint(),
new PathControlPoint(new Vector2(50))
}
}
}
]);
2024-03-28 17:05:26 +08:00
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
2024-03-27 19:22:51 +08:00
selectEverything();
reverseSelection();
2024-03-28 17:05:26 +08:00
AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
2024-03-27 19:22:51 +08:00
}
[Test]
public void TestReverseSelectionTwoCombos()
{
2024-03-28 17:05:26 +08:00
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
2024-03-27 19:22:51 +08:00
addObjects([
new Fruit
{
StartTime = 200,
2024-03-28 17:05:26 +08:00
X = 0,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 400,
2024-03-28 17:05:26 +08:00
X = 20,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 600,
2024-03-28 17:05:26 +08:00
X = 40,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 800,
NewCombo = true,
2024-03-28 17:05:26 +08:00
X = 60,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 1000,
2024-03-28 17:05:26 +08:00
X = 80,
2024-03-27 19:22:51 +08:00
},
new Fruit
{
StartTime = 1200,
2024-03-28 17:05:26 +08:00
X = 100,
2024-03-27 19:22:51 +08:00
}
]);
2024-03-28 17:05:26 +08:00
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
2024-03-27 19:22:51 +08:00
selectEverything();
reverseSelection();
2024-03-28 17:05:26 +08:00
AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
2024-03-27 19:22:51 +08:00
}
private void addObjects(CatchHitObject[] hitObjects) => AddStep("Add objects", () => EditorBeatmap.AddRange(hitObjects));
2024-03-28 17:05:26 +08:00
private IEnumerable<CatchHitObject> getObjects() => EditorBeatmap.HitObjects.OfType<CatchHitObject>();
private IEnumerable<bool> getObjectNewCombos() => getObjects().Select(ho => ho.NewCombo);
2024-03-27 19:22:51 +08:00
private void selectEverything()
{
AddStep("Select everything", () =>
{
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects);
});
}
private void reverseSelection()
{
AddStep("Reverse selection", () =>
{
InputManager.PressKey(Key.LControl);
InputManager.Key(Key.G);
InputManager.ReleaseKey(Key.LControl);
});
}
}
}