1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-10 18:17:19 +08:00

Split out methods so retrieving the room is not a callback function

This commit is contained in:
Dean Herbert 2025-03-04 19:19:53 +09:00
parent b19c2c7f9f
commit 918315aa65
No known key found for this signature in database
10 changed files with 43 additions and 34 deletions

View File

@ -19,7 +19,8 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
public override void SetUpSteps()
{
base.SetUpSteps();
JoinDefaultRoom();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
}
[Test]

View File

@ -24,7 +24,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
JoinDefaultRoom();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
AddStep("reset", () =>
{

View File

@ -66,7 +66,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("clear playing users", () => playingUsers.Clear());
JoinDefaultRoom(r => room = r);
AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
}
[TestCase(1)]

View File

@ -62,7 +62,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override void SetUpSteps()
{
base.SetUpSteps();
JoinDefaultRoom(r => room = r);
AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
}
private void setUp()

View File

@ -32,7 +32,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
JoinDefaultRoom();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
createNewParticipantsList();
}

View File

@ -25,7 +25,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override void SetUpSteps()
{
base.SetUpSteps();
JoinDefaultRoom();
AddStep("join room", () => JoinRoom(CreateDefaultRoom()));
WaitForJoined();
}
[Test]

View File

@ -47,7 +47,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
JoinDefaultRoom(r => room = r);
AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
AddStep("create list", () =>
{

View File

@ -43,7 +43,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
JoinDefaultRoom(r => room = r);
AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
AddStep("create playlist", () =>
{

View File

@ -47,7 +47,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
JoinDefaultRoom(r => room = r);
AddStep("create room", () => room = CreateDefaultRoom());
AddStep("join room", () => JoinRoom(room));
WaitForJoined();
AddStep("create button", () =>
{

View File

@ -1,7 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual.OnlinePlay;
@ -24,34 +24,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
public bool RoomJoined => MultiplayerClient.RoomJoined;
protected Room CreateDefaultRoom()
{
return new Room
{
Name = "test name",
Type = MatchType.HeadToHead,
Playlist =
[
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)
{
RulesetID = Ruleset.Value.OnlineID
}
]
};
}
/// <summary>
/// Creates and joins a basic multiplayer room.
/// </summary>
/// <param name="setupFunc">A callback that may be used to further set up the room.</param>
protected void JoinDefaultRoom(Action<Room>? setupFunc = null)
{
AddStep("join room", () =>
{
Room room = new Room
{
Name = "test name",
Type = MatchType.HeadToHead,
Playlist =
[
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)
{
RulesetID = Ruleset.Value.OnlineID
}
]
};
protected void JoinRoom(Room room) => MultiplayerClient.CreateRoom(room).FireAndForget();
setupFunc?.Invoke(room);
MultiplayerClient.CreateRoom(room).ConfigureAwait(false);
});
AddUntilStep("wait for room join", () => RoomJoined);
}
protected void WaitForJoined() => AddUntilStep("wait for room join", () => RoomJoined);
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new MultiplayerTestSceneDependencies();
}