From c0ad91796d75e2f38b5117c0b484589cba1c588b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Apr 2022 20:57:40 +0900 Subject: [PATCH] Fix gameplay start flow --- .../Multiplayer/TestSceneMatchStartControl.cs | 16 +++++++--------- osu.Game/Online/Multiplayer/MultiplayerClient.cs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchStartControl.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchStartControl.cs index bf980b0694..8af1187b67 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchStartControl.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchStartControl.cs @@ -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(new InvalidOperationException())); + multiplayerClient.Setup(m => m.StartMatch()) + .Callback(() => multiplayerClient.Raise(m => m.LoadRequested -= null)); multiplayerClient.Setup(m => m.SendMatchRequest(It.IsAny())) .Callback((MatchUserRequest request) => @@ -384,13 +382,13 @@ namespace osu.Game.Tests.Visual.Multiplayer { AddUntilStep("user is ready", () => localUser.State == MultiplayerUserState.Ready); ClickButtonWhenEnabled(); + + 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().Single().Enabled.Value); + + AddStep("finish gameplay", () => changeUserState(localUser.UserID, MultiplayerUserState.Idle)); AddUntilStep("ready button enabled", () => control.ChildrenOfType().Single().Enabled.Value); } diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index e29aee2c6d..967220abbf 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -67,7 +67,7 @@ namespace osu.Game.Online.Multiplayer /// /// Invoked when the multiplayer server requests the current beatmap to be loaded into play. /// - public event Action? LoadRequested; + public virtual event Action? LoadRequested; /// /// Invoked when the multiplayer server requests gameplay to be started.