2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
2019-06-13 17:51:41 +08:00
|
|
|
|
using NUnit.Framework;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2021-04-02 20:14:31 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2021-10-25 13:44:49 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[System.ComponentModel.Description("PlaySongSelect beatmap details")]
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneBeatmapDetails : OsuTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-13 17:51:41 +08:00
|
|
|
|
private BeatmapDetails details;
|
|
|
|
|
|
2021-04-02 20:14:31 +08:00
|
|
|
|
private DummyAPIAccess api => (DummyAPIAccess)API;
|
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup() => Schedule(() =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-13 17:51:41 +08:00
|
|
|
|
Child = details = new BeatmapDetails
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding(150),
|
2019-06-13 17:51:41 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestAllMetrics()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("all metrics", () => details.BeatmapInfo = new APIBeatmap
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
BeatmapSet = new APIBeatmapSet
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-07-04 11:39:50 +08:00
|
|
|
|
Source = "osu!",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Tags = "this beatmap has all the metrics",
|
2021-11-01 14:42:12 +08:00
|
|
|
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2021-11-01 14:42:12 +08:00
|
|
|
|
DifficultyName = "All Metrics",
|
|
|
|
|
CircleSize = 7,
|
|
|
|
|
DrainRate = 1,
|
|
|
|
|
OverallDifficulty = 5.7f,
|
|
|
|
|
ApproachRate = 3.5f,
|
|
|
|
|
StarRating = 5.3f,
|
|
|
|
|
FailTimes = new APIFailTimes
|
|
|
|
|
{
|
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestAllMetricsExceptSource()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("all except source", () => details.BeatmapInfo = new APIBeatmap
|
2019-02-26 15:12:40 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
BeatmapSet = new APIBeatmapSet
|
2019-02-26 15:12:40 +08:00
|
|
|
|
{
|
|
|
|
|
Tags = "this beatmap has all the metrics",
|
2021-11-01 14:42:12 +08:00
|
|
|
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
2019-02-26 15:12:40 +08:00
|
|
|
|
},
|
2021-11-01 14:42:12 +08:00
|
|
|
|
DifficultyName = "All Metrics",
|
|
|
|
|
CircleSize = 7,
|
|
|
|
|
DrainRate = 1,
|
|
|
|
|
OverallDifficulty = 5.7f,
|
|
|
|
|
ApproachRate = 3.5f,
|
|
|
|
|
StarRating = 5.3f,
|
|
|
|
|
FailTimes = new APIFailTimes
|
|
|
|
|
{
|
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
2019-02-26 15:12:40 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2019-02-26 15:12:40 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnlyRatings()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("ratings", () => details.BeatmapInfo = new APIBeatmap
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
BeatmapSet = new APIBeatmapSet
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
2021-07-04 11:39:50 +08:00
|
|
|
|
Source = "osu!",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Tags = "this beatmap has ratings metrics but not retries or fails",
|
|
|
|
|
},
|
2021-11-01 14:42:12 +08:00
|
|
|
|
DifficultyName = "Only Ratings",
|
|
|
|
|
CircleSize = 6,
|
|
|
|
|
DrainRate = 9,
|
|
|
|
|
OverallDifficulty = 6,
|
|
|
|
|
ApproachRate = 6,
|
|
|
|
|
StarRating = 4.8f,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnlyFailsAndRetries()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("fails retries", () => details.BeatmapInfo = new APIBeatmap
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
DifficultyName = "Only Retries and Fails",
|
|
|
|
|
BeatmapSet = new APIBeatmapSet
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-07-04 11:39:50 +08:00
|
|
|
|
Source = "osu!",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Tags = "this beatmap has retries and fails but no ratings",
|
|
|
|
|
},
|
2021-11-01 14:42:12 +08:00
|
|
|
|
CircleSize = 3.7f,
|
|
|
|
|
DrainRate = 6,
|
|
|
|
|
OverallDifficulty = 6,
|
|
|
|
|
ApproachRate = 7,
|
|
|
|
|
StarRating = 2.91f,
|
|
|
|
|
FailTimes = new APIFailTimes
|
|
|
|
|
{
|
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestNoMetrics()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("no metrics", () => details.BeatmapInfo = new APIBeatmap
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
DifficultyName = "No Metrics",
|
|
|
|
|
BeatmapSet = new APIBeatmapSet
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-07-04 11:39:50 +08:00
|
|
|
|
Source = "osu!",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Tags = "this beatmap has no metrics",
|
|
|
|
|
},
|
2021-11-01 14:42:12 +08:00
|
|
|
|
CircleSize = 5,
|
|
|
|
|
DrainRate = 5,
|
|
|
|
|
OverallDifficulty = 5.5f,
|
|
|
|
|
ApproachRate = 6.5f,
|
|
|
|
|
StarRating = 1.97f,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestNullBeatmap()
|
|
|
|
|
{
|
2021-10-02 23:55:29 +08:00
|
|
|
|
AddStep("null beatmap", () => details.BeatmapInfo = null);
|
2019-06-13 17:51:41 +08:00
|
|
|
|
}
|
2019-06-13 16:10:09 +08:00
|
|
|
|
|
2019-06-13 17:51:41 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnlineMetrics()
|
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
AddStep("online ratings/retries/fails", () => details.BeatmapInfo = new APIBeatmap
|
2019-06-13 16:10:09 +08:00
|
|
|
|
{
|
2021-11-01 14:42:12 +08:00
|
|
|
|
OnlineID = 162,
|
2019-06-13 16:10:09 +08:00
|
|
|
|
});
|
2021-04-02 20:14:31 +08:00
|
|
|
|
AddStep("set online", () => api.SetState(APIState.Online));
|
|
|
|
|
AddStep("set offline", () => api.SetState(APIState.Offline));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|