1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Move UserLookupCache to online play test dependencies

This commit is contained in:
Dan Balasescu 2022-02-15 20:56:46 +09:00
parent b2276baf71
commit c48a0dc993
8 changed files with 13 additions and 14 deletions

View File

@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = LookupCache.GetUserAsync(1).GetResultSafely());
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = UserLookupCache.GetUserAsync(1).GetResultSafely());
AddStep("create leaderboard", () =>
{
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestUserQuit()
{
foreach (int user in users)
AddStep($"mark user {user} quit", () => Client.RemoveUser(LookupCache.GetUserAsync(user).GetResultSafely().AsNonNull()));
AddStep($"mark user {user} quit", () => Client.RemoveUser(UserLookupCache.GetUserAsync(user).GetResultSafely().AsNonNull()));
}
[Test]

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
base.SetUpSteps();
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = LookupCache.GetUserAsync(1).GetResultSafely());
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = UserLookupCache.GetUserAsync(1).GetResultSafely());
AddStep("create leaderboard", () =>
{

View File

@ -1,7 +1,6 @@
// 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.Database;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Tests.Visual.OnlinePlay;
@ -24,11 +23,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
/// </summary>
new TestMultiplayerRoomManager RoomManager { get; }
/// <summary>
/// The cached <see cref="UserLookupCache"/>.
/// </summary>
TestUserLookupCache LookupCache { get; }
/// <summary>
/// The cached <see cref="osu.Game.Online.Spectator.SpectatorClient"/>.
/// </summary>

View File

@ -19,7 +19,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
public TestMultiplayerClient Client => OnlinePlayDependencies.Client;
public new TestMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
public TestUserLookupCache LookupCache => OnlinePlayDependencies?.LookupCache;
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies?.SpectatorClient;
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;

View File

@ -1,7 +1,6 @@
// 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.Database;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Spectator;
using osu.Game.Screens.OnlinePlay;
@ -16,18 +15,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
public class MultiplayerTestSceneDependencies : OnlinePlayTestSceneDependencies, IMultiplayerTestSceneDependencies
{
public TestMultiplayerClient Client { get; }
public TestUserLookupCache LookupCache { get; }
public TestSpectatorClient SpectatorClient { get; }
public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
public MultiplayerTestSceneDependencies()
{
Client = new TestMultiplayerClient(RoomManager);
LookupCache = new TestUserLookupCache();
SpectatorClient = CreateSpectatorClient();
CacheAs<MultiplayerClient>(Client);
CacheAs<UserLookupCache>(LookupCache);
CacheAs<SpectatorClient>(SpectatorClient);
}

View File

@ -31,5 +31,10 @@ namespace osu.Game.Tests.Visual.OnlinePlay
/// The cached <see cref="OnlinePlayBeatmapAvailabilityTracker"/>.
/// </summary>
OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker { get; }
/// <summary>
/// The cached <see cref="UserLookupCache"/>.
/// </summary>
TestUserLookupCache UserLookupCache { get; }
}
}

View File

@ -22,6 +22,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
public IRoomManager RoomManager => OnlinePlayDependencies?.RoomManager;
public OngoingOperationTracker OngoingOperationTracker => OnlinePlayDependencies?.OngoingOperationTracker;
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker => OnlinePlayDependencies?.AvailabilityTracker;
public TestUserLookupCache UserLookupCache => OnlinePlayDependencies?.UserLookupCache;
/// <summary>
/// All dependencies required for online play components and screens.

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Database;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay;
@ -22,6 +23,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
public OngoingOperationTracker OngoingOperationTracker { get; }
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker { get; }
public TestRoomRequestsHandler RequestsHandler { get; }
public TestUserLookupCache UserLookupCache { get; }
/// <summary>
/// All cached dependencies which are also <see cref="Drawable"/> components.
@ -38,6 +40,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
OngoingOperationTracker = new OngoingOperationTracker();
AvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
RoomManager = CreateRoomManager();
UserLookupCache = new TestUserLookupCache();
dependencies = new DependencyContainer(new CachedModelDependencyContainer<Room>(null) { Model = { BindTarget = SelectedRoom } });
@ -47,6 +50,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
CacheAs(OngoingOperationTracker);
CacheAs(AvailabilityTracker);
CacheAs(new OverlayColourProvider(OverlayColourScheme.Plum));
CacheAs<UserLookupCache>(UserLookupCache);
}
public object Get(Type type)