Add check for player screens too

This commit is contained in:
Dean Herbert 2018-06-13 15:26:05 +09:00
parent 14f5c814a6
commit 39738a997e
1 changed files with 12 additions and 2 deletions

View File

@ -6,7 +6,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Lists;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@ -55,6 +54,7 @@ private void load(RulesetStore rulesets)
Player p = null;
AddStep(r.Name, () => p = loadPlayerFor(r));
AddUntilStep(() => ContinueCondition(p));
AddAssert("no leaked beatmaps", () =>
{
p = null;
@ -64,9 +64,16 @@ private void load(RulesetStore rulesets)
int count = 0;
workingWeakReferences.ForEachAlive(_ => count++);
return count == 1;
});
Logger.Log($"reference count {count}");
AddAssert("no leaked players", () =>
{
GC.Collect();
GC.WaitForPendingFinalizers();
int count = 0;
playerWeakReferences.ForEachAlive(_ => count++);
return count == 1;
});
}
@ -78,6 +85,7 @@ private void load(RulesetStore rulesets)
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
private readonly WeakList<WorkingBeatmap> workingWeakReferences = new WeakList<WorkingBeatmap>();
private readonly WeakList<Player> playerWeakReferences = new WeakList<Player>();
private Player loadPlayerFor(RulesetInfo ri) => loadPlayerFor(ri.CreateInstance());
@ -95,6 +103,8 @@ private Player loadPlayerFor(Ruleset r)
var player = CreatePlayer(r);
playerWeakReferences.Add(player);
LoadComponentAsync(player, p =>
{
Player = p;