mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Fix testcases
This commit is contained in:
parent
d05947ef48
commit
8fbaa86e64
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Edit.Screens.Compose;
|
||||
|
||||
@ -19,7 +20,9 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
random = new Random(1337);
|
||||
|
||||
Add(compose = new Compose());
|
||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
Add(compose = new Compose(clock, clock));
|
||||
AddStep("Next beatmap", nextBeatmap);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets;
|
||||
@ -30,9 +31,13 @@ namespace osu.Game.Tests.Visual
|
||||
private Track track;
|
||||
private HitObjectComposer composer;
|
||||
|
||||
private DecoupleableInterpolatingFramedClock clock;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame)
|
||||
{
|
||||
clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
var testBeatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = new ControlPointInfo
|
||||
@ -62,8 +67,8 @@ namespace osu.Game.Tests.Visual
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[] { composer = new TestHitObjectComposer(new OsuRuleset()) },
|
||||
new Drawable[] { new TimingPointVisualiser(testBeatmap, track) },
|
||||
new Drawable[] { composer = new TestHitObjectComposer(new OsuRuleset(), clock, clock) },
|
||||
new Drawable[] { new TimingPointVisualiser(testBeatmap, track) { Clock = clock } },
|
||||
},
|
||||
RowDimensions = new[]
|
||||
{
|
||||
@ -92,17 +97,17 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
// Forwards
|
||||
AddStep("Seek(0)", () => composer.SeekTo(0));
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
AddStep("Seek(33)", () => composer.SeekTo(33));
|
||||
AddAssert("Time = 33", () => track.CurrentTime == 33);
|
||||
AddAssert("Time = 33", () => clock.CurrentTime == 33);
|
||||
AddStep("Seek(89)", () => composer.SeekTo(89));
|
||||
AddAssert("Time = 89", () => track.CurrentTime == 89);
|
||||
AddAssert("Time = 89", () => clock.CurrentTime == 89);
|
||||
|
||||
// Backwards
|
||||
AddStep("Seek(25)", () => composer.SeekTo(25));
|
||||
AddAssert("Time = 25", () => track.CurrentTime == 25);
|
||||
AddAssert("Time = 25", () => clock.CurrentTime == 25);
|
||||
AddStep("Seek(0)", () => composer.SeekTo(0));
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -114,19 +119,19 @@ namespace osu.Game.Tests.Visual
|
||||
reset();
|
||||
|
||||
AddStep("Seek(0), Snap", () => composer.SeekTo(0, true));
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
AddStep("Seek(50), Snap", () => composer.SeekTo(50, true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("Seek(100), Snap", () => composer.SeekTo(100, true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("Seek(175), Snap", () => composer.SeekTo(175, true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("Seek(350), Snap", () => composer.SeekTo(350, true));
|
||||
AddAssert("Time = 350", () => track.CurrentTime == 350);
|
||||
AddAssert("Time = 350", () => clock.CurrentTime == 350);
|
||||
AddStep("Seek(400), Snap", () => composer.SeekTo(400, true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("Seek(450), Snap", () => composer.SeekTo(450, true));
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,17 +144,17 @@ namespace osu.Game.Tests.Visual
|
||||
reset();
|
||||
|
||||
AddStep("Seek(24), Snap", () => composer.SeekTo(24, true));
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
AddStep("Seek(26), Snap", () => composer.SeekTo(26, true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("Seek(150), Snap", () => composer.SeekTo(150, true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("Seek(170), Snap", () => composer.SeekTo(170, true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("Seek(274), Snap", () => composer.SeekTo(274, true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("Seek(276), Snap", () => composer.SeekTo(276, true));
|
||||
AddAssert("Time = 350", () => track.CurrentTime == 350);
|
||||
AddAssert("Time = 350", () => clock.CurrentTime == 350);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,15 +165,15 @@ namespace osu.Game.Tests.Visual
|
||||
reset();
|
||||
|
||||
AddStep("SeekForward", () => composer.SeekForward());
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("SeekForward", () => composer.SeekForward());
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("SeekForward", () => composer.SeekForward());
|
||||
AddAssert("Time = 200", () => track.CurrentTime == 200);
|
||||
AddAssert("Time = 200", () => clock.CurrentTime == 200);
|
||||
AddStep("SeekForward", () => composer.SeekForward());
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("SeekForward", () => composer.SeekForward());
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -179,17 +184,17 @@ namespace osu.Game.Tests.Visual
|
||||
reset();
|
||||
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 350", () => track.CurrentTime == 350);
|
||||
AddAssert("Time = 350", () => clock.CurrentTime == 350);
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -202,28 +207,28 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("Seek(49)", () => composer.SeekTo(49));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("Seek(49.999)", () => composer.SeekTo(49.999));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("Seek(99)", () => composer.SeekTo(99));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("Seek(99.999)", () => composer.SeekTo(99.999));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("Seek(174)", () => composer.SeekTo(174));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("Seek(349)", () => composer.SeekTo(349));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 350", () => track.CurrentTime == 350);
|
||||
AddAssert("Time = 350", () => clock.CurrentTime == 350);
|
||||
AddStep("Seek(399)", () => composer.SeekTo(399));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("Seek(449)", () => composer.SeekTo(449));
|
||||
AddStep("SeekForward, Snap", () => composer.SeekForward(true));
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -235,17 +240,17 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("Seek(450)", () => composer.SeekTo(450));
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 425", () => track.CurrentTime == 425);
|
||||
AddAssert("Time = 425", () => clock.CurrentTime == 425);
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 375", () => track.CurrentTime == 375);
|
||||
AddAssert("Time = 375", () => clock.CurrentTime == 375);
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 325", () => track.CurrentTime == 325);
|
||||
AddAssert("Time = 325", () => clock.CurrentTime == 325);
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 125", () => track.CurrentTime == 125);
|
||||
AddAssert("Time = 125", () => clock.CurrentTime == 125);
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 25", () => track.CurrentTime == 25);
|
||||
AddAssert("Time = 25", () => clock.CurrentTime == 25);
|
||||
AddStep("SeekBackward", () => composer.SeekBackward());
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -257,17 +262,17 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("Seek(450)", () => composer.SeekTo(450));
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 350", () => track.CurrentTime == 350);
|
||||
AddAssert("Time = 350", () => clock.CurrentTime == 350);
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 175", () => track.CurrentTime == 175);
|
||||
AddAssert("Time = 175", () => clock.CurrentTime == 175);
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 100", () => track.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => clock.CurrentTime == 100);
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 50", () => track.CurrentTime == 50);
|
||||
AddAssert("Time = 50", () => clock.CurrentTime == 50);
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -280,16 +285,16 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("Seek(451)", () => composer.SeekTo(451));
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
AddStep("Seek(450.999)", () => composer.SeekTo(450.999));
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 450", () => track.CurrentTime == 450);
|
||||
AddAssert("Time = 450", () => clock.CurrentTime == 450);
|
||||
AddStep("Seek(401)", () => composer.SeekTo(401));
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
AddStep("Seek(401.999)", () => composer.SeekTo(401.999));
|
||||
AddStep("SeekBackward, Snap", () => composer.SeekBackward(true));
|
||||
AddAssert("Time = 400", () => track.CurrentTime == 400);
|
||||
AddAssert("Time = 400", () => clock.CurrentTime == 400);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -307,23 +312,23 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
AddStep("SeekForward, Snap", () =>
|
||||
{
|
||||
lastTime = track.CurrentTime;
|
||||
lastTime = clock.CurrentTime;
|
||||
composer.SeekForward(true);
|
||||
});
|
||||
AddAssert("Time > lastTime", () => track.CurrentTime > lastTime);
|
||||
AddAssert("Time > lastTime", () => clock.CurrentTime > lastTime);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
AddStep("SeekBackward, Snap", () =>
|
||||
{
|
||||
lastTime = track.CurrentTime;
|
||||
lastTime = clock.CurrentTime;
|
||||
composer.SeekBackward(true);
|
||||
});
|
||||
AddAssert("Time < lastTime", () => track.CurrentTime < lastTime);
|
||||
AddAssert("Time < lastTime", () => clock.CurrentTime < lastTime);
|
||||
}
|
||||
|
||||
AddAssert("Time = 0", () => track.CurrentTime == 0);
|
||||
AddAssert("Time = 0", () => clock.CurrentTime == 0);
|
||||
}
|
||||
|
||||
private void reset()
|
||||
@ -333,8 +338,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
private class TestHitObjectComposer : HitObjectComposer
|
||||
{
|
||||
public TestHitObjectComposer(Ruleset ruleset)
|
||||
: base(ruleset)
|
||||
public TestHitObjectComposer(Ruleset ruleset, IAdjustableClock adjustableClock, IFrameBasedClock framedClock)
|
||||
: base(ruleset, adjustableClock, framedClock)
|
||||
{
|
||||
}
|
||||
|
||||
@ -409,7 +414,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
base.Update();
|
||||
|
||||
tracker.X = (float)(track.CurrentTime / track.Length);
|
||||
tracker.X = (float)(Time.Current / track.Length);
|
||||
}
|
||||
|
||||
private class TimingPointTimeline : CompositeDrawable
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Timing;
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -62,7 +63,9 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
});
|
||||
|
||||
Child = new OsuHitObjectComposer(new OsuRuleset());
|
||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
Child = new OsuHitObjectComposer(new OsuRuleset(), clock, clock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
using OpenTK;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Timing;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@ -29,8 +30,10 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
random = new Random(1337);
|
||||
|
||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
SummaryTimeline summaryTimeline;
|
||||
Add(summaryTimeline = new SummaryTimeline
|
||||
Add(summaryTimeline = new SummaryTimeline(clock)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -15,7 +16,9 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public TestCasePlaybackControl()
|
||||
{
|
||||
var playback = new PlaybackControl
|
||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
var playback = new PlaybackControl(clock)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
Loading…
Reference in New Issue
Block a user