Merge pull request #15757 from smoogipoo/fix-multiplayer-tests

Fix several intermittent multiplayer test failures
This commit is contained in:
Dean Herbert
2021-11-24 09:32:01 +09:00
committed by GitHub
10 changed files with 71 additions and 35 deletions

View File

@ -24,6 +24,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
public bool RoomJoined => RoomManager.RoomJoined;
private readonly bool joinRoom;
protected MultiplayerTestScene(bool joinRoom = true)
@ -61,7 +63,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
if (joinRoom)
{
AddStep("join room", () => RoomManager.CreateRoom(SelectedRoom.Value));
AddUntilStep("wait for room join", () => Client.Room != null);
AddUntilStep("wait for room join", () => RoomJoined);
}
}

View File

@ -1,6 +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 System.Collections.Generic;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
@ -15,6 +16,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
/// </summary>
public class TestMultiplayerRoomManager : MultiplayerRoomManager
{
public bool RoomJoined { get; private set; }
private readonly TestRoomRequestsHandler requestsHandler;
public TestMultiplayerRoomManager(TestRoomRequestsHandler requestsHandler)
@ -24,6 +27,30 @@ namespace osu.Game.Tests.Visual.Multiplayer
public IReadOnlyList<Room> ServerSideRooms => requestsHandler.ServerSideRooms;
public override void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
{
base.CreateRoom(room, r =>
{
onSuccess?.Invoke(r);
RoomJoined = true;
}, onError);
}
public override void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null)
{
base.JoinRoom(room, password, r =>
{
onSuccess?.Invoke(r);
RoomJoined = true;
}, onError);
}
public override void PartRoom()
{
base.PartRoom();
RoomJoined = false;
}
/// <summary>
/// Adds a room to a local "server-side" list that's returned when a <see cref="GetRoomsRequest"/> is fired.
/// </summary>