mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Rework MultiplayerTestScene to make use of OnlinePlayTestScene
This commit is contained in:
@ -7,6 +7,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Tests.Visual.Multiplayer;
|
using osu.Game.Tests.Visual.Multiplayer;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
@ -50,7 +51,10 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
|
|
||||||
AddStep("create room initially in gameplay", () =>
|
AddStep("create room initially in gameplay", () =>
|
||||||
{
|
{
|
||||||
Room.RoomID.Value = null;
|
var newRoom = new Room();
|
||||||
|
newRoom.CopyFrom(SelectedRoom.Value);
|
||||||
|
|
||||||
|
newRoom.RoomID.Value = null;
|
||||||
Client.RoomSetupAction = room =>
|
Client.RoomSetupAction = room =>
|
||||||
{
|
{
|
||||||
room.State = MultiplayerRoomState.Playing;
|
room.State = MultiplayerRoomState.Playing;
|
||||||
@ -61,7 +65,7 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
RoomManager.CreateRoom(Room);
|
RoomManager.CreateRoom(newRoom);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for room join", () => Client.Room != null);
|
AddUntilStep("wait for room join", () => Client.Room != null);
|
||||||
|
@ -7,17 +7,14 @@ using osu.Game.Screens.OnlinePlay;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneFreeModSelectOverlay : OsuTestScene
|
public class TestSceneFreeModSelectOverlay : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
|
||||||
Child = new TestMultiplayerRoomContainer
|
|
||||||
{
|
{
|
||||||
Child = new FreeModSelectOverlay
|
Child = new FreeModSelectOverlay
|
||||||
{
|
{
|
||||||
State = { Value = Visibility.Visible }
|
State = { Value = Visibility.Visible }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
@ -22,8 +21,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private RoomsContainer container;
|
private RoomsContainer container;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[SetUp]
|
||||||
private void load()
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = container = new RoomsContainer
|
Child = container = new RoomsContainer
|
||||||
{
|
{
|
||||||
@ -32,7 +31,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
JoinRequested = joinRequested
|
JoinRequested = joinRequested
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicListChanges()
|
public void TestBasicListChanges()
|
||||||
@ -113,14 +112,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("add rooms", () => RoomManager.AddRooms(2, new OsuRuleset().RulesetInfo));
|
AddStep("add rooms", () => RoomManager.AddRooms(2, new OsuRuleset().RulesetInfo));
|
||||||
AddStep("add rooms", () => RoomManager.AddRooms(3, new CatchRuleset().RulesetInfo));
|
AddStep("add rooms", () => RoomManager.AddRooms(3, new CatchRuleset().RulesetInfo));
|
||||||
|
|
||||||
|
// Todo: What even is this case...?
|
||||||
|
AddStep("set empty filter criteria", () => container.Filter(null));
|
||||||
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
|
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
|
||||||
|
|
||||||
AddStep("filter osu! rooms", () => container.Filter(new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo }));
|
AddStep("filter osu! rooms", () => container.Filter(new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo }));
|
||||||
|
|
||||||
AddUntilStep("2 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 2);
|
AddUntilStep("2 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 2);
|
||||||
|
|
||||||
AddStep("filter catch rooms", () => container.Filter(new FilterCriteria { Ruleset = new CatchRuleset().RulesetInfo }));
|
AddStep("filter catch rooms", () => container.Filter(new FilterCriteria { Ruleset = new CatchRuleset().RulesetInfo }));
|
||||||
|
|
||||||
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
|
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,51 +1,48 @@
|
|||||||
// 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 System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
using osu.Game.Tests.Visual.Spectator;
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorLeaderboard : OsuTestScene
|
public class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private Dictionary<int, ManualClock> clocks;
|
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
||||||
|
|
||||||
|
protected new TestDependencies RoomDependencies => (TestDependencies)base.RoomDependencies;
|
||||||
|
|
||||||
|
private Dictionary<int, ManualClock> clocks;
|
||||||
private MultiSpectatorLeaderboard leaderboard;
|
private MultiSpectatorLeaderboard leaderboard;
|
||||||
private TestContainer container;
|
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public new void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep("reset", () =>
|
AddStep("reset", () =>
|
||||||
{
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
clocks = new Dictionary<int, ManualClock>
|
clocks = new Dictionary<int, ManualClock>
|
||||||
{
|
{
|
||||||
{ MultiplayerTestScene.PLAYER_1_ID, new ManualClock() },
|
{ PLAYER_1_ID, new ManualClock() },
|
||||||
{ MultiplayerTestScene.PLAYER_2_ID, new ManualClock() }
|
{ PLAYER_2_ID, new ManualClock() }
|
||||||
};
|
};
|
||||||
|
|
||||||
Child = container = new TestContainer();
|
|
||||||
|
|
||||||
foreach (var (userId, _) in clocks)
|
foreach (var (userId, _) in clocks)
|
||||||
container.SpectatorClient.StartPlay(userId, 0);
|
SpectatorClient.StartPlay(userId, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("create leaderboard", () =>
|
AddStep("create leaderboard", () =>
|
||||||
@ -55,7 +52,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
var scoreProcessor = new OsuScoreProcessor();
|
var scoreProcessor = new OsuScoreProcessor();
|
||||||
scoreProcessor.ApplyBeatmap(playable);
|
scoreProcessor.ApplyBeatmap(playable);
|
||||||
|
|
||||||
container.LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(scoreProcessor, clocks.Keys.ToArray()) { Expanded = { Value = true } }, container.Add);
|
LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(scoreProcessor, clocks.Keys.ToArray()) { Expanded = { Value = true } }, Add);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => leaderboard.IsLoaded);
|
AddUntilStep("wait for load", () => leaderboard.IsLoaded);
|
||||||
@ -76,42 +73,42 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
// For player 2, send frames in sets of 10.
|
// For player 2, send frames in sets of 10.
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
container.SpectatorClient.SendFrames(MultiplayerTestScene.PLAYER_1_ID, i, 1);
|
SpectatorClient.SendFrames(PLAYER_1_ID, i, 1);
|
||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
container.SpectatorClient.SendFrames(MultiplayerTestScene.PLAYER_2_ID, i, 10);
|
SpectatorClient.SendFrames(PLAYER_2_ID, i, 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 1);
|
assertCombo(PLAYER_1_ID, 1);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 10);
|
assertCombo(PLAYER_2_ID, 10);
|
||||||
|
|
||||||
// Advance to a point where only user player 1's frame changes.
|
// Advance to a point where only user player 1's frame changes.
|
||||||
setTime(500);
|
setTime(500);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 5);
|
assertCombo(PLAYER_1_ID, 5);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 10);
|
assertCombo(PLAYER_2_ID, 10);
|
||||||
|
|
||||||
// Advance to a point where both user's frame changes.
|
// Advance to a point where both user's frame changes.
|
||||||
setTime(1100);
|
setTime(1100);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 11);
|
assertCombo(PLAYER_1_ID, 11);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 20);
|
assertCombo(PLAYER_2_ID, 20);
|
||||||
|
|
||||||
// Advance user player 2 only to a point where its frame changes.
|
// Advance user player 2 only to a point where its frame changes.
|
||||||
setTime(MultiplayerTestScene.PLAYER_2_ID, 2100);
|
setTime(PLAYER_2_ID, 2100);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 11);
|
assertCombo(PLAYER_1_ID, 11);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 30);
|
assertCombo(PLAYER_2_ID, 30);
|
||||||
|
|
||||||
// Advance both users beyond their last frame
|
// Advance both users beyond their last frame
|
||||||
setTime(101 * 100);
|
setTime(101 * 100);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 100);
|
assertCombo(PLAYER_1_ID, 100);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 100);
|
assertCombo(PLAYER_2_ID, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNoFrames()
|
public void TestNoFrames()
|
||||||
{
|
{
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_1_ID, 0);
|
assertCombo(PLAYER_1_ID, 0);
|
||||||
assertCombo(MultiplayerTestScene.PLAYER_2_ID, 0);
|
assertCombo(PLAYER_2_ID, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTime(double time) => AddStep($"set time {time}", () =>
|
private void setTime(double time) => AddStep($"set time {time}", () =>
|
||||||
@ -126,30 +123,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private void assertCombo(int userId, int expectedCombo)
|
private void assertCombo(int userId, int expectedCombo)
|
||||||
=> AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId).Combo.Value == expectedCombo);
|
=> AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId).Combo.Value == expectedCombo);
|
||||||
|
|
||||||
private class TestContainer : TestMultiplayerRoomContainer
|
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
||||||
{
|
|
||||||
[Cached(typeof(SpectatorClient))]
|
|
||||||
public readonly TestSpectatorClient SpectatorClient = new TestSpectatorClient();
|
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
protected class TestDependencies : MultiplayerRoomTestDependencies
|
||||||
|
{
|
||||||
|
public readonly TestSpectatorClient SpectatorClient = new TestSpectatorClient();
|
||||||
public readonly UserLookupCache LookupCache = new TestUserLookupCache();
|
public readonly UserLookupCache LookupCache = new TestUserLookupCache();
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
public TestDependencies()
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
public TestContainer()
|
|
||||||
{
|
{
|
||||||
AddRangeInternal(new Drawable[]
|
CacheAs<SpectatorClient>(SpectatorClient);
|
||||||
{
|
CacheAs(LookupCache);
|
||||||
SpectatorClient,
|
|
||||||
LookupCache,
|
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public new Task LoadComponentAsync<TLoadable>([NotNull] TLoadable component, Action<TLoadable> onLoaded = null, CancellationToken cancellation = default, Scheduler scheduler = null)
|
|
||||||
where TLoadable : Drawable
|
|
||||||
=> base.LoadComponentAsync(component, onLoaded, cancellation, scheduler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestUserLookupCache : UserLookupCache
|
private class TestUserLookupCache : UserLookupCache
|
||||||
|
@ -15,6 +15,7 @@ using osu.Game.Online.Spectator;
|
|||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
using osu.Game.Tests.Visual.Spectator;
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
@ -22,11 +23,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(SpectatorClient))]
|
public TestSpectatorClient SpectatorClient => RoomDependencies?.SpectatorClient;
|
||||||
private TestSpectatorClient spectatorClient = new TestSpectatorClient();
|
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
protected new TestDependencies RoomDependencies => (TestDependencies)base.RoomDependencies;
|
||||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuGameBase game { get; set; }
|
private OsuGameBase game { get; set; }
|
||||||
@ -51,25 +50,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
importedBeatmapId = importedBeatmap.OnlineBeatmapID ?? -1;
|
importedBeatmapId = importedBeatmap.OnlineBeatmapID ?? -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetUpSteps()
|
[SetUp]
|
||||||
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
nextFrame.Clear();
|
||||||
|
|
||||||
AddStep("reset sent frames", () => nextFrame.Clear());
|
|
||||||
|
|
||||||
AddStep("add streaming client", () =>
|
|
||||||
{
|
|
||||||
Remove(spectatorClient);
|
|
||||||
Add(spectatorClient);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("finish previous gameplay", () =>
|
|
||||||
{
|
|
||||||
foreach (var id in playingUserIds)
|
|
||||||
spectatorClient.EndPlay(id);
|
|
||||||
playingUserIds.Clear();
|
playingUserIds.Clear();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDelayedStart()
|
public void TestDelayedStart()
|
||||||
@ -87,11 +73,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
loadSpectateScreen(false);
|
loadSpectateScreen(false);
|
||||||
|
|
||||||
AddWaitStep("wait a bit", 10);
|
AddWaitStep("wait a bit", 10);
|
||||||
AddStep("load player first_player_id", () => spectatorClient.StartPlay(PLAYER_1_ID, importedBeatmapId));
|
AddStep("load player first_player_id", () => SpectatorClient.StartPlay(PLAYER_1_ID, importedBeatmapId));
|
||||||
AddUntilStep("one player added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 1);
|
AddUntilStep("one player added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 1);
|
||||||
|
|
||||||
AddWaitStep("wait a bit", 10);
|
AddWaitStep("wait a bit", 10);
|
||||||
AddStep("load player second_player_id", () => spectatorClient.StartPlay(PLAYER_2_ID, importedBeatmapId));
|
AddStep("load player second_player_id", () => SpectatorClient.StartPlay(PLAYER_2_ID, importedBeatmapId));
|
||||||
AddUntilStep("two players added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 2);
|
AddUntilStep("two players added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +237,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
foreach (int id in userIds)
|
foreach (int id in userIds)
|
||||||
{
|
{
|
||||||
Client.CurrentMatchPlayingUserIds.Add(id);
|
Client.CurrentMatchPlayingUserIds.Add(id);
|
||||||
spectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
SpectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
||||||
playingUserIds.Add(id);
|
playingUserIds.Add(id);
|
||||||
nextFrame[id] = 0;
|
nextFrame[id] = 0;
|
||||||
}
|
}
|
||||||
@ -262,7 +248,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("end play", () =>
|
AddStep("end play", () =>
|
||||||
{
|
{
|
||||||
spectatorClient.EndPlay(userId);
|
SpectatorClient.EndPlay(userId);
|
||||||
playingUserIds.Remove(userId);
|
playingUserIds.Remove(userId);
|
||||||
nextFrame.Remove(userId);
|
nextFrame.Remove(userId);
|
||||||
});
|
});
|
||||||
@ -276,7 +262,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
foreach (int id in userIds)
|
foreach (int id in userIds)
|
||||||
{
|
{
|
||||||
spectatorClient.SendFrames(id, nextFrame[id], count);
|
SpectatorClient.SendFrames(id, nextFrame[id], count);
|
||||||
nextFrame[id] += count;
|
nextFrame[id] += count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -298,6 +284,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
|
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
|
||||||
|
|
||||||
|
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
||||||
|
|
||||||
|
protected class TestDependencies : MultiplayerRoomTestDependencies
|
||||||
|
{
|
||||||
|
public readonly TestSpectatorClient SpectatorClient = new TestSpectatorClient();
|
||||||
|
public readonly UserLookupCache LookupCache = new TestUserLookupCache();
|
||||||
|
|
||||||
|
public TestDependencies()
|
||||||
|
{
|
||||||
|
CacheAs<SpectatorClient>(SpectatorClient);
|
||||||
|
CacheAs(LookupCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class TestUserLookupCache : UserLookupCache
|
internal class TestUserLookupCache : UserLookupCache
|
||||||
{
|
{
|
||||||
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default)
|
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default)
|
||||||
|
@ -29,7 +29,7 @@ using osu.Game.Screens.Select;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMultiplayerMatchSongSelect : ScreenTestScene
|
public class TestSceneMultiplayerMatchSongSelect : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private BeatmapManager manager;
|
private BeatmapManager manager;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
@ -49,13 +49,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public new void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.Name.Value = "Test Room";
|
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
|
||||||
});
|
});
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetupSteps()
|
public void SetupSteps()
|
||||||
{
|
{
|
||||||
AddStep("load match", () => LoadScreen(screen = new MultiplayerMatchSubScreen(Room)));
|
AddStep("load match", () => LoadScreen(screen = new MultiplayerMatchSubScreen(SelectedRoom.Value)));
|
||||||
AddUntilStep("wait for load", () => screen.IsCurrentScreen());
|
AddUntilStep("wait for load", () => screen.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("set playlist", () =>
|
AddStep("set playlist", () =>
|
||||||
{
|
{
|
||||||
Room.Playlist.Add(new PlaylistItem
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("set playlist", () =>
|
AddStep("set playlist", () =>
|
||||||
{
|
{
|
||||||
Room.Playlist.Add(new PlaylistItem
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||||
@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("set playlist", () =>
|
AddStep("set playlist", () =>
|
||||||
{
|
{
|
||||||
Room.Playlist.Add(new PlaylistItem
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo },
|
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()).BeatmapInfo },
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||||
|
@ -27,7 +27,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
public class TestSceneMultiplayerReadyButton : MultiplayerTestScene
|
public class TestSceneMultiplayerReadyButton : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private MultiplayerReadyButton button;
|
private MultiplayerReadyButton button;
|
||||||
private OnlinePlayBeatmapAvailabilityTracker beatmapTracker;
|
|
||||||
private BeatmapSetInfo importedSet;
|
private BeatmapSetInfo importedSet;
|
||||||
|
|
||||||
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
||||||
@ -43,18 +42,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
||||||
|
|
||||||
Add(beatmapTracker = new OnlinePlayBeatmapAvailabilityTracker
|
|
||||||
{
|
|
||||||
SelectedItem = { BindTarget = selectedItem }
|
|
||||||
});
|
|
||||||
|
|
||||||
Dependencies.Cache(beatmapTracker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public new void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
AvailabilityTracker.SelectedItem.BindTo(selectedItem);
|
||||||
|
|
||||||
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
||||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
|
||||||
selectedItem.Value = new PlaylistItem
|
selectedItem.Value = new PlaylistItem
|
||||||
|
@ -3,37 +3,38 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public class TestSceneMultiplayerRoomManager : OsuTestScene
|
public class TestSceneMultiplayerRoomManager : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private TestMultiplayerRoomContainer roomContainer;
|
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
||||||
private TestMultiplayerRoomManager roomManager => roomContainer.RoomManager;
|
|
||||||
|
public TestSceneMultiplayerRoomManager()
|
||||||
|
: base(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestPollsInitially()
|
public void TestPollsInitially()
|
||||||
{
|
{
|
||||||
AddStep("create room manager with a few rooms", () =>
|
AddStep("create room manager with a few rooms", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom(r => r.Name.Value = "1"));
|
||||||
{
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom(r => r.Name.Value = "1"));
|
RoomManager.CreateRoom(createRoom(r => r.Name.Value = "2"));
|
||||||
roomManager.PartRoom();
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom(r => r.Name.Value = "2"));
|
RoomManager.ClearRooms();
|
||||||
roomManager.PartRoom();
|
|
||||||
roomManager.ClearRooms();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("manager polled for rooms", () => ((RoomManager)roomManager).Rooms.Count == 2);
|
AddAssert("manager polled for rooms", () => ((RoomManager)RoomManager).Rooms.Count == 2);
|
||||||
AddAssert("initial rooms received", () => roomManager.InitialRoomsReceived.Value);
|
AddAssert("initial rooms received", () => RoomManager.InitialRoomsReceived.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -41,19 +42,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("create room manager with a few rooms", () =>
|
AddStep("create room manager with a few rooms", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom());
|
||||||
{
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom());
|
RoomManager.CreateRoom(createRoom());
|
||||||
roomManager.PartRoom();
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom());
|
|
||||||
roomManager.PartRoom();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("disconnect", () => roomContainer.Client.Disconnect());
|
AddStep("disconnect", () => Client.Disconnect());
|
||||||
|
|
||||||
AddAssert("rooms cleared", () => ((RoomManager)roomManager).Rooms.Count == 0);
|
AddAssert("rooms cleared", () => ((RoomManager)RoomManager).Rooms.Count == 0);
|
||||||
AddAssert("initial rooms not received", () => !roomManager.InitialRoomsReceived.Value);
|
AddAssert("initial rooms not received", () => !RoomManager.InitialRoomsReceived.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -61,20 +59,17 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("create room manager with a few rooms", () =>
|
AddStep("create room manager with a few rooms", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom());
|
||||||
{
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom());
|
RoomManager.CreateRoom(createRoom());
|
||||||
roomManager.PartRoom();
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom());
|
|
||||||
roomManager.PartRoom();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("disconnect", () => roomContainer.Client.Disconnect());
|
AddStep("disconnect", () => Client.Disconnect());
|
||||||
AddStep("connect", () => roomContainer.Client.Connect());
|
AddStep("connect", () => Client.Connect());
|
||||||
|
|
||||||
AddAssert("manager polled for rooms", () => ((RoomManager)roomManager).Rooms.Count == 2);
|
AddAssert("manager polled for rooms", () => ((RoomManager)RoomManager).Rooms.Count == 2);
|
||||||
AddAssert("initial rooms received", () => roomManager.InitialRoomsReceived.Value);
|
AddAssert("initial rooms received", () => RoomManager.InitialRoomsReceived.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -82,15 +77,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("create room manager with a room", () =>
|
AddStep("create room manager with a room", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom());
|
||||||
{
|
RoomManager.ClearRooms();
|
||||||
roomManager.CreateRoom(createRoom());
|
|
||||||
roomManager.ClearRooms();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("manager not polled for rooms", () => ((RoomManager)roomManager).Rooms.Count == 0);
|
AddAssert("manager not polled for rooms", () => ((RoomManager)RoomManager).Rooms.Count == 0);
|
||||||
AddAssert("initial rooms not received", () => !roomManager.InitialRoomsReceived.Value);
|
AddAssert("initial rooms not received", () => !RoomManager.InitialRoomsReceived.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -98,13 +90,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("create room manager with a room", () =>
|
AddStep("create room manager with a room", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom());
|
||||||
{
|
|
||||||
roomManager.CreateRoom(createRoom());
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("multiplayer room joined", () => roomContainer.Client.Room != null);
|
AddUntilStep("multiplayer room joined", () => Client.Room != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -112,31 +101,25 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("create room manager with a room", () =>
|
AddStep("create room manager with a room", () =>
|
||||||
{
|
{
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
RoomManager.CreateRoom(createRoom());
|
||||||
{
|
RoomManager.PartRoom();
|
||||||
roomManager.CreateRoom(createRoom());
|
|
||||||
roomManager.PartRoom();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("multiplayer room parted", () => roomContainer.Client.Room == null);
|
AddAssert("multiplayer room parted", () => Client.Room == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestMultiplayerRoomJoinedWhenAPIRoomJoined()
|
public void TestMultiplayerRoomJoinedWhenAPIRoomJoined()
|
||||||
{
|
{
|
||||||
AddStep("create room manager with a room", () =>
|
AddStep("create room manager with a room", () =>
|
||||||
{
|
|
||||||
createRoomManager().With(d => d.OnLoadComplete += _ =>
|
|
||||||
{
|
{
|
||||||
var r = createRoom();
|
var r = createRoom();
|
||||||
roomManager.CreateRoom(r);
|
RoomManager.CreateRoom(r);
|
||||||
roomManager.PartRoom();
|
RoomManager.PartRoom();
|
||||||
roomManager.JoinRoom(r);
|
RoomManager.JoinRoom(r);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("multiplayer room joined", () => roomContainer.Client.Room != null);
|
AddUntilStep("multiplayer room joined", () => Client.Room != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Room createRoom(Action<Room> initFunc = null)
|
private Room createRoom(Action<Room> initFunc = null)
|
||||||
@ -161,18 +144,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestMultiplayerRoomManager createRoomManager()
|
private class TestDependencies : MultiplayerRoomTestDependencies
|
||||||
{
|
{
|
||||||
Child = roomContainer = new TestMultiplayerRoomContainer
|
public TestDependencies()
|
||||||
{
|
{
|
||||||
RoomManager =
|
RoomManager.TimeBetweenListingPolls.Value = 1;
|
||||||
{
|
RoomManager.TimeBetweenSelectionPolls.Value = 1;
|
||||||
TimeBetweenListingPolls = { Value = 1 },
|
|
||||||
TimeBetweenSelectionPolls = { Value = 1 }
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return roomManager;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,40 +37,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private IDisposable readyClickOperation;
|
private IDisposable readyClickOperation;
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
public TestSceneMultiplayerSpectateButton()
|
|
||||||
{
|
|
||||||
base.Content.Add(content = new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, AudioManager audio)
|
private void load(GameHost host, AudioManager audio)
|
||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||||
|
|
||||||
var beatmapTracker = new OnlinePlayBeatmapAvailabilityTracker { SelectedItem = { BindTarget = selectedItem } };
|
|
||||||
base.Content.Add(beatmapTracker);
|
|
||||||
Dependencies.Cache(beatmapTracker);
|
|
||||||
|
|
||||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public new void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
AvailabilityTracker.SelectedItem.BindTo(selectedItem);
|
||||||
|
|
||||||
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
||||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
|
||||||
selectedItem.Value = new PlaylistItem
|
selectedItem.Value = new PlaylistItem
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
|
||||||
{
|
|
||||||
public class MultiplayerSubScreenTestScene : OnlinePlayTestScene, IMultiplayerRoomTestDependencies
|
|
||||||
{
|
|
||||||
public TestMultiplayerClient Client => RoomDependencies.Client;
|
|
||||||
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
|
||||||
|
|
||||||
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
|
||||||
|
|
||||||
protected override RoomTestDependencies CreateRoomDependencies() => new MultiplayerRoomTestDependencies();
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,66 +2,51 @@
|
|||||||
// 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 NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public abstract class MultiplayerTestScene : RoomTestScene
|
public abstract class MultiplayerTestScene : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
public const int PLAYER_1_ID = 55;
|
public const int PLAYER_1_ID = 55;
|
||||||
public const int PLAYER_2_ID = 56;
|
public const int PLAYER_2_ID = 56;
|
||||||
|
|
||||||
[Cached(typeof(MultiplayerClient))]
|
public TestMultiplayerClient Client => RoomDependencies.Client;
|
||||||
public TestMultiplayerClient Client { get; }
|
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
||||||
|
|
||||||
[Cached(typeof(IRoomManager))]
|
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
||||||
public TestMultiplayerRoomManager RoomManager { get; }
|
|
||||||
|
|
||||||
[Cached]
|
protected override RoomTestDependencies CreateRoomDependencies() => new MultiplayerRoomTestDependencies();
|
||||||
public Bindable<FilterCriteria> Filter { get; }
|
|
||||||
|
|
||||||
[Cached]
|
|
||||||
public OngoingOperationTracker OngoingOperationTracker { get; }
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
private readonly TestMultiplayerRoomContainer content;
|
|
||||||
|
|
||||||
private readonly bool joinRoom;
|
private readonly bool joinRoom;
|
||||||
|
|
||||||
protected MultiplayerTestScene(bool joinRoom = true)
|
protected MultiplayerTestScene(bool joinRoom = true)
|
||||||
{
|
{
|
||||||
this.joinRoom = joinRoom;
|
this.joinRoom = joinRoom;
|
||||||
base.Content.Add(content = new TestMultiplayerRoomContainer { RelativeSizeAxes = Axes.Both });
|
|
||||||
|
|
||||||
Client = content.Client;
|
|
||||||
RoomManager = content.RoomManager;
|
|
||||||
Filter = content.Filter;
|
|
||||||
OngoingOperationTracker = content.OngoingOperationTracker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public new void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
RoomManager.Schedule(() => RoomManager.PartRoom());
|
|
||||||
|
|
||||||
if (joinRoom)
|
if (joinRoom)
|
||||||
{
|
{
|
||||||
Room.Name.Value = "test name";
|
var room = new Room
|
||||||
Room.Playlist.Add(new PlaylistItem
|
{
|
||||||
|
Name = { Value = "test name" },
|
||||||
|
Playlist =
|
||||||
|
{
|
||||||
|
new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
Beatmap = { Value = new TestBeatmap(Ruleset.Value).BeatmapInfo },
|
||||||
Ruleset = { Value = Ruleset.Value }
|
Ruleset = { Value = Ruleset.Value }
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
RoomManager.Schedule(() => RoomManager.CreateRoom(Room));
|
RoomManager.CreateRoom(room);
|
||||||
|
SelectedRoom.Value = room;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -70,7 +55,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
if (joinRoom)
|
if (joinRoom)
|
||||||
|
{
|
||||||
AddUntilStep("wait for room join", () => Client.Room != null);
|
AddUntilStep("wait for room join", () => Client.Room != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
|
||||||
using osu.Game.Screens.OnlinePlay;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
|
||||||
{
|
|
||||||
public class TestMultiplayerRoomContainer : Container
|
|
||||||
{
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
[Cached(typeof(MultiplayerClient))]
|
|
||||||
public readonly TestMultiplayerClient Client;
|
|
||||||
|
|
||||||
[Cached(typeof(IRoomManager))]
|
|
||||||
public readonly TestMultiplayerRoomManager RoomManager;
|
|
||||||
|
|
||||||
[Cached]
|
|
||||||
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>(new FilterCriteria());
|
|
||||||
|
|
||||||
[Cached]
|
|
||||||
public readonly OngoingOperationTracker OngoingOperationTracker;
|
|
||||||
|
|
||||||
public TestMultiplayerRoomContainer()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
RoomManager = new TestMultiplayerRoomManager();
|
|
||||||
Client = new TestMultiplayerClient(RoomManager);
|
|
||||||
OngoingOperationTracker = new OngoingOperationTracker();
|
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
|
||||||
{
|
|
||||||
Client,
|
|
||||||
RoomManager,
|
|
||||||
OngoingOperationTracker,
|
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,10 +29,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public new readonly List<Room> Rooms = new List<Room>();
|
public new readonly List<Room> Rooms = new List<Room>();
|
||||||
|
|
||||||
protected override void LoadComplete()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
int currentScoreId = 0;
|
int currentScoreId = 0;
|
||||||
int currentRoomId = 0;
|
int currentRoomId = 0;
|
||||||
int currentPlaylistItemId = 0;
|
int currentPlaylistItemId = 0;
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Online.Rooms;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
|
||||||
{
|
|
||||||
public abstract class RoomTestScene : ScreenTestScene
|
|
||||||
{
|
|
||||||
[Cached]
|
|
||||||
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
|
|
||||||
|
|
||||||
protected Room Room => currentRoom.Value;
|
|
||||||
|
|
||||||
private CachedModelDependencyContainer<Room> dependencies;
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
|
||||||
dependencies.Model.BindTo(currentRoom);
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
[SetUp]
|
|
||||||
public void Setup() => Schedule(() =>
|
|
||||||
{
|
|
||||||
currentRoom.Value = new Room();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user