mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Merge pull request #16194 from peppy/fix-results-screen-wait-test
Fix intermittent test failures on `TestSceneResultsScreen` due to long delay step
This commit is contained in:
commit
a53c67b2ea
@ -203,8 +203,12 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
DelayedFetchResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(TestResources.CreateTestScoreInfo(), 3000)));
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(TestResources.CreateTestScoreInfo(), tcs.Task)));
|
||||
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
@ -212,6 +216,10 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("no fetch yet", () => !screen.FetchCompleted);
|
||||
|
||||
AddStep("allow fetch", () => tcs.SetResult());
|
||||
|
||||
AddUntilStep("wait for fetch", () => screen.FetchCompleted);
|
||||
AddAssert("expanded panel still on screen", () => this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0);
|
||||
}
|
||||
@ -295,21 +303,21 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
private class DelayedFetchResultsScreen : TestResultsScreen
|
||||
{
|
||||
private readonly Task fetchWaitTask;
|
||||
|
||||
public bool FetchCompleted { get; private set; }
|
||||
|
||||
private readonly double delay;
|
||||
|
||||
public DelayedFetchResultsScreen(ScoreInfo score, double delay)
|
||||
public DelayedFetchResultsScreen(ScoreInfo score, Task fetchWaitTask = null)
|
||||
: base(score)
|
||||
{
|
||||
this.delay = delay;
|
||||
this.fetchWaitTask = fetchWaitTask ?? Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
await fetchWaitTask;
|
||||
|
||||
var scores = new List<ScoreInfo>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user