1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 12:53:11 +08:00

Fix online play test request handling

This commit is contained in:
smoogipoo 2021-10-27 14:49:50 +09:00
parent 45db99171e
commit 85b21174dd
2 changed files with 18 additions and 12 deletions

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay; using osu.Game.Screens.OnlinePlay;
@ -27,11 +28,15 @@ namespace osu.Game.Tests.Visual.OnlinePlay
/// </summary> /// </summary>
protected OnlinePlayTestSceneDependencies OnlinePlayDependencies => dependencies?.OnlinePlayDependencies; protected OnlinePlayTestSceneDependencies OnlinePlayDependencies => dependencies?.OnlinePlayDependencies;
private DelegatedDependencyContainer dependencies;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
[Resolved]
private OsuGameBase game { get; set; }
private readonly Container content; private readonly Container content;
private readonly Container drawableDependenciesContainer; private readonly Container drawableDependenciesContainer;
private DelegatedDependencyContainer dependencies;
private TestRoomRequestsHandler requestsHandler;
protected OnlinePlayTestScene() protected OnlinePlayTestScene()
{ {
@ -57,6 +62,17 @@ namespace osu.Game.Tests.Visual.OnlinePlay
drawableDependenciesContainer.AddRange(OnlinePlayDependencies.DrawableComponents); drawableDependenciesContainer.AddRange(OnlinePlayDependencies.DrawableComponents);
}); });
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("setup API", () =>
{
requestsHandler = new TestRoomRequestsHandler();
((DummyAPIAccess)API).HandleRequest = request => requestsHandler.HandleRequest(request, API.LocalUser.Value, game);
});
}
/// <summary> /// <summary>
/// Creates the room dependencies. Called every <see cref="Setup"/>. /// Creates the room dependencies. Called every <see cref="Setup"/>.
/// </summary> /// </summary>

View File

@ -2,9 +2,7 @@
// 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;
using osu.Framework.Allocation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.OnlinePlay.Components; using osu.Game.Screens.OnlinePlay.Components;
@ -21,14 +19,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
private int currentRoomId; private int currentRoomId;
private readonly TestRoomRequestsHandler handler = new TestRoomRequestsHandler();
[BackgroundDependencyLoader]
private void load(IAPIProvider api, OsuGameBase game)
{
((DummyAPIAccess)api).HandleRequest = request => handler.HandleRequest(request, api.LocalUser.Value, game);
}
public override void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null) public override void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null)
{ {
JoinRoomRequested?.Invoke(room, password); JoinRoomRequested?.Invoke(room, password);