1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Add tests and clean up inefficient code

This commit is contained in:
Joppe27 2022-11-22 17:22:34 +01:00
parent 5343f6922c
commit db34fa99b1
4 changed files with 79 additions and 61 deletions

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
};
[Test]
public void DrumrollTest()
public void TestDrumroll()
{
AddStep("Drum roll", () => SetContents(_ =>
{
@ -57,6 +57,14 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
}));
}
[Test]
public void TestDrumrollKiai()
{
AddStep("Create beatmap", createBeatmap);
TestDrumroll();
}
private DrumRoll createDrumRollAtCurrentTime(bool strong = false)
{
var drumroll = new DrumRoll
@ -73,5 +81,20 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
return drumroll;
}
private void createBeatmap()
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
Beatmap.Value.Track.Start();
}
}
}

View File

@ -1,30 +0,0 @@
// 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 NUnit.Framework;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableDrumRollKiai : TestSceneDrawableDrumRoll
{
[SetUp]
public void SetUp() => Schedule(() =>
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
// track needs to be playing for BeatSyncedContainer to work.
Beatmap.Value.Track.Start();
});
}
}

View File

@ -4,17 +4,23 @@
#nullable disable
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Screens.Play;
using osu.Game.Tests.Gameplay;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableHit : TaikoSkinnableTestScene
{
[Cached]
private GameplayState gameplayState = TestGameplayState.Create(new TaikoRuleset());
[Test]
public void TestHits()
{
@ -43,6 +49,38 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
}));
}
[Test]
public void TestHitKiai()
{
AddStep("Create beatmap", () => createBeatmap(true));
TestHits();
}
[Test]
public void TestHitAnimationSlow()
{
AddStep("Create beatmap", () => createBeatmap(false));
AddStep("Reset combo", () => gameplayState.ScoreProcessor.Combo.Value = 0);
AddRepeatStep("Increase combo", () => gameplayState.ScoreProcessor.Combo.Value++, 50);
TestHits();
}
[Test]
public void TestHitAnimationFast()
{
AddStep("Create beatmap", () => createBeatmap(false));
AddStep("Reset combo", () => gameplayState.ScoreProcessor.Combo.Value = 0);
AddRepeatStep("Increase combo", () => gameplayState.ScoreProcessor.Combo.Value++, 150);
TestHits();
}
private Hit createHitAtCurrentTime(bool strong = false, bool rim = false)
{
var hit = new Hit
@ -56,5 +94,22 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
return hit;
}
private void createBeatmap(bool includeKiai)
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
if (includeKiai)
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
Beatmap.Value.Track.Start();
}
}
}

View File

@ -1,30 +0,0 @@
// 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 NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{
[TestFixture]
public class TestSceneDrawableHitKiai : TestSceneDrawableHit
{
[SetUp]
public void SetUp() => Schedule(() =>
{
var controlPointInfo = new ControlPointInfo();
controlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
controlPointInfo.Add(0, new EffectControlPoint { KiaiMode = true });
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
ControlPointInfo = controlPointInfo
});
// track needs to be playing for BeatSyncedContainer to work.
Beatmap.Value.Track.Start();
});
}
}