From 8c36604e58e84265d623f0ec19e3eec85370ef4d Mon Sep 17 00:00:00 2001 From: Poyo Date: Sun, 12 Nov 2023 11:16:06 -0800 Subject: [PATCH] Add rate-change UR tests --- .../NonVisual/Ranking/UnstableRateTest.cs | 32 +++++++++++++++++++ .../Gameplay/TestSceneUnstableRateCounter.cs | 22 +++++++++++++ 2 files changed, 54 insertions(+) diff --git a/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs b/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs index bde3c37af7..5a416d05d7 100644 --- a/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs +++ b/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs @@ -42,5 +42,37 @@ public void TestMissesAndEmptyWindows() Assert.AreEqual(0, unstableRate.Value); } + + [Test] + public void TestStaticRateChange() + { + var events = new[] + { + new HitEvent(-150, 1.5, HitResult.Great, new HitObject(), null, null), + new HitEvent(-150, 1.5, HitResult.Great, new HitObject(), null, null), + new HitEvent(150, 1.5, HitResult.Great, new HitObject(), null, null), + new HitEvent(150, 1.5, HitResult.Great, new HitObject(), null, null), + }; + + var unstableRate = new UnstableRate(events); + + Assert.AreEqual(10 * 100, unstableRate.Value); + } + + [Test] + public void TestDynamicRateChange() + { + var events = new[] + { + new HitEvent(-50, 0.5, HitResult.Great, new HitObject(), null, null), + new HitEvent(75, 0.75, HitResult.Great, new HitObject(), null, null), + new HitEvent(-100, 1.0, HitResult.Great, new HitObject(), null, null), + new HitEvent(125, 1.25, HitResult.Great, new HitObject(), null, null), + }; + + var unstableRate = new UnstableRate(events); + + Assert.AreEqual(10 * 100, unstableRate.Value); + } } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs index f6c819b329..73ec6ea335 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -81,6 +82,27 @@ public void TestCounterReceivesJudgementsBeforeCreation() AddUntilStep("UR = 250", () => counter.Current.Value == 250.0); } + [Test] + public void TestStaticRateChange() + { + AddStep("Create Display", recreateDisplay); + + AddRepeatStep("Set UR to 250 at 1.5x", () => applyJudgement(25, true, 1.5), 4); + + AddUntilStep("UR = 250/1.5", () => counter.Current.Value == Math.Round(250.0 / 1.5)); + } + + [Test] + public void TestDynamicRateChange() + { + AddStep("Create Display", recreateDisplay); + + AddRepeatStep("Set UR to 100 at 1.0x", () => applyJudgement(10, true, 1.0), 4); + AddRepeatStep("Bring UR to 100 at 1.5x", () => applyJudgement(15, true, 1.5), 4); + + AddUntilStep("UR = 100", () => counter.Current.Value == 100.0); + } + private void recreateDisplay() { Clear();