From bad970d1d1f0b0feee09c54ab3b5ee7918458d90 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Wed, 29 Nov 2017 17:25:55 +0900
Subject: [PATCH] Add wait steps to ensure the player is completely loaded
 before continuing

---
 osu.Game/Tests/Visual/TestCasePlayer.cs | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs
index 64da838494..d9951e002b 100644
--- a/osu.Game/Tests/Visual/TestCasePlayer.cs
+++ b/osu.Game/Tests/Visual/TestCasePlayer.cs
@@ -50,7 +50,11 @@ namespace osu.Game.Tests.Visual
             string instantiation = ruleset?.AssemblyQualifiedName;
 
             foreach (var r in rulesets.AvailableRulesets.Where(rs => instantiation == null || rs.InstantiationInfo == instantiation))
-                AddStep(r.Name, () => loadPlayerFor(r));
+            {
+                Player p = null;
+                AddStep(r.Name, () => p = loadPlayerFor(r));
+                AddUntilStep(() => p.IsLoaded);
+            }
         }
 
         protected virtual Beatmap CreateBeatmap()
@@ -64,7 +68,7 @@ namespace osu.Game.Tests.Visual
             return beatmap;
         }
 
-        private void loadPlayerFor(RulesetInfo r)
+        private Player loadPlayerFor(RulesetInfo r)
         {
             var beatmap = CreateBeatmap();
 
@@ -78,7 +82,11 @@ namespace osu.Game.Tests.Visual
             if (Player != null)
                 Remove(Player);
 
-            LoadComponentAsync(CreatePlayer(working, instance), LoadScreen);
+            var player = CreatePlayer(working, instance);
+
+            LoadComponentAsync(player, LoadScreen);
+
+            return player;
         }
 
         protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player