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

Fix regressed test

This commit is contained in:
Dean Herbert 2020-11-06 18:41:05 +09:00
parent 4bbd3fe886
commit ee84a9827e

View File

@ -2,12 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Database;
using osu.Game.Online.Spectator;
using osu.Game.Overlays.Dashboard;
using osu.Game.Tests.Visual.Gameplay;
@ -22,32 +24,34 @@ namespace osu.Game.Tests.Visual.Online
private CurrentlyPlayingDisplay currentlyPlaying;
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
[Cached(typeof(UserLookupCache))]
private UserLookupCache lookupCache = new TestUserLookupCache();
private Container nestedContainer;
[SetUpSteps]
public void SetUpSteps()
{
AddStep("register request handling", () => dummyAPI.HandleRequest = req =>
{
switch (req)
{
case GetUserRequest cRequest:
cRequest.TriggerSuccess(new User { Username = "peppy", Id = 2 });
break;
}
});
AddStep("add streaming client", () =>
{
Remove(testSpectatorStreamingClient);
nestedContainer?.Remove(testSpectatorStreamingClient);
Remove(lookupCache);
Children = new Drawable[]
{
testSpectatorStreamingClient,
currentlyPlaying = new CurrentlyPlayingDisplay
lookupCache,
nestedContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
Children = new Drawable[]
{
testSpectatorStreamingClient,
currentlyPlaying = new CurrentlyPlayingDisplay
{
RelativeSizeAxes = Axes.Both,
}
}
},
};
});
@ -62,5 +66,11 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Remove playing user", () => testSpectatorStreamingClient.PlayingUsers.Remove(2));
AddUntilStep("Panel no longer present", () => !currentlyPlaying.ChildrenOfType<UserGridPanel>().Any());
}
internal class TestUserLookupCache : UserLookupCache
{
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default)
=> Task.FromResult(new User { Username = "peppy", Id = 2 });
}
}
}