Set new room for each test iteration

This commit is contained in:
smoogipoo
2020-12-18 14:58:58 +09:00
parent 2969500743
commit 208a9e596e
11 changed files with 49 additions and 55 deletions

View File

@ -4,7 +4,6 @@
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.RoomStatuses; using osu.Game.Online.Multiplayer.RoomStatuses;
using osu.Game.Screens.Multi.Lounge.Components; using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Users; using osu.Game.Users;
@ -14,10 +13,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
public class TestSceneLoungeRoomInfo : MultiplayerTestScene public class TestSceneLoungeRoomInfo : MultiplayerTestScene
{ {
[SetUp] [SetUp]
public void Setup() => Schedule(() => public new void Setup() => Schedule(() =>
{ {
Room = new Room();
Child = new RoomInfo Child = new RoomInfo
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -24,10 +24,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private RulesetStore rulesetStore { get; set; } private RulesetStore rulesetStore { get; set; }
[SetUp] [SetUp]
public void Setup() => Schedule(() => public new void Setup() => Schedule(() =>
{ {
Room = new Room();
Child = new MatchBeatmapDetailArea Child = new MatchBeatmapDetailArea
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,

View File

@ -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 NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -14,7 +15,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
public TestSceneMatchHeader() public TestSceneMatchHeader()
{ {
Room = new Room(); Child = new Header();
}
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.Playlist.Add(new PlaylistItem Room.Playlist.Add(new PlaylistItem
{ {
Beatmap = Beatmap =
@ -41,8 +47,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
Room.Name.Value = "A very awesome room"; Room.Name.Value = "A very awesome room";
Room.Host.Value = new User { Id = 2, Username = "peppy" }; Room.Host.Value = new User { Id = 2, Username = "peppy" };
});
Child = new Header();
}
} }
} }

View File

@ -3,10 +3,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.Allocation; 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.Multiplayer;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -19,8 +19,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
public TestSceneMatchLeaderboard() public TestSceneMatchLeaderboard()
{ {
Room = new Room { RoomID = { Value = 3 } };
Add(new MatchLeaderboard Add(new MatchLeaderboard
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -40,6 +38,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
api.Queue(req); api.Queue(req);
} }
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.RoomID.Value = 3;
});
private class GetRoomScoresRequest : APIRequest<List<RoomScore>> private class GetRoomScoresRequest : APIRequest<List<RoomScore>>
{ {
protected override string Target => "rooms/3/leaderboard"; protected override string Target => "rooms/3/leaderboard";

View File

@ -23,10 +23,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private TestRoomSettings settings; private TestRoomSettings settings;
[SetUp] [SetUp]
public void Setup() => Schedule(() => public new void Setup() => Schedule(() =>
{ {
Room = new Room();
settings = new TestRoomSettings settings = new TestRoomSettings
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,

View File

@ -14,7 +14,6 @@ using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -94,12 +93,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
} }
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room();
});
[Test] [Test]
public void TestItemAddedIfEmptyOnStart() public void TestItemAddedIfEmptyOnStart()
{ {

View File

@ -45,12 +45,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait(); manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
} }
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room();
});
[SetUpSteps] [SetUpSteps]
public void SetupSteps() public void SetupSteps()
{ {

View File

@ -3,7 +3,6 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using osuTK; using osuTK;
@ -14,9 +13,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
protected override bool UseOnlineAPI => true; protected override bool UseOnlineAPI => true;
[SetUp] [SetUp]
public void Setup() => Schedule(() => public new void Setup() => Schedule(() =>
{ {
Room = new Room { RoomID = { Value = 7 } }; Room.RoomID.Value = 7;
}); });
[Test] [Test]

View File

@ -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 NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -16,7 +17,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
public TestSceneOverlinedPlaylist() public TestSceneOverlinedPlaylist()
{ {
Room = new Room { RoomID = { Value = 7 } }; Add(new DrawableRoomPlaylist(false, false)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500),
});
}
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.RoomID.Value = 7;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
@ -27,13 +39,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
Ruleset = { Value = new OsuRuleset().RulesetInfo } Ruleset = { Value = new OsuRuleset().RulesetInfo }
}); });
} }
Add(new DrawableRoomPlaylist(false, false)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500),
}); });
} }
} }
}

View File

@ -3,7 +3,6 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
namespace osu.Game.Tests.Visual.Multiplayer namespace osu.Game.Tests.Visual.Multiplayer
@ -12,15 +11,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
protected override bool UseOnlineAPI => true; protected override bool UseOnlineAPI => true;
[SetUp]
public void Setup() => Schedule(() =>
{
Room = new Room { RoomID = { Value = 7 } };
});
public TestSceneParticipantsList() public TestSceneParticipantsList()
{ {
Add(new ParticipantsList { RelativeSizeAxes = Axes.Both }); Add(new ParticipantsList { RelativeSizeAxes = Axes.Both });
} }
[SetUp]
public new void Setup() => Schedule(() =>
{
Room.RoomID.Value = 7;
});
} }
} }

View File

@ -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 NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
@ -10,13 +11,9 @@ namespace osu.Game.Tests.Visual
public abstract class MultiplayerTestScene : ScreenTestScene public abstract class MultiplayerTestScene : ScreenTestScene
{ {
[Cached] [Cached]
private readonly Bindable<Room> currentRoom = new Bindable<Room>(); private readonly Bindable<Room> currentRoom = new Bindable<Room>(new Room());
protected Room Room protected Room Room => currentRoom.Value;
{
get => currentRoom.Value;
set => currentRoom.Value = value;
}
private CachedModelDependencyContainer<Room> dependencies; private CachedModelDependencyContainer<Room> dependencies;
@ -26,5 +23,11 @@ namespace osu.Game.Tests.Visual
dependencies.Model.BindTo(currentRoom); dependencies.Model.BindTo(currentRoom);
return dependencies; return dependencies;
} }
[SetUp]
public void Setup() => Schedule(() =>
{
Room.CopyFrom(new Room());
});
} }
} }