2019-06-13 13:41:10 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
2020-01-09 12:43:44 +08:00
|
|
|
using osu.Framework.Utils;
|
2019-06-13 13:41:10 +08:00
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-11-21 17:50:54 +08:00
|
|
|
using osu.Game.Storyboards;
|
2019-06-13 13:41:10 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2020-06-12 18:40:54 +08:00
|
|
|
public class TestSceneGameplayRewinding : OsuPlayerTestScene
|
2019-06-13 13:41:10 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private AudioManager audioManager { get; set; }
|
|
|
|
|
2020-08-21 16:21:08 +08:00
|
|
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
|
|
|
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
2019-06-13 13:41:10 +08:00
|
|
|
|
|
|
|
[Test]
|
2019-06-14 18:35:47 +08:00
|
|
|
public void TestNoJudgementsOnRewind()
|
2019-06-13 13:41:10 +08:00
|
|
|
{
|
2020-08-21 16:21:08 +08:00
|
|
|
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
2019-06-13 13:41:10 +08:00
|
|
|
addSeekStep(3000);
|
2020-03-05 10:25:07 +08:00
|
|
|
AddAssert("all judged", () => Player.DrawableRuleset.Playfield.AllHitObjects.All(h => h.Judged));
|
|
|
|
AddUntilStep("key counter counted keys", () => Player.HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses >= 7));
|
|
|
|
AddStep("clear results", () => Player.Results.Clear());
|
2019-06-13 13:41:10 +08:00
|
|
|
addSeekStep(0);
|
2020-03-05 10:25:07 +08:00
|
|
|
AddAssert("none judged", () => Player.DrawableRuleset.Playfield.AllHitObjects.All(h => !h.Judged));
|
|
|
|
AddUntilStep("key counters reset", () => Player.HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0));
|
|
|
|
AddAssert("no results triggered", () => Player.Results.Count == 0);
|
2019-06-13 13:41:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void addSeekStep(double time)
|
|
|
|
{
|
2020-08-21 16:21:08 +08:00
|
|
|
AddStep($"seek to {time}", () => Beatmap.Value.Track.Seek(time));
|
2019-06-13 13:41:10 +08:00
|
|
|
|
2019-06-13 14:47:21 +08:00
|
|
|
// Allow a few frames of lenience
|
2020-03-05 10:25:07 +08:00
|
|
|
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(time, Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
2019-06-13 13:41:10 +08:00
|
|
|
}
|
|
|
|
|
2020-03-05 10:25:07 +08:00
|
|
|
protected override TestPlayer CreatePlayer(Ruleset ruleset)
|
2019-06-13 13:41:10 +08:00
|
|
|
{
|
2019-12-13 20:45:38 +08:00
|
|
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
2020-03-05 10:25:07 +08:00
|
|
|
return base.CreatePlayer(ruleset);
|
2019-06-13 13:41:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
|
|
|
{
|
|
|
|
var beatmap = new Beatmap
|
|
|
|
{
|
2021-10-02 11:34:29 +08:00
|
|
|
Difficulty = { ApproachRate = 9 },
|
2019-06-13 13:41:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 0; i < 15; i++)
|
|
|
|
{
|
|
|
|
beatmap.HitObjects.Add(new HitCircle
|
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
StartTime = 1000 + 30 * i
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return beatmap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|