Add failing test coverage for tournament startup states

This commit is contained in:
Dean Herbert 2021-08-28 14:15:47 +09:00
parent 69f5705ca0
commit 7fbeb9ecc7
1 changed files with 22 additions and 4 deletions

View File

@ -4,8 +4,10 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Gameplay;
using osu.Game.Tournament.Screens.Gameplay.Components;
@ -16,16 +18,18 @@ public class TestSceneGameplayScreen : TournamentTestScene
[Cached]
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay { Width = 0.5f };
[BackgroundDependencyLoader]
private void load()
[Test]
public void TestStartupState([Values] TourneyState state)
{
Add(new GameplayScreen());
Add(chat);
AddStep("set state", () => IPCInfo.State.Value = state);
createScreen();
}
[Test]
public void TestWarmup()
{
createScreen();
checkScoreVisibility(false);
toggleWarmup();
@ -35,6 +39,20 @@ public void TestWarmup()
checkScoreVisibility(false);
}
private void createScreen()
{
AddStep("setup screen", () =>
{
Remove(chat);
Children = new Drawable[]
{
new GameplayScreen(),
chat,
};
});
}
private void checkScoreVisibility(bool visible)
=> AddUntilStep($"scores {(visible ? "shown" : "hidden")}",
() => this.ChildrenOfType<TeamScore>().All(score => score.Alpha == (visible ? 1 : 0)));