apply some suggestions/corrections

This commit is contained in:
wooster0 2024-01-09 21:28:46 +09:00
parent 2c64db0628
commit 8ad697ff4c
2 changed files with 24 additions and 24 deletions

View File

@ -79,6 +79,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("bind user score info handler", () => bindHandler(userScore: userScore)); AddStep("bind user score info handler", () => bindHandler(userScore: userScore));
createResults(() => userScore); createResults(() => userScore);
waitForDisplay();
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded); AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
AddAssert($"score panel position is {real_user_position}", AddAssert($"score panel position is {real_user_position}",
@ -91,6 +92,7 @@ namespace osu.Game.Tests.Visual.Playlists
InitialiseUserScoresAndBeatmap(); InitialiseUserScoresAndBeatmap();
createResults(); createResults();
waitForDisplay();
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded); AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
} }
@ -103,6 +105,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("bind user score info handler", () => bindHandler(true, userScore)); AddStep("bind user score info handler", () => bindHandler(true, userScore));
createResults(() => userScore); createResults(() => userScore);
waitForDisplay();
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1); AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded); AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
@ -116,6 +119,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("bind delayed handler", () => bindHandler(true)); AddStep("bind delayed handler", () => bindHandler(true));
createResults(); createResults();
waitForDisplay();
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded); AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
} }
@ -126,6 +130,7 @@ namespace osu.Game.Tests.Visual.Playlists
InitialiseUserScoresAndBeatmap(); InitialiseUserScoresAndBeatmap();
createResults(); createResults();
waitForDisplay();
AddStep("bind delayed handler", () => bindHandler(true)); AddStep("bind delayed handler", () => bindHandler(true));
@ -152,6 +157,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("bind user score info handler", () => bindHandler(userScore: userScore)); AddStep("bind user score info handler", () => bindHandler(userScore: userScore));
createResults(() => userScore); createResults(() => userScore);
waitForDisplay();
AddStep("bind delayed handler", () => bindHandler(true)); AddStep("bind delayed handler", () => bindHandler(true));
@ -174,12 +180,11 @@ namespace osu.Game.Tests.Visual.Playlists
public void TestShowWithNoScores() public void TestShowWithNoScores()
{ {
InitialiseUserScoresAndBeatmap(noScores: true); InitialiseUserScoresAndBeatmap(noScores: true);
createResults();
createResults(noScores: true);
AddAssert("no scores visible", () => resultsScreen.ScorePanelList.GetScorePanels().Count() == 0); AddAssert("no scores visible", () => resultsScreen.ScorePanelList.GetScorePanels().Count() == 0);
} }
private void createResults(Func<ScoreInfo> getScore = null, bool noScores = false) private void createResults(Func<ScoreInfo> getScore = null)
{ {
AddStep("load results", () => AddStep("load results", () =>
{ {
@ -190,13 +195,10 @@ namespace osu.Game.Tests.Visual.Playlists
}); });
AddUntilStep("wait for screen to load", () => resultsScreen.IsLoaded); AddUntilStep("wait for screen to load", () => resultsScreen.IsLoaded);
waitForDisplay(noScores);
} }
private void waitForDisplay(bool noScores = false) private void waitForDisplay()
{ {
if (noScores) return;
AddUntilStep("wait for scores loaded", () => AddUntilStep("wait for scores loaded", () =>
requestComplete requestComplete
// request handler may need to fire more than once to get scores. // request handler may need to fire more than once to get scores.

View File

@ -206,25 +206,17 @@ namespace osu.Game.Screens.Ranking
if (lastFetchCompleted) if (lastFetchCompleted)
{ {
if (ScorePanelList.IsEmpty) APIRequest nextPageRequest = null;
{
// This can happen if a beatmap part of a playlist hasn't been played yet.
VerticalScrollContent.Add(new MessagePlaceholder(LeaderboardStrings.NoRecordsYet));
}
else
{
APIRequest nextPageRequest = null;
if (ScorePanelList.IsScrolledToStart) if (ScorePanelList.IsScrolledToStart)
nextPageRequest = FetchNextPage(-1, fetchScoresCallback); nextPageRequest = FetchNextPage(-1, fetchScoresCallback);
else if (ScorePanelList.IsScrolledToEnd) else if (ScorePanelList.IsScrolledToEnd)
nextPageRequest = FetchNextPage(1, fetchScoresCallback); nextPageRequest = FetchNextPage(1, fetchScoresCallback);
if (nextPageRequest != null) if (nextPageRequest != null)
{ {
lastFetchCompleted = false; lastFetchCompleted = false;
api.Queue(nextPageRequest); api.Queue(nextPageRequest);
}
} }
} }
} }
@ -255,6 +247,12 @@ namespace osu.Game.Screens.Ranking
addScore(s); addScore(s);
lastFetchCompleted = true; lastFetchCompleted = true;
if (ScorePanelList.IsEmpty)
{
// This can happen if for example a beatmap that is part of a playlist hasn't been played yet.
VerticalScrollContent.Add(new MessagePlaceholder(LeaderboardStrings.NoRecordsYet));
}
}); });
public override void OnEntering(ScreenTransitionEvent e) public override void OnEntering(ScreenTransitionEvent e)