1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Use WaitSafely() in tests where it was not already being used

This commit is contained in:
Dean Herbert 2022-02-15 02:35:08 +09:00
parent b581ca14cc
commit 02f58a82fc
4 changed files with 14 additions and 13 deletions

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
@ -71,7 +72,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("change queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings AddStep("change queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings
{ {
QueueMode = QueueMode.AllPlayers QueueMode = QueueMode.AllPlayers
})); }).WaitSafely());
AddUntilStep("api room updated", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers); AddUntilStep("api room updated", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
} }

View File

@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
importedBeatmap = importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0); importedBeatmap = importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0);
}); });
AddStep("change to all players mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers })); AddStep("change to all players mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }).WaitSafely());
} }
[Test] [Test]
@ -97,19 +97,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
addItemStep(); addItemStep();
addItemStep(); addItemStep();
AddStep("finish current item", () => Client.FinishCurrentItem()); AddStep("finish current item", () => Client.FinishCurrentItem().WaitSafely());
assertItemInHistoryListStep(1, 0); assertItemInHistoryListStep(1, 0);
assertItemInQueueListStep(2, 0); assertItemInQueueListStep(2, 0);
assertItemInQueueListStep(3, 1); assertItemInQueueListStep(3, 1);
AddStep("finish current item", () => Client.FinishCurrentItem()); AddStep("finish current item", () => Client.FinishCurrentItem().WaitSafely());
assertItemInHistoryListStep(2, 0); assertItemInHistoryListStep(2, 0);
assertItemInHistoryListStep(1, 1); assertItemInHistoryListStep(1, 1);
assertItemInQueueListStep(3, 0); assertItemInQueueListStep(3, 0);
AddStep("finish current item", () => Client.FinishCurrentItem()); AddStep("finish current item", () => Client.FinishCurrentItem().WaitSafely());
assertItemInHistoryListStep(3, 0); assertItemInHistoryListStep(3, 0);
assertItemInHistoryListStep(2, 1); assertItemInHistoryListStep(2, 1);
@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestListsClearedWhenRoomLeft() public void TestListsClearedWhenRoomLeft()
{ {
addItemStep(); addItemStep();
AddStep("finish current item", () => Client.FinishCurrentItem()); AddStep("finish current item", () => Client.FinishCurrentItem().WaitSafely());
AddStep("leave room", () => RoomManager.PartRoom()); AddStep("leave room", () => RoomManager.PartRoom());
AddUntilStep("wait for room part", () => !RoomJoined); AddUntilStep("wait for room part", () => !RoomJoined);

View File

@ -65,13 +65,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
importedBeatmap = importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0); importedBeatmap = importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0);
}); });
AddStep("change to all players mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers })); AddStep("change to all players mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }).WaitSafely());
} }
[Test] [Test]
public void TestDeleteButtonAlwaysVisibleForHost() public void TestDeleteButtonAlwaysVisibleForHost()
{ {
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers })); AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }).WaitSafely());
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers); AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
addPlaylistItem(() => API.LocalUser.Value.OnlineID); addPlaylistItem(() => API.LocalUser.Value.OnlineID);
@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestDeleteButtonOnlyVisibleForItemOwnerIfNotHost() public void TestDeleteButtonOnlyVisibleForItemOwnerIfNotHost()
{ {
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers })); AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }).WaitSafely());
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers); AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
AddStep("join other user", () => Client.AddUser(new APIUser { Id = 1234 })); AddStep("join other user", () => Client.AddUser(new APIUser { Id = 1234 }));
@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test] [Test]
public void TestCurrentItemDoesNotHaveDeleteButton() public void TestCurrentItemDoesNotHaveDeleteButton()
{ {
AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers })); AddStep("set all players queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings { QueueMode = QueueMode.AllPlayers }).WaitSafely());
AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers); AddUntilStep("wait for queue mode change", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
addPlaylistItem(() => API.LocalUser.Value.OnlineID); addPlaylistItem(() => API.LocalUser.Value.OnlineID);
@ -110,7 +110,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
assertDeleteButtonVisibility(0, false); assertDeleteButtonVisibility(0, false);
assertDeleteButtonVisibility(1, true); assertDeleteButtonVisibility(1, true);
AddStep("finish current item", () => Client.FinishCurrentItem()); AddStep("finish current item", () => Client.FinishCurrentItem().WaitSafely());
AddUntilStep("wait for next item to be selected", () => Client.Room?.Settings.PlaylistItemId == 2); AddUntilStep("wait for next item to be selected", () => Client.Room?.Settings.PlaylistItemId == 2);
AddUntilStep("wait for two items in playlist", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().Count() == 2); AddUntilStep("wait for two items in playlist", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().Count() == 2);
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
BeatmapID = importedBeatmap.OnlineID, BeatmapID = importedBeatmap.OnlineID,
}); });
Client.AddUserPlaylistItem(userId(), item); Client.AddUserPlaylistItem(userId(), item).WaitSafely();
itemId = item.ID; itemId = item.ID;
}); });

View File

@ -143,7 +143,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("change match type", () => client.ChangeSettings(new MultiplayerRoomSettings AddStep("change match type", () => client.ChangeSettings(new MultiplayerRoomSettings
{ {
MatchType = MatchType.TeamVersus MatchType = MatchType.TeamVersus
})); }).WaitSafely());
AddUntilStep("api room updated to team versus", () => client.APIRoom?.Type.Value == MatchType.TeamVersus); AddUntilStep("api room updated to team versus", () => client.APIRoom?.Type.Value == MatchType.TeamVersus);
} }