mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix further test failures
This commit is contained in:
@ -442,7 +442,12 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task IMultiplayerClient.SettingsChanged(MultiplayerRoomSettings newSettings) => updateLocalRoomSettings(newSettings);
|
Task IMultiplayerClient.SettingsChanged(MultiplayerRoomSettings newSettings)
|
||||||
|
{
|
||||||
|
// Do not return this task, as it will cause tests to deadlock.
|
||||||
|
updateLocalRoomSettings(newSettings);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
Task IMultiplayerClient.UserStateChanged(int userId, MultiplayerUserState state)
|
Task IMultiplayerClient.UserStateChanged(int userId, MultiplayerUserState state)
|
||||||
{
|
{
|
||||||
@ -601,16 +606,17 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
var playlistItem = await createPlaylistItem(item).ConfigureAwait(false);
|
var playlistItem = await createPlaylistItem(item).ConfigureAwait(false);
|
||||||
|
|
||||||
await scheduleAsync(() =>
|
Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.Assert(APIRoom != null);
|
Debug.Assert(APIRoom != null);
|
||||||
|
|
||||||
|
APIRoom.Playlist.RemoveAll(i => i.ID == playlistItem.ID);
|
||||||
APIRoom.Playlist.Add(playlistItem);
|
APIRoom.Playlist.Add(playlistItem);
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
}).ConfigureAwait(false);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task PlaylistItemRemoved(long playlistItemId)
|
public Task PlaylistItemRemoved(long playlistItemId)
|
||||||
@ -618,7 +624,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
if (Room == null)
|
if (Room == null)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
return scheduleAsync(() =>
|
Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
@ -628,6 +634,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
APIRoom.Playlist.RemoveAll(i => i.ID == playlistItemId);
|
APIRoom.Playlist.RemoveAll(i => i.ID == playlistItemId);
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PlaylistItemChanged(APIPlaylistItem item)
|
public async Task PlaylistItemChanged(APIPlaylistItem item)
|
||||||
@ -637,7 +645,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
var playlistItem = await createPlaylistItem(item).ConfigureAwait(false);
|
var playlistItem = await createPlaylistItem(item).ConfigureAwait(false);
|
||||||
|
|
||||||
await scheduleAsync(() =>
|
Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
@ -658,7 +666,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
CurrentMatchPlayingItem.Value = APIRoom.Playlist[index];
|
CurrentMatchPlayingItem.Value = APIRoom.Playlist[index];
|
||||||
|
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
}).ConfigureAwait(false);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -41,8 +41,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; } = null!;
|
private BeatmapManager beatmaps { get; set; } = null!;
|
||||||
|
|
||||||
|
private readonly List<APIPlaylistItem> playlistItems = new List<APIPlaylistItem>();
|
||||||
private readonly TestMultiplayerRoomManager roomManager;
|
private readonly TestMultiplayerRoomManager roomManager;
|
||||||
private PlaylistItem? currentItem;
|
private APIPlaylistItem? currentItem;
|
||||||
|
|
||||||
public TestMultiplayerClient(TestMultiplayerRoomManager roomManager)
|
public TestMultiplayerClient(TestMultiplayerRoomManager roomManager)
|
||||||
{
|
{
|
||||||
@ -139,7 +140,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
((IMultiplayerClient)this).ResultsReady();
|
((IMultiplayerClient)this).ResultsReady();
|
||||||
|
|
||||||
Task.Run(finishCurrentItem);
|
finishCurrentItem().Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -161,6 +162,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
if (password != apiRoom.Password.Value)
|
if (password != apiRoom.Password.Value)
|
||||||
throw new InvalidOperationException("Invalid password.");
|
throw new InvalidOperationException("Invalid password.");
|
||||||
|
|
||||||
|
playlistItems.AddRange(apiRoom.Playlist.Select(i => new APIPlaylistItem(i)));
|
||||||
|
|
||||||
var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
var localUser = new MultiplayerRoomUser(api.LocalUser.Value.Id)
|
||||||
{
|
{
|
||||||
User = api.LocalUser.Value
|
User = api.LocalUser.Value
|
||||||
@ -198,10 +201,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
changeMatchType(Room.Settings.MatchType).Wait();
|
changeMatchType(Room.Settings.MatchType).Wait();
|
||||||
|
|
||||||
// emulate the server sending all playlist items after room join.
|
// emulate the server sending all playlist items after room join.
|
||||||
var serverSideRom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == APIRoom.RoomID.Value);
|
var serverSideRoom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == APIRoom.RoomID.Value);
|
||||||
|
Task.WhenAll(serverSideRoom.Playlist.Select(i => ((IMultiplayerClient)this).PlaylistItemAdded(new APIPlaylistItem(i)))).Wait();
|
||||||
foreach (var playlistItem in serverSideRom.Playlist)
|
|
||||||
((IMultiplayerClient)this).PlaylistItemAdded(new APIPlaylistItem(playlistItem)).Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task LeaveRoomInternal() => Task.CompletedTask;
|
protected override Task LeaveRoomInternal() => Task.CompletedTask;
|
||||||
@ -311,6 +312,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
case QueueModes.HostOnly:
|
case QueueModes.HostOnly:
|
||||||
// In host-only mode, the current item is re-used.
|
// In host-only mode, the current item is re-used.
|
||||||
item.ID = currentItem.ID;
|
item.ID = currentItem.ID;
|
||||||
|
playlistItems[playlistItems.FindIndex(i => i == currentItem)] = item;
|
||||||
await ((IMultiplayerClient)this).PlaylistItemChanged(item).ConfigureAwait(false);
|
await ((IMultiplayerClient)this).PlaylistItemChanged(item).ConfigureAwait(false);
|
||||||
|
|
||||||
// Note: Unlike the server, this is the easiest way to update the current item at this point.
|
// Note: Unlike the server, this is the easiest way to update the current item at this point.
|
||||||
@ -318,7 +320,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
item.ID = APIRoom.Playlist.Last().ID + 1;
|
item.ID = playlistItems.Last().ID + 1;
|
||||||
|
playlistItems.Add(item);
|
||||||
await ((IMultiplayerClient)this).PlaylistItemAdded(item).ConfigureAwait(false);
|
await ((IMultiplayerClient)this).PlaylistItemAdded(item).ConfigureAwait(false);
|
||||||
await updateCurrentItem().ConfigureAwait(false);
|
await updateCurrentItem().ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
@ -384,7 +387,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
if (newMode == QueueModes.HostOnly)
|
if (newMode == QueueModes.HostOnly)
|
||||||
{
|
{
|
||||||
foreach (var playlistItem in APIRoom.Playlist.Where(i => !i.Expired && i.ID != currentItem.ID).ToArray())
|
foreach (var playlistItem in playlistItems.Where(i => !i.Expired && i.ID != currentItem.ID).ToArray())
|
||||||
await ((IMultiplayerClient)this).PlaylistItemRemoved(playlistItem.ID).ConfigureAwait(false);
|
await ((IMultiplayerClient)this).PlaylistItemRemoved(playlistItem.ID).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +402,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Debug.Assert(currentItem != null);
|
Debug.Assert(currentItem != null);
|
||||||
|
|
||||||
// Expire the current playlist item.
|
// Expire the current playlist item.
|
||||||
await ((IMultiplayerClient)this).PlaylistItemChanged(new APIPlaylistItem(currentItem) { Expired = true }).ConfigureAwait(false);
|
currentItem.Expired = true;
|
||||||
|
await ((IMultiplayerClient)this).PlaylistItemChanged(currentItem).ConfigureAwait(false);
|
||||||
|
|
||||||
// In host-only mode, a duplicate playlist item will be used for the next round.
|
// In host-only mode, a duplicate playlist item will be used for the next round.
|
||||||
if (Room.Settings.QueueMode == QueueModes.HostOnly)
|
if (Room.Settings.QueueMode == QueueModes.HostOnly)
|
||||||
@ -414,17 +418,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Debug.Assert(APIRoom != null);
|
Debug.Assert(APIRoom != null);
|
||||||
Debug.Assert(currentItem != null);
|
Debug.Assert(currentItem != null);
|
||||||
|
|
||||||
var newItem = new PlaylistItem
|
var newItem = new APIPlaylistItem
|
||||||
{
|
{
|
||||||
ID = APIRoom.Playlist.Last().ID + 1,
|
ID = playlistItems.Last().ID + 1,
|
||||||
BeatmapID = currentItem.BeatmapID,
|
BeatmapID = currentItem.BeatmapID,
|
||||||
|
BeatmapChecksum = currentItem.BeatmapChecksum,
|
||||||
RulesetID = currentItem.RulesetID,
|
RulesetID = currentItem.RulesetID,
|
||||||
|
RequiredMods = currentItem.RequiredMods,
|
||||||
|
AllowedMods = currentItem.AllowedMods
|
||||||
};
|
};
|
||||||
|
|
||||||
newItem.AllowedMods.AddRange(currentItem.AllowedMods);
|
playlistItems.Add(newItem);
|
||||||
newItem.RequiredMods.AddRange(currentItem.AllowedMods);
|
await ((IMultiplayerClient)this).PlaylistItemAdded(newItem).ConfigureAwait(false);
|
||||||
|
|
||||||
await ((IMultiplayerClient)this).PlaylistItemAdded(new APIPlaylistItem(newItem)).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task updateCurrentItem(bool notify = true, Room? apiRoom = null)
|
private async Task updateCurrentItem(bool notify = true, Room? apiRoom = null)
|
||||||
@ -439,7 +444,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
// Pick the single non-expired playlist item.
|
// Pick the single non-expired playlist item.
|
||||||
currentItem = apiRoom.Playlist.FirstOrDefault(i => !i.Expired) ?? apiRoom.Playlist.Last();
|
currentItem = playlistItems.FirstOrDefault(i => !i.Expired) ?? playlistItems.Last();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QueueModes.FairRotate:
|
case QueueModes.FairRotate:
|
||||||
|
Reference in New Issue
Block a user