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

View File

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