mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 18:07:25 +08:00
Merge pull request #15757 from smoogipoo/fix-multiplayer-tests
Fix several intermittent multiplayer test failures
This commit is contained in:
commit
049f25a133
@ -72,7 +72,7 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
RoomManager.CreateRoom(newRoom);
|
RoomManager.CreateRoom(newRoom);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for room join", () => Client.Room != null);
|
AddUntilStep("wait for room join", () => RoomJoined);
|
||||||
checkPlayingUserCount(1);
|
checkPlayingUserCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -92,7 +93,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for join", () => Client.Room != null);
|
AddUntilStep("wait for join", () => RoomManager.RoomJoined);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -104,23 +105,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
protected void RunGameplay()
|
protected void RunGameplay()
|
||||||
{
|
{
|
||||||
AddUntilStep("wait for idle", () => Client.LocalUser?.State == MultiplayerUserState.Idle);
|
AddUntilStep("wait for idle", () => Client.LocalUser?.State == MultiplayerUserState.Idle);
|
||||||
|
clickReadyButton();
|
||||||
AddStep("click ready button", () =>
|
|
||||||
{
|
|
||||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerReadyButton>().Single());
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for ready", () => Client.LocalUser?.State == MultiplayerUserState.Ready);
|
AddUntilStep("wait for ready", () => Client.LocalUser?.State == MultiplayerUserState.Ready);
|
||||||
|
clickReadyButton();
|
||||||
AddStep("click ready button", () =>
|
|
||||||
{
|
|
||||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerReadyButton>().Single());
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player player && player.IsLoaded);
|
AddUntilStep("wait for player", () => multiplayerScreenStack.CurrentScreen is Player player && player.IsLoaded);
|
||||||
AddStep("exit player", () => multiplayerScreenStack.MultiplayerScreen.MakeCurrent());
|
AddStep("exit player", () => multiplayerScreenStack.MultiplayerScreen.MakeCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clickReadyButton()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for ready button to be enabled", () => this.ChildrenOfType<MultiplayerReadyButton>().Single().ChildrenOfType<Button>().Single().Enabled.Value);
|
||||||
|
|
||||||
|
AddStep("click ready button", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerReadyButton>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("Press select", () => InputManager.Key(Key.Enter));
|
AddStep("Press select", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => roomManager.RoomJoined);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -293,7 +293,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("join room", () => InputManager.Key(Key.Enter));
|
AddStep("join room", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => roomManager.RoomJoined);
|
||||||
|
|
||||||
AddAssert("Check participant count correct", () => client.APIRoom?.ParticipantCount.Value == 1);
|
AddAssert("Check participant count correct", () => client.APIRoom?.ParticipantCount.Value == 1);
|
||||||
AddAssert("Check participant list contains user", () => client.APIRoom?.RecentParticipants.Count(u => u.Id == API.LocalUser.Value.Id) == 1);
|
AddAssert("Check participant list contains user", () => client.APIRoom?.RecentParticipants.Count(u => u.Id == API.LocalUser.Value.Id) == 1);
|
||||||
@ -351,7 +351,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
|
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
|
||||||
|
|
||||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => roomManager.RoomJoined);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -618,7 +618,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("join room", () => InputManager.Key(Key.Enter));
|
AddStep("join room", () => InputManager.Key(Key.Enter));
|
||||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => roomManager.RoomJoined);
|
||||||
|
|
||||||
AddAssert("local room has correct settings", () =>
|
AddAssert("local room has correct settings", () =>
|
||||||
{
|
{
|
||||||
@ -644,7 +644,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => roomManager.RoomJoined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for join", () => Client.Room != null);
|
AddUntilStep("wait for join", () => RoomJoined);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for room join", () => Client.Room != null);
|
AddUntilStep("wait for room join", () => RoomJoined);
|
||||||
|
|
||||||
AddStep("join other user (ready)", () =>
|
AddStep("join other user (ready)", () =>
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -198,11 +199,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}, users);
|
}, users);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addClickButtonStep() => AddStep("click button", () =>
|
private void addClickButtonStep()
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(button);
|
AddUntilStep("wait for button to be ready", () => button.ChildrenOfType<Button>().Single().Enabled.Value);
|
||||||
InputManager.Click(MouseButton.Left);
|
AddStep("click button", () =>
|
||||||
});
|
{
|
||||||
|
InputManager.MoveMouseTo(button);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyGameplayStartFlow()
|
private void verifyGameplayStartFlow()
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for join", () => client.Room != null);
|
AddUntilStep("wait for join", () => multiplayerScreenStack.RoomManager.RoomJoined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,11 +160,10 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
foreach (var user in joinedRoom.Users)
|
foreach (var user in joinedRoom.Users)
|
||||||
updateUserPlayingState(user.UserID, user.State);
|
updateUserPlayingState(user.UserID, user.State);
|
||||||
|
|
||||||
|
updateLocalRoomSettings(joinedRoom.Settings);
|
||||||
|
|
||||||
OnRoomJoined();
|
OnRoomJoined();
|
||||||
}, cancellationSource.Token).ConfigureAwait(false);
|
}, cancellationSource.Token).ConfigureAwait(false);
|
||||||
|
|
||||||
// Update room settings.
|
|
||||||
await updateLocalRoomSettings(joinedRoom.Settings, cancellationSource.Token).ConfigureAwait(false);
|
|
||||||
}, cancellationSource.Token).ConfigureAwait(false);
|
}, cancellationSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,8 +446,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.SettingsChanged(MultiplayerRoomSettings newSettings)
|
Task IMultiplayerClient.SettingsChanged(MultiplayerRoomSettings newSettings)
|
||||||
{
|
{
|
||||||
// Do not return this task, as it will cause tests to deadlock.
|
Scheduler.Add(() => updateLocalRoomSettings(newSettings));
|
||||||
updateLocalRoomSettings(newSettings);
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,8 +683,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// This updates both the joined <see cref="MultiplayerRoom"/> and the respective API <see cref="Room"/>.
|
/// This updates both the joined <see cref="MultiplayerRoom"/> and the respective API <see cref="Room"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="settings">The new <see cref="MultiplayerRoomSettings"/> to update from.</param>
|
/// <param name="settings">The new <see cref="MultiplayerRoomSettings"/> to update from.</param>
|
||||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to cancel the update.</param>
|
private void updateLocalRoomSettings(MultiplayerRoomSettings settings)
|
||||||
private Task updateLocalRoomSettings(MultiplayerRoomSettings settings, CancellationToken cancellationToken = default) => scheduleAsync(() =>
|
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
@ -701,7 +698,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
|
|
||||||
CurrentMatchPlayingItem.Value = APIRoom.Playlist.SingleOrDefault(p => p.ID == settings.PlaylistItemId);
|
CurrentMatchPlayingItem.Value = APIRoom.Playlist.SingleOrDefault(p => p.ID == settings.PlaylistItemId);
|
||||||
}, cancellationToken);
|
}
|
||||||
|
|
||||||
private async Task<PlaylistItem> createPlaylistItem(MultiplayerPlaylistItem item)
|
private async Task<PlaylistItem> createPlaylistItem(MultiplayerPlaylistItem item)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +93,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (!isConnected.Value)
|
if (!isConnected.Value)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
|
if (client.Room != null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
return base.Poll();
|
return base.Poll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
|
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
|
||||||
|
|
||||||
|
public bool RoomJoined => RoomManager.RoomJoined;
|
||||||
|
|
||||||
private readonly bool joinRoom;
|
private readonly bool joinRoom;
|
||||||
|
|
||||||
protected MultiplayerTestScene(bool joinRoom = true)
|
protected MultiplayerTestScene(bool joinRoom = true)
|
||||||
@ -61,7 +63,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
if (joinRoom)
|
if (joinRoom)
|
||||||
{
|
{
|
||||||
AddStep("join room", () => RoomManager.CreateRoom(SelectedRoom.Value));
|
AddStep("join room", () => RoomManager.CreateRoom(SelectedRoom.Value));
|
||||||
AddUntilStep("wait for room join", () => Client.Room != null);
|
AddUntilStep("wait for room join", () => RoomJoined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
@ -15,6 +16,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TestMultiplayerRoomManager : MultiplayerRoomManager
|
public class TestMultiplayerRoomManager : MultiplayerRoomManager
|
||||||
{
|
{
|
||||||
|
public bool RoomJoined { get; private set; }
|
||||||
|
|
||||||
private readonly TestRoomRequestsHandler requestsHandler;
|
private readonly TestRoomRequestsHandler requestsHandler;
|
||||||
|
|
||||||
public TestMultiplayerRoomManager(TestRoomRequestsHandler requestsHandler)
|
public TestMultiplayerRoomManager(TestRoomRequestsHandler requestsHandler)
|
||||||
@ -24,6 +27,30 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public IReadOnlyList<Room> ServerSideRooms => requestsHandler.ServerSideRooms;
|
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>
|
/// <summary>
|
||||||
/// Adds a room to a local "server-side" list that's returned when a <see cref="GetRoomsRequest"/> is fired.
|
/// Adds a room to a local "server-side" list that's returned when a <see cref="GetRoomsRequest"/> is fired.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user