osu/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightS...

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

85 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.
2022-06-17 07:37:17 +00:00
#nullable disable
using System;
using System.Collections.Generic;
2020-01-14 05:37:14 +00: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-03 16:44:10 +00:00
using osu.Game.Overlays;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online
{
public partial class TestSceneRankingsSpotlightSelector : OsuTestScene
{
2020-01-14 05:37:14 +00:00
protected override bool UseOnlineAPI => true;
2020-02-03 16:44:10 +00:00
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2020-01-14 05:37:14 +00:00
[Resolved]
private IAPIProvider api { get; set; }
private readonly SpotlightSelector selector;
public TestSceneRankingsSpotlightSelector()
{
Add(selector = new SpotlightSelector());
2020-01-14 05:37:14 +00:00
}
2020-01-14 05:37:14 +00:00
[Test]
public void TestLocalSpotlights()
{
2020-01-14 04:20:03 +00:00
var spotlights = new[]
{
2020-01-14 05:37:14 +00: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 05:37:14 +00: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 05:37:14 +00:00
if (spotlights != null)
selector.Spotlights = spotlights;
2020-01-14 05:01:51 +00:00
});
}
}
}