Centralise all multiplayer button clicking test logic

This adds the "wait for enabled" check in a way that can be easily
reused, as it keeps getting missed in test implementations.

This particular commit hopefully fixes
https://github.com/ppy/osu/runs/4583845033?check_suite_focus=true.
This commit is contained in:
Dean Herbert
2021-12-21 13:20:12 +09:00
parent 377cb1d9e3
commit 9aff646ff4
6 changed files with 48 additions and 94 deletions

View File

@ -14,12 +14,10 @@ using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Multiplayer;
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Multiplayer
{
@ -62,22 +60,17 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestCreatedRoom()
{
AddStep("create room", () =>
AddStep("add playlist item", () =>
{
SelectedRoom.Value.Playlist.Add(new PlaylistItem
{
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
Ruleset = { Value = new OsuRuleset().RulesetInfo },
});
// Needs to run after components update with the playlist item.
Schedule(() =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>().Single());
InputManager.Click(MouseButton.Left);
});
});
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
AddUntilStep("wait for join", () => RoomJoined);
}
@ -110,11 +103,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
});
});
AddStep("click create button", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>().Single());
InputManager.Click(MouseButton.Left);
});
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
AddUntilStep("wait for room join", () => RoomJoined);
@ -124,21 +113,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
Client.ChangeUserState(PLAYER_1_ID, MultiplayerUserState.Ready);
});
AddStep("click spectate button", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerSpectateButton>().Single());
InputManager.Click(MouseButton.Left);
});
ClickButtonWhenEnabled<MultiplayerSpectateButton>();
AddUntilStep("wait for spectating user state", () => Client.LocalUser?.State == MultiplayerUserState.Spectating);
AddUntilStep("wait for ready button to be enabled", () => this.ChildrenOfType<MultiplayerReadyButton>().Single().ChildrenOfType<ReadyButton>().Single().Enabled.Value);
AddStep("click ready button", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerReadyButton>().Single());
InputManager.Click(MouseButton.Left);
});
ClickButtonWhenEnabled<MultiplayerReadyButton>();
AddUntilStep("match started", () => Client.Room?.State == MultiplayerRoomState.WaitingForLoad);
}