1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:09:34 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.4 KiB
C#
Raw Normal View History

// 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 System;
using System.Collections.Generic;
2020-01-14 13:37:14 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
2020-02-04 00:44:10 +08:00
using osu.Game.Overlays;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsSpotlightSelector : OsuTestScene
{
2020-01-14 13:37:14 +08:00
protected override bool UseOnlineAPI => true;
2020-02-04 00:44:10 +08:00
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2020-01-14 13:37:14 +08:00
[Resolved]
private IAPIProvider api { get; set; }
private readonly SpotlightSelector selector;
public TestSceneRankingsSpotlightSelector()
{
Add(selector = new SpotlightSelector());
2020-01-14 13:37:14 +08:00
}
2020-01-14 13:37:14 +08:00
[Test]
public void TestLocalSpotlights()
{
2020-01-14 12:20:03 +08:00
var spotlights = new[]
{
2020-01-14 13:37:14 +08:00
new APISpotlight
{
Name = "Spotlight 1",
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now,
},
new APISpotlight
{
Name = "Spotlight 2",
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now,
},
new APISpotlight
{
Name = "Spotlight 3",
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now,
},
};
2020-01-14 13:37:14 +08:00
AddStep("load spotlights", () => selector.Spotlights = spotlights);
AddStep("change to spotlight 3", () => selector.Current.Value = spotlights[2]);
}
[Test]
public void TestOnlineSpotlights()
{
List<APISpotlight> spotlights = null;
AddStep("retrieve spotlights", () =>
{
var req = new GetSpotlightsRequest();
req.Success += res => spotlights = res.Spotlights;
api.Perform(req);
});
AddStep("set spotlights", () =>
{
2020-01-14 13:37:14 +08:00
if (spotlights != null)
selector.Spotlights = spotlights;
2020-01-14 13:01:51 +08:00
});
}
}
}