1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:33:20 +08:00

Don't break VisualTests and add a real beatmap step.

This commit is contained in:
Unknown 2017-11-25 20:59:03 +05:30
parent e723e66850
commit 0b3f75505e
2 changed files with 60 additions and 11 deletions

View File

@ -6,15 +6,43 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users;
using osu.Framework.Allocation;
using OpenTK;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
namespace osu.Game.Tests.Visual
{
[Description("PlaySongSelect leaderboard")]
internal class TestCaseLeaderboard : OsuTestCase
{
private RulesetStore rulesets;
private readonly Leaderboard leaderboard;
public TestCaseLeaderboard()
{
Add(leaderboard = new Leaderboard
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f),
Scope = LeaderboardScope.Global,
});
AddStep(@"New Scores", newScores);
AddStep(@"Empty Scores", () => leaderboard.Scores = Enumerable.Empty<Score>());
AddStep(@"Real beatmap", realBeatmap);
newScores();
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
this.rulesets = rulesets;
}
private void newScores()
{
var scores = new[]
@ -204,17 +232,36 @@ namespace osu.Game.Tests.Visual
leaderboard.Scores = scores;
}
public TestCaseLeaderboard()
private void realBeatmap()
{
Add(leaderboard = new Leaderboard
leaderboard.Beatmap = new BeatmapInfo
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f),
});
AddStep(@"New Scores", newScores);
newScores();
StarDifficulty = 1.36,
Version = @"BASIC",
OnlineBeatmapID = 1113057,
Ruleset = rulesets.GetRuleset(0),
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 4,
DrainRate = 6.5f,
OverallDifficulty = 6.5f,
ApproachRate = 5,
},
OnlineInfo = new BeatmapOnlineInfo
{
Length = 115000,
CircleCount = 265,
SliderCount = 71,
PlayCount = 47906,
PassCount = 19899,
},
Metrics = new BeatmapMetrics
{
Ratings = Enumerable.Range(0, 11),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
},
};
}
}
}

View File

@ -51,6 +51,7 @@ namespace osu.Game.Screens.Select.Leaderboards
noResultsPlaceholder.FadeOut(fade_duration);
scrollFlow?.FadeOut(fade_duration).Expire();
scrollContainer.Clear(true); // scores stick around in scrollFlow in VisualTests without this for some reason
scrollFlow = null;
loading.Hide();
@ -204,7 +205,8 @@ namespace osu.Game.Screens.Select.Leaderboards
this.api = api;
this.osuGame = osuGame;
osuGame.Ruleset.ValueChanged += r => updateScores();
if (osuGame != null)
osuGame.Ruleset.ValueChanged += r => updateScores();
}
private GetScoresRequest getScoresRequest;
@ -228,7 +230,7 @@ namespace osu.Game.Screens.Select.Leaderboards
loading.Show();
getScoresRequest = new GetScoresRequest(Beatmap, osuGame.Ruleset.Value, Scope);
getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value, Scope);
getScoresRequest.Success += r =>
{
Scores = r.Scores;