mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:43:04 +08:00
Fix online play test request handling
This commit is contained in:
parent
45db99171e
commit
85b21174dd
@ -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>
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user