1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 19:02:56 +08:00

Use ChildrenOfType<> to get ScoreTable to test

This commit is contained in:
Jonas Brandstötter 2024-10-14 16:11:58 +02:00
parent dcd3e5194e
commit 750e0b29ca
No known key found for this signature in database
GPG Key ID: DF758C8A6271E098
2 changed files with 15 additions and 10 deletions

View File

@ -103,16 +103,21 @@ namespace osu.Game.Tests.Visual.Online
}); });
AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType<ScoreTableRowBackground>().Any()); AddUntilStep("wait for scores displayed", () => scoresContainer.ChildrenOfType<ScoreTableRowBackground>().Any());
AddAssert("only one column for slider end", () => scoresContainer.ScoreTable.Columns.Count(c => c.Header.Equals("slider end")) == 1); AddAssert("only one column for slider end", () =>
{
ScoreTable scoreTable = scoresContainer.ChildrenOfType<ScoreTable>().First();
return scoreTable.Columns.Count(c => c.Header.Equals("slider end")) == 1;
});
AddAssert("all rows show non-zero slider ends", () => AddAssert("all rows show non-zero slider ends", () =>
{ {
int sliderEndColumnIndex = Array.FindIndex(scoresContainer.ScoreTable.Columns, c => c != null && c.Header.Equals("slider end")); ScoreTable scoreTable = scoresContainer.ChildrenOfType<ScoreTable>().First();
int sliderEndColumnIndex = Array.FindIndex(scoreTable.Columns, c => c != null && c.Header.Equals("slider end"));
bool sliderEndFilledInEachRow = true; bool sliderEndFilledInEachRow = true;
for (int i = 0; i < scoresContainer.ScoreTable.Content?.GetLength(0); i++) for (int i = 0; i < scoreTable.Content?.GetLength(0); i++)
{ {
switch (scoresContainer.ScoreTable.Content[i, sliderEndColumnIndex]) switch (scoreTable.Content[i, sliderEndColumnIndex])
{ {
case OsuSpriteText text: case OsuSpriteText text:
if (text.Text.Equals(0.0d.ToLocalisableString(@"N0"))) if (text.Text.Equals(0.0d.ToLocalisableString(@"N0")))

View File

@ -34,7 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly IBindable<APIUser> user = new Bindable<APIUser>(); private readonly IBindable<APIUser> user = new Bindable<APIUser>();
private readonly Box background; private readonly Box background;
public readonly ScoreTable ScoreTable; private readonly ScoreTable scoreTable;
private readonly FillFlowContainer topScoresContainer; private readonly FillFlowContainer topScoresContainer;
private readonly LoadingLayer loading; private readonly LoadingLayer loading;
private readonly LeaderboardModSelector modSelector; private readonly LeaderboardModSelector modSelector;
@ -59,8 +59,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
loadCancellationSource = new CancellationTokenSource(); loadCancellationSource = new CancellationTokenSource();
topScoresContainer.Clear(); topScoresContainer.Clear();
ScoreTable.ClearScores(); scoreTable.ClearScores();
ScoreTable.Hide(); scoreTable.Hide();
loading.Hide(); loading.Hide();
loading.FinishTransforms(); loading.FinishTransforms();
@ -85,8 +85,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
var scores = value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo)).OrderByTotalScore().ToArray(); var scores = value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo)).OrderByTotalScore().ToArray();
var topScore = scores.First(); var topScore = scores.First();
ScoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints()); scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
ScoreTable.Show(); scoreTable.Show();
var userScore = value.UserScore; var userScore = value.UserScore;
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo); var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
@ -175,7 +175,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5), Spacing = new Vector2(0, 5),
}, },
ScoreTable = new ScoreTable scoreTable = new ScoreTable
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,