Fix potential test failures due to Setup/SetUpSteps ordering

This commit is contained in:
Dan Balasescu
2022-07-29 15:27:39 +09:00
parent bc685918b6
commit aaa6f963bd
15 changed files with 258 additions and 221 deletions

View File

@ -19,8 +19,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
private DrawableRoomParticipantsList list; private DrawableRoomParticipantsList list;
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create list", () =>
{ {
SelectedRoom.Value = new Room SelectedRoom.Value = new Room
{ {
@ -42,6 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
NumberOfCircles = 4 NumberOfCircles = 4
}; };
}); });
}
[Test] [Test]
public void TestCircleCountNearLimit() public void TestCircleCountNearLimit()

View File

@ -25,8 +25,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
private RoomsContainer container; private RoomsContainer container;
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create container", () =>
{ {
Child = new PopoverContainer Child = new PopoverContainer
{ {
@ -42,6 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
} }
}; };
}); });
}
[Test] [Test]
public void TestBasicListChanges() public void TestBasicListChanges()

View File

@ -3,7 +3,6 @@
#nullable disable #nullable disable
using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
@ -18,8 +17,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public class TestSceneMatchBeatmapDetailArea : OnlinePlayTestScene public class TestSceneMatchBeatmapDetailArea : OnlinePlayTestScene
{ {
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create area", () =>
{ {
SelectedRoom.Value = new Room(); SelectedRoom.Value = new Room();
@ -31,6 +33,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
CreateNewItem = createNewItem CreateNewItem = createNewItem
}; };
}); });
}
private void createNewItem() private void createNewItem()
{ {

View File

@ -4,8 +4,6 @@
#nullable disable #nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -19,8 +17,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public class TestSceneMatchLeaderboard : OnlinePlayTestScene public class TestSceneMatchLeaderboard : OnlinePlayTestScene
{ {
[BackgroundDependencyLoader] public override void SetUpSteps()
private void load() {
base.SetUpSteps();
AddStep("setup API", () =>
{ {
((DummyAPIAccess)API).HandleRequest = r => ((DummyAPIAccess)API).HandleRequest = r =>
{ {
@ -58,10 +59,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
return false; return false;
}; };
} });
[SetUp] AddStep("create leaderboard", () =>
public new void Setup() => Schedule(() =>
{ {
SelectedRoom.Value = new Room { RoomID = { Value = 3 } }; SelectedRoom.Value = new Room { RoomID = { Value = 3 } };
@ -74,4 +74,5 @@ namespace osu.Game.Tests.Visual.Multiplayer
}; };
}); });
} }
}
} }

View File

@ -22,8 +22,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
private MultiSpectatorLeaderboard leaderboard; private MultiSpectatorLeaderboard leaderboard;
[SetUpSteps] [SetUpSteps]
public new void SetUpSteps() public override void SetUpSteps()
{ {
base.SetUpSteps();
AddStep("reset", () => AddStep("reset", () =>
{ {
leaderboard?.RemoveAndDisposeImmediately(); leaderboard?.RemoveAndDisposeImmediately();

View File

@ -56,8 +56,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
importedBeatmapId = importedBeatmap.OnlineID; importedBeatmapId = importedBeatmap.OnlineID;
} }
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => playingUsers.Clear()); {
base.SetUpSteps();
AddStep("clear playing users", () => playingUsers.Clear());
}
[Test] [Test]
public void TestDelayedStart() public void TestDelayedStart()

View File

@ -3,7 +3,6 @@
#nullable disable #nullable disable
using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
@ -13,8 +12,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public class TestSceneMultiplayerMatchFooter : MultiplayerTestScene public class TestSceneMultiplayerMatchFooter : MultiplayerTestScene
{ {
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create footer", () =>
{ {
Child = new PopoverContainer Child = new PopoverContainer
{ {
@ -32,4 +34,5 @@ namespace osu.Game.Tests.Visual.Multiplayer
}; };
}); });
} }
}
} }

View File

@ -59,16 +59,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
importedSet = beatmaps.GetAllUsableBeatmapSets().First(); importedSet = beatmaps.GetAllUsableBeatmapSets().First();
} }
[SetUp]
public new void Setup() => Schedule(() =>
{
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
});
[SetUpSteps] [SetUpSteps]
public void SetupSteps() public void SetupSteps()
{ {
AddStep("load match", () => LoadScreen(screen = new MultiplayerMatchSubScreen(SelectedRoom.Value))); AddStep("load match", () =>
{
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
LoadScreen(screen = new MultiplayerMatchSubScreen(SelectedRoom.Value));
});
AddUntilStep("wait for load", () => screen.IsCurrentScreen()); AddUntilStep("wait for load", () => screen.IsCurrentScreen());
} }

View File

@ -42,8 +42,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
Dependencies.Cache(Realm); Dependencies.Cache(Realm);
} }
[SetUp] [SetUpSteps]
public new void Setup() => Schedule(() => public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("create list", () =>
{ {
Child = list = new MultiplayerPlaylist Child = list = new MultiplayerPlaylist
{ {
@ -54,9 +58,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
}; };
}); });
[SetUpSteps]
public new void SetUpSteps()
{
AddStep("import beatmap", () => AddStep("import beatmap", () =>
{ {
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely(); beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();

View File

@ -46,8 +46,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely(); beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
} }
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create button", () =>
{ {
AvailabilityTracker.SelectedItem.BindTo(selectedItem); AvailabilityTracker.SelectedItem.BindTo(selectedItem);
@ -83,6 +86,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
} }
}; };
}); });
}
[TestCase(MultiplayerRoomState.Open)] [TestCase(MultiplayerRoomState.Open)]
[TestCase(MultiplayerRoomState.WaitingForLoad)] [TestCase(MultiplayerRoomState.WaitingForLoad)]

View File

@ -14,8 +14,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public class TestSceneStarRatingRangeDisplay : OnlinePlayTestScene public class TestSceneStarRatingRangeDisplay : OnlinePlayTestScene
{ {
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create display", () =>
{ {
SelectedRoom.Value = new Room(); SelectedRoom.Value = new Room();
@ -25,6 +28,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Origin = Anchor.Centre Origin = Anchor.Centre
}; };
}); });
}
[Test] [Test]
public void TestRange([Values(0, 2, 3, 4, 6, 7)] double min, [Values(0, 2, 3, 4, 6, 7)] double max) public void TestRange([Values(0, 2, 3, 4, 6, 7)] double min, [Values(0, 2, 3, 4, 6, 7)] double max)

View File

@ -25,8 +25,11 @@ namespace osu.Game.Tests.Visual.Playlists
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new TestDependencies(); protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new TestDependencies();
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create overlay", () =>
{ {
SelectedRoom.Value = new Room(); SelectedRoom.Value = new Room();
@ -36,6 +39,7 @@ namespace osu.Game.Tests.Visual.Playlists
State = { Value = Visibility.Visible } State = { Value = Visibility.Visible }
}; };
}); });
}
[Test] [Test]
public void TestButtonEnabledOnlyWithNameAndBeatmap() public void TestButtonEnabledOnlyWithNameAndBeatmap()

View File

@ -15,8 +15,11 @@ namespace osu.Game.Tests.Visual.Playlists
{ {
public class TestScenePlaylistsParticipantsList : OnlinePlayTestScene public class TestScenePlaylistsParticipantsList : OnlinePlayTestScene
{ {
[SetUp] public override void SetUpSteps()
public new void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("create list", () =>
{ {
SelectedRoom.Value = new Room { RoomID = { Value = 7 } }; SelectedRoom.Value = new Room { RoomID = { Value = 7 } };
@ -30,6 +33,7 @@ namespace osu.Game.Tests.Visual.Playlists
}); });
} }
}); });
}
[Test] [Test]
public void TestHorizontalLayout() public void TestHorizontalLayout()

View File

@ -3,7 +3,6 @@
#nullable disable #nullable disable
using NUnit.Framework;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual.OnlinePlay; using osu.Game.Tests.Visual.OnlinePlay;
@ -34,13 +33,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
this.joinRoom = joinRoom; this.joinRoom = joinRoom;
} }
[SetUp]
public new void Setup() => Schedule(() =>
{
if (joinRoom)
SelectedRoom.Value = CreateRoom();
});
protected virtual Room CreateRoom() protected virtual Room CreateRoom()
{ {
return new Room return new Room
@ -63,7 +55,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
if (joinRoom) if (joinRoom)
{ {
AddStep("join room", () => RoomManager.CreateRoom(SelectedRoom.Value)); AddStep("join room", () =>
{
SelectedRoom.Value = CreateRoom();
RoomManager.CreateRoom(SelectedRoom.Value);
});
AddUntilStep("wait for room join", () => RoomJoined); AddUntilStep("wait for room join", () => RoomJoined);
} }
} }

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using System; using System;
using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -56,8 +55,11 @@ namespace osu.Game.Tests.Visual.OnlinePlay
return dependencies; return dependencies;
} }
[SetUp] public override void SetUpSteps()
public void Setup() => Schedule(() => {
base.SetUpSteps();
AddStep("setup dependencies", () =>
{ {
// Reset the room dependencies to a fresh state. // Reset the room dependencies to a fresh state.
drawableDependenciesContainer.Clear(); drawableDependenciesContainer.Clear();
@ -86,9 +88,10 @@ namespace osu.Game.Tests.Visual.OnlinePlay
} }
}; };
}); });
}
/// <summary> /// <summary>
/// Creates the room dependencies. Called every <see cref="Setup"/>. /// Creates the room dependencies. Called every <see cref="SetUpSteps"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Any custom dependencies required for online play sub-classes should be added here. /// Any custom dependencies required for online play sub-classes should be added here.