1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:02:54 +08:00

Fix test compile errors

This commit is contained in:
smoogipoo 2020-11-20 13:54:41 +09:00
parent d467a00eea
commit a3145ed96d
2 changed files with 287 additions and 276 deletions

View File

@ -1,276 +1,285 @@
// // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
//
// using System; using System;
// using System.Linq; using System.Linq;
// using NUnit.Framework; using NUnit.Framework;
// using osu.Framework.Graphics; using osu.Framework.Graphics;
// using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
// using osu.Framework.Testing; using osu.Framework.Testing;
// using osu.Framework.Utils; using osu.Framework.Timing;
// using osu.Game.Beatmaps; using osu.Framework.Utils;
// using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps;
// using osu.Game.Rulesets.Osu.Objects; using osu.Game.Beatmaps.ControlPoints;
// using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects;
// using osu.Game.Rulesets.Osu.Objects.Drawables.Connections; using osu.Game.Rulesets.Osu.Objects.Drawables;
// using osu.Game.Tests.Visual; using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
// using osuTK; using osu.Game.Tests.Visual;
// using osuTK;
// namespace osu.Game.Rulesets.Osu.Tests
// { namespace osu.Game.Rulesets.Osu.Tests
// public class TestSceneFollowPoints : OsuTestScene {
// { public class TestSceneFollowPoints : OsuTestScene
// private Container<DrawableOsuHitObject> hitObjectContainer; {
// private FollowPointRenderer followPointRenderer; private Container<DrawableOsuHitObject> hitObjectContainer;
// private FollowPointRenderer followPointRenderer;
// [SetUp]
// public void Setup() => Schedule(() => [SetUp]
// { public void Setup() => Schedule(() =>
// Children = new Drawable[] {
// { Children = new Drawable[]
// hitObjectContainer = new TestHitObjectContainer { RelativeSizeAxes = Axes.Both }, {
// followPointRenderer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both } hitObjectContainer = new TestHitObjectContainer { RelativeSizeAxes = Axes.Both },
// }; followPointRenderer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both }
// }); };
// });
// [Test]
// public void TestAddObject() [Test]
// { public void TestAddObject()
// addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } }); {
// addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } });
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestRemoveObject() [Test]
// { public void TestRemoveObject()
// addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } }); {
// addObjectsStep(() => new OsuHitObject[] { new HitCircle { Position = new Vector2(100, 100) } });
// removeObjectStep(() => getObject(0));
// removeObjectStep(() => getObject(0));
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestAddMultipleObjects() [Test]
// { public void TestAddMultipleObjects()
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestRemoveEndObject() [Test]
// { public void TestRemoveEndObject()
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// removeObjectStep(() => getObject(4));
// removeObjectStep(() => getObject(4));
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestRemoveStartObject() [Test]
// { public void TestRemoveStartObject()
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// removeObjectStep(() => getObject(0));
// removeObjectStep(() => getObject(0));
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestRemoveMiddleObject() [Test]
// { public void TestRemoveMiddleObject()
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// removeObjectStep(() => getObject(2));
// removeObjectStep(() => getObject(2));
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestMoveObject() [Test]
// { public void TestMoveObject()
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// AddStep("move hitobject", () => getObject(2).HitObject.Position = new Vector2(300, 100));
// AddStep("move hitobject", () => getObject(2).HitObject.Position = new Vector2(300, 100));
// assertGroups();
// } assertGroups();
// }
// [TestCase(0, 0)] // Start -> Start
// [TestCase(0, 2)] // Start -> Middle [TestCase(0, 0)] // Start -> Start
// [TestCase(0, 5)] // Start -> End [TestCase(0, 2)] // Start -> Middle
// [TestCase(2, 0)] // Middle -> Start [TestCase(0, 5)] // Start -> End
// [TestCase(1, 3)] // Middle -> Middle (forwards) [TestCase(2, 0)] // Middle -> Start
// [TestCase(3, 1)] // Middle -> Middle (backwards) [TestCase(1, 3)] // Middle -> Middle (forwards)
// [TestCase(4, 0)] // End -> Start [TestCase(3, 1)] // Middle -> Middle (backwards)
// [TestCase(4, 2)] // End -> Middle [TestCase(4, 0)] // End -> Start
// [TestCase(4, 4)] // End -> End [TestCase(4, 2)] // End -> Middle
// public void TestReorderObjects(int startIndex, int endIndex) [TestCase(4, 4)] // End -> End
// { public void TestReorderObjects(int startIndex, int endIndex)
// addMultipleObjectsStep(); {
// addMultipleObjectsStep();
// reorderObjectStep(startIndex, endIndex);
// reorderObjectStep(startIndex, endIndex);
// assertGroups();
// } assertGroups();
// }
// [Test]
// public void TestStackedObjects() [Test]
// { public void TestStackedObjects()
// addObjectsStep(() => new OsuHitObject[] {
// { addObjectsStep(() => new OsuHitObject[]
// new HitCircle { Position = new Vector2(300, 100) }, {
// new HitCircle new HitCircle { Position = new Vector2(300, 100) },
// { new HitCircle
// Position = new Vector2(300, 300), {
// StackHeight = 20 Position = new Vector2(300, 300),
// }, StackHeight = 20
// }); },
// });
// assertDirections();
// } assertDirections();
// }
// private void addMultipleObjectsStep() => addObjectsStep(() => new OsuHitObject[]
// { private void addMultipleObjectsStep() => addObjectsStep(() => new OsuHitObject[]
// new HitCircle { Position = new Vector2(100, 100) }, {
// new HitCircle { Position = new Vector2(200, 200) }, new HitCircle { Position = new Vector2(100, 100) },
// new HitCircle { Position = new Vector2(300, 300) }, new HitCircle { Position = new Vector2(200, 200) },
// new HitCircle { Position = new Vector2(400, 400) }, new HitCircle { Position = new Vector2(300, 300) },
// new HitCircle { Position = new Vector2(500, 500) }, new HitCircle { Position = new Vector2(400, 400) },
// }); new HitCircle { Position = new Vector2(500, 500) },
// });
// private void addObjectsStep(Func<OsuHitObject[]> ctorFunc)
// { private void addObjectsStep(Func<OsuHitObject[]> ctorFunc)
// AddStep("add hitobjects", () => {
// { AddStep("add hitobjects", () =>
// var objects = ctorFunc(); {
// var objects = ctorFunc();
// for (int i = 0; i < objects.Length; i++)
// { for (int i = 0; i < objects.Length; i++)
// objects[i].StartTime = Time.Current + 1000 + 500 * (i + 1); {
// objects[i].ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); objects[i].StartTime = Time.Current + 1000 + 500 * (i + 1);
// objects[i].ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
// DrawableOsuHitObject drawableObject = null;
// DrawableOsuHitObject drawableObject = null;
// switch (objects[i])
// { switch (objects[i])
// case HitCircle circle: {
// drawableObject = new DrawableHitCircle(circle); case HitCircle circle:
// break; drawableObject = new DrawableHitCircle(circle);
// break;
// case Slider slider:
// drawableObject = new DrawableSlider(slider); case Slider slider:
// break; drawableObject = new DrawableSlider(slider);
// break;
// case Spinner spinner:
// drawableObject = new DrawableSpinner(spinner); case Spinner spinner:
// break; drawableObject = new DrawableSpinner(spinner);
// } break;
// }
// hitObjectContainer.Add(drawableObject);
// followPointRenderer.AddFollowPoints(objects[i]); hitObjectContainer.Add(drawableObject);
// } followPointRenderer.AddFollowPoints2(objects[i]);
// }); }
// } });
// }
// private void removeObjectStep(Func<DrawableOsuHitObject> getFunc)
// { private void removeObjectStep(Func<DrawableOsuHitObject> getFunc)
// AddStep("remove hitobject", () => {
// { AddStep("remove hitobject", () =>
// var drawableObject = getFunc.Invoke(); {
// var drawableObject = getFunc.Invoke();
// hitObjectContainer.Remove(drawableObject);
// followPointRenderer.RemoveFollowPoints(drawableObject.HitObject); hitObjectContainer.Remove(drawableObject);
// }); followPointRenderer.RemoveFollowPoints2(drawableObject.HitObject);
// } });
// }
// private void reorderObjectStep(int startIndex, int endIndex)
// { private void reorderObjectStep(int startIndex, int endIndex)
// AddStep($"move object {startIndex} to {endIndex}", () => {
// { AddStep($"move object {startIndex} to {endIndex}", () =>
// DrawableOsuHitObject toReorder = getObject(startIndex); {
// DrawableOsuHitObject toReorder = getObject(startIndex);
// double targetTime;
// if (endIndex < hitObjectContainer.Count) double targetTime;
// targetTime = getObject(endIndex).HitObject.StartTime - 1; if (endIndex < hitObjectContainer.Count)
// else targetTime = getObject(endIndex).HitObject.StartTime - 1;
// targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1; else
// targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1;
// hitObjectContainer.Remove(toReorder);
// toReorder.HitObject.StartTime = targetTime; hitObjectContainer.Remove(toReorder);
// hitObjectContainer.Add(toReorder); toReorder.HitObject.StartTime = targetTime;
// }); hitObjectContainer.Add(toReorder);
// } });
// }
// private void assertGroups()
// { private void assertGroups()
// AddAssert("has correct group count", () => followPointRenderer.Connections.Count == hitObjectContainer.Count); {
// AddAssert("group endpoints are correct", () => AddAssert("has correct group count", () => followPointRenderer.Entries.Count == hitObjectContainer.Count);
// { AddAssert("group endpoints are correct", () =>
// for (int i = 0; i < hitObjectContainer.Count; i++) {
// { for (int i = 0; i < hitObjectContainer.Count; i++)
// DrawableOsuHitObject expectedStart = getObject(i); {
// DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null; DrawableOsuHitObject expectedStart = getObject(i);
// DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null;
// if (getGroup(i).Start != expectedStart.HitObject)
// throw new AssertionException($"Object {i} expected to be the start of group {i}."); if (getEntry(i).Start != expectedStart.HitObject)
// throw new AssertionException($"Object {i} expected to be the start of group {i}.");
// if (getGroup(i).End != expectedEnd?.HitObject)
// throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}."); if (getEntry(i).End != expectedEnd?.HitObject)
// } throw new AssertionException($"Object {(expectedEnd == null ? "null" : i.ToString())} expected to be the end of group {i}.");
// }
// return true;
// }); return true;
// } });
// }
// private void assertDirections()
// { private void assertDirections()
// AddAssert("group directions are correct", () => {
// { AddAssert("group directions are correct", () =>
// for (int i = 0; i < hitObjectContainer.Count; i++) {
// { for (int i = 0; i < hitObjectContainer.Count; i++)
// DrawableOsuHitObject expectedStart = getObject(i); {
// DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null; DrawableOsuHitObject expectedStart = getObject(i);
// DrawableOsuHitObject expectedEnd = i < hitObjectContainer.Count - 1 ? getObject(i + 1) : null;
// if (expectedEnd == null)
// continue; if (expectedEnd == null)
// continue;
// var points = getGroup(i).ChildrenOfType<FollowPoint>().ToArray();
// if (points.Length == 0) var manualClock = new ManualClock();
// continue; followPointRenderer.Clock = new FramedClock(manualClock);
//
// float expectedDirection = MathF.Atan2(expectedStart.Position.Y - expectedEnd.Position.Y, expectedStart.Position.X - expectedEnd.Position.X); manualClock.CurrentTime = expectedStart.HitObject.StartTime;
// float realDirection = MathF.Atan2(expectedStart.Position.Y - points[^1].Position.Y, expectedStart.Position.X - points[^1].Position.X); followPointRenderer.UpdateSubTree();
//
// if (!Precision.AlmostEquals(expectedDirection, realDirection)) var points = getGroup(i).ChildrenOfType<FollowPoint>().ToArray();
// throw new AssertionException($"Expected group {i} in direction {expectedDirection}, but was {realDirection}."); if (points.Length == 0)
// } continue;
//
// return true; float expectedDirection = MathF.Atan2(expectedStart.Position.Y - expectedEnd.Position.Y, expectedStart.Position.X - expectedEnd.Position.X);
// }); float realDirection = MathF.Atan2(expectedStart.Position.Y - points[^1].Position.Y, expectedStart.Position.X - points[^1].Position.X);
// }
// if (!Precision.AlmostEquals(expectedDirection, realDirection))
// private DrawableOsuHitObject getObject(int index) => hitObjectContainer[index]; throw new AssertionException($"Expected group {i} in direction {expectedDirection}, but was {realDirection}.");
// }
// private FollowPointConnection getGroup(int index) => followPointRenderer.Connections[index];
// return true;
// private class TestHitObjectContainer : Container<DrawableOsuHitObject> });
// { }
// protected override int Compare(Drawable x, Drawable y)
// { private DrawableOsuHitObject getObject(int index) => hitObjectContainer[index];
// var osuX = (DrawableOsuHitObject)x;
// var osuY = (DrawableOsuHitObject)y; private FollowPointRenderer.FollowPointLifetimeEntry getEntry(int index) => followPointRenderer.Entries[index];
//
// int compare = osuX.HitObject.StartTime.CompareTo(osuY.HitObject.StartTime); private FollowPointConnection getGroup(int index) => followPointRenderer.ChildrenOfType<FollowPointConnection>().Single(c => c.Entry == getEntry(index));
//
// if (compare == 0) private class TestHitObjectContainer : Container<DrawableOsuHitObject>
// return base.Compare(x, y); {
// protected override int Compare(Drawable x, Drawable y)
// return compare; {
// } var osuX = (DrawableOsuHitObject)x;
// } var osuY = (DrawableOsuHitObject)y;
// }
// } int compare = osuX.HitObject.StartTime.CompareTo(osuY.HitObject.StartTime);
if (compare == 0)
return base.Compare(x, y);
return compare;
}
}
}
}

View File

@ -20,6 +20,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
public IReadOnlyList<FollowPointLifetimeEntry> Entries => lifetimeEntries;
private DrawablePool<FollowPointConnection> connectionPool; private DrawablePool<FollowPointConnection> connectionPool;
private DrawablePool<FollowPoint> pointPool; private DrawablePool<FollowPoint> pointPool;