1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 04:52:53 +08:00

Make test actually test drum behaviours

This commit is contained in:
Dean Herbert 2022-07-22 16:18:14 +09:00
parent c32af3c041
commit b884ed2a3d

View File

@ -1,55 +1,50 @@
// 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.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Beatmaps; using osu.Framework.Graphics;
using osu.Game.Rulesets.Taiko.Objects; using osu.Framework.Testing;
using osu.Game.Rulesets.Taiko.UI; using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests namespace osu.Game.Rulesets.Taiko.Tests
{ {
[TestFixture] [TestFixture]
public class TestSceneDrumTouchInputArea : DrawableTaikoRulesetTestScene public class TestSceneDrumTouchInputArea : OsuTestScene
{ {
protected const double NUM_HIT_OBJECTS = 10; [Cached]
protected const double HIT_OBJECT_TIME_SPACING_MS = 1000; private TaikoInputManager taikoInputManager = new TaikoInputManager(new TaikoRuleset().RulesetInfo);
[BackgroundDependencyLoader] private DrumTouchInputArea drumTouchInputArea = null!;
private void load()
{
var drumTouchInputArea = new DrumTouchInputArea();
DrawableRuleset.KeyBindingInputManager.Add(drumTouchInputArea);
drumTouchInputArea.ShowTouchControls();
}
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) [SetUpSteps]
public void SetUpSteps()
{ {
List<TaikoHitObject> hitObjects = new List<TaikoHitObject>(); AddStep("create drum", () =>
for (int i = 0; i < NUM_HIT_OBJECTS; i++)
{ {
hitObjects.Add(new Hit Children = new Drawable[]
{ {
StartTime = Time.Current + i * HIT_OBJECT_TIME_SPACING_MS, new InputDrum
IsStrong = isOdd(i), {
Type = isOdd(i / 2) ? HitType.Centre : HitType.Rim Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Height = 0.5f,
},
drumTouchInputArea = new DrumTouchInputArea
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Height = 0.5f,
},
};
}); });
} }
var beatmap = new Beatmap<TaikoHitObject> [Test]
public void TestDrum()
{ {
BeatmapInfo = { Ruleset = ruleset }, AddStep("show drum", () => drumTouchInputArea.Show());
HitObjects = hitObjects
};
return beatmap;
}
private bool isOdd(int number)
{
return number % 2 == 0;
} }
} }
} }