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 @@ public void TestHitResultsWithSameNameAreGrouped()
});
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", () =>
{
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;
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:
if (text.Text.Equals(0.0d.ToLocalisableString(@"N0")))

View File

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