1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add failing assertions to hit error meter test

This commit is contained in:
Bartłomiej Dach 2021-06-07 12:25:48 +02:00
parent 122a624b7f
commit 37d062c7cd
3 changed files with 18 additions and 4 deletions

View File

@ -4,10 +4,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
@ -86,6 +88,18 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestEmpty()
{
AddStep("empty windows", () => recreateDisplay(HitWindows.Empty, 5));
AddStep("hit", () => newJudgement());
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
AddAssert("circle added", () =>
this.ChildrenOfType<ColourHitErrorMeter>().All(
meter => meter.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() == 1));
AddStep("miss", () => newJudgement(50, HitResult.Miss));
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
AddAssert("circle added", () =>
this.ChildrenOfType<ColourHitErrorMeter>().All(
meter => meter.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() == 2));
}
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
@ -152,12 +166,12 @@ namespace osu.Game.Tests.Visual.Gameplay
});
}
private void newJudgement(double offset = 0)
private void newJudgement(double offset = 0, HitResult result = HitResult.Perfect)
{
scoreProcessor.ApplyResult(new JudgementResult(new HitCircle { HitWindows = drawableRuleset.HitWindows }, new Judgement())
{
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
Type = HitResult.Perfect,
Type = result,
});
}

View File

@ -244,7 +244,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private float getRelativeJudgementPosition(double value) => Math.Clamp((float)((value / maxHitWindow) + 1) / 2, 0, 1);
private class JudgementLine : CompositeDrawable
internal class JudgementLine : CompositeDrawable
{
private const int judgement_fade_duration = 5000;

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
}
}
private class HitErrorCircle : Container
internal class HitErrorCircle : Container
{
public bool IsRemoved { get; private set; }