mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Merge branch 'master' into visual-settings-container
This commit is contained in:
@ -1,12 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseAllPlayers : TestCasePlayer
|
||||
{
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
@ -11,7 +10,7 @@ using osu.Game.Screens.Play;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("Player instantiated with an autoplay mod.")]
|
||||
public class TestCaseAutoplay : TestCasePlayer
|
||||
public class TestCaseAutoplay : AllPlayersTestCase
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
@ -24,11 +23,10 @@ namespace osu.Game.Tests.Visual
|
||||
};
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps(Func<Player> player)
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
base.AddCheckSteps(player);
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
}
|
||||
|
||||
private class ScoreAccessiblePlayer : Player
|
||||
|
@ -371,7 +371,7 @@ namespace osu.Game.Tests.Visual
|
||||
Thread.Sleep(1);
|
||||
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||
RulesetContainer.IsPaused.BindTo(IsPaused);
|
||||
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
||||
}
|
||||
}
|
||||
|
||||
|
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.cs
Normal file
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCasePlayerReferenceLeaking : AllPlayersTestCase
|
||||
{
|
||||
private readonly WeakList<WorkingBeatmap> workingWeakReferences = new WeakList<WorkingBeatmap>();
|
||||
|
||||
private readonly WeakList<Player> playerWeakReferences = new WeakList<Player>();
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("no leaked beatmaps", () =>
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
int count = 0;
|
||||
|
||||
workingWeakReferences.ForEachAlive(_ => count++);
|
||||
return count == 1;
|
||||
});
|
||||
|
||||
AddUntilStep("no leaked players", () =>
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
int count = 0;
|
||||
|
||||
playerWeakReferences.ForEachAlive(_ => count++);
|
||||
return count == 1;
|
||||
});
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock)
|
||||
{
|
||||
var working = base.CreateWorkingBeatmap(beatmap, clock);
|
||||
workingWeakReferences.Add(working);
|
||||
return working;
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
var player = base.CreatePlayer(ruleset);
|
||||
playerWeakReferences.Add(player);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
@ -12,7 +11,7 @@ using osu.Game.Screens.Play;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("Player instantiated with a replay.")]
|
||||
public class TestCaseReplay : TestCasePlayer
|
||||
public class TestCaseReplay : AllPlayersTestCase
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
@ -21,11 +20,10 @@ namespace osu.Game.Tests.Visual
|
||||
return new ScoreAccessibleReplayPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps(Func<Player> player)
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
base.AddCheckSteps(player);
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)player()).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
}
|
||||
|
||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
|
Reference in New Issue
Block a user