1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Fix gameplay start flow

This commit is contained in:
Dean Herbert 2022-04-13 20:57:40 +09:00
parent 8a7b37856c
commit c0ad91796d
2 changed files with 8 additions and 10 deletions

View File

@ -3,7 +3,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -69,9 +68,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
raiseRoomUpdated();
});
// We don't want to have to handle entering into actual gameplay in this test.
// Returning a failed task should always allow the button to always stay in a clickable state.
multiplayerClient.Setup(m => m.StartMatch()).Returns(Task.FromException<InvalidOperationException>(new InvalidOperationException()));
multiplayerClient.Setup(m => m.StartMatch())
.Callback(() => multiplayerClient.Raise(m => m.LoadRequested -= null));
multiplayerClient.Setup(m => m.SendMatchRequest(It.IsAny<MatchUserRequest>()))
.Callback((MatchUserRequest request) =>
@ -384,13 +382,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddUntilStep("user is ready", () => localUser.State == MultiplayerUserState.Ready);
ClickButtonWhenEnabled<MultiplayerReadyButton>();
AddStep("check start request received", () => multiplayerClient.Verify(m => m.StartMatch(), Times.Once));
AddUntilStep("user waiting for load", () => localUser.State == MultiplayerUserState.WaitingForLoad);
AddStep("finish gameplay", () =>
{
changeUserState(localUser.UserID, MultiplayerUserState.Loaded);
changeUserState(localUser.UserID, MultiplayerUserState.FinishedPlay);
});
AddUntilStep("ready button disabled", () => !control.ChildrenOfType<OsuButton>().Single().Enabled.Value);
AddStep("finish gameplay", () => changeUserState(localUser.UserID, MultiplayerUserState.Idle));
AddUntilStep("ready button enabled", () => control.ChildrenOfType<OsuButton>().Single().Enabled.Value);
}

View File

@ -67,7 +67,7 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// Invoked when the multiplayer server requests the current beatmap to be loaded into play.
/// </summary>
public event Action? LoadRequested;
public virtual event Action? LoadRequested;
/// <summary>
/// Invoked when the multiplayer server requests gameplay to be started.