2019-06-13 09:31:39 +00:00
|
|
|
// 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.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2020-02-04 21:39:51 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-06-13 09:31:39 +00:00
|
|
|
using osu.Framework.Graphics;
|
2020-01-09 04:43:44 +00:00
|
|
|
using osu.Framework.Utils;
|
2019-06-13 09:31:39 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2021-10-20 09:43:48 +00:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-02-04 21:39:51 +00:00
|
|
|
using osu.Game.Overlays;
|
2019-06-13 09:31:39 +00:00
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
|
|
|
using osu.Game.Screens.Select.Details;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
{
|
|
|
|
public class TestSceneBeatmapSetOverlayDetails : OsuTestScene
|
|
|
|
{
|
|
|
|
private RatingsExposingDetails details;
|
|
|
|
|
2020-02-04 21:39:51 +00:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
2019-06-13 09:31:39 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Child = details = new RatingsExposingDetails
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMetrics()
|
|
|
|
{
|
|
|
|
var firstSet = createSet();
|
|
|
|
var secondSet = createSet();
|
|
|
|
|
|
|
|
AddStep("set first set", () => details.BeatmapSet = firstSet);
|
2021-10-25 05:44:49 +00:00
|
|
|
AddAssert("ratings set", () => details.Ratings.Ratings == firstSet.Ratings);
|
2019-06-13 09:31:39 +00:00
|
|
|
|
|
|
|
AddStep("set second set", () => details.BeatmapSet = secondSet);
|
2021-10-25 05:44:49 +00:00
|
|
|
AddAssert("ratings set", () => details.Ratings.Ratings == secondSet.Ratings);
|
2019-06-13 09:31:39 +00:00
|
|
|
|
2019-12-14 12:26:28 +00:00
|
|
|
static BeatmapSetInfo createSet() => new BeatmapSetInfo
|
2019-06-13 09:31:39 +00:00
|
|
|
{
|
|
|
|
Beatmaps = new List<BeatmapInfo>
|
|
|
|
{
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2021-10-25 06:12:11 +00:00
|
|
|
OnlineInfo = new APIBeatmap
|
2019-06-13 09:31:39 +00:00
|
|
|
{
|
2021-10-25 06:12:11 +00:00
|
|
|
Metrics = new BeatmapMetrics
|
|
|
|
{
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
|
|
|
},
|
|
|
|
}
|
2019-06-13 09:31:39 +00:00
|
|
|
}
|
2020-02-04 21:39:51 +00:00
|
|
|
},
|
2021-10-20 09:43:48 +00:00
|
|
|
OnlineInfo = new APIBeatmapSet
|
2020-02-04 21:39:51 +00:00
|
|
|
{
|
2021-10-25 05:44:49 +00:00
|
|
|
Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(),
|
2020-02-04 21:39:51 +00:00
|
|
|
Status = BeatmapSetOnlineStatus.Ranked
|
2019-06-13 09:31:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private class RatingsExposingDetails : Details
|
|
|
|
{
|
|
|
|
public new UserRatings Ratings => base.Ratings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|