Move to using test methods for better separation

This commit is contained in:
smoogipoo
2020-03-02 12:20:25 +09:00
parent 239cfddcbb
commit ce7cbf29ca
4 changed files with 48 additions and 30 deletions

View File

@ -1,6 +1,7 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
@ -14,6 +15,11 @@ namespace osu.Game.Tests.Visual
{
public abstract class PlayerTestScene : RateAdjustedBeatmapTestScene
{
/// <summary>
/// Whether custom test steps are provided. Custom tests should invoke <see cref="CreateTest"/> to create the test steps.
/// </summary>
protected virtual bool HasCustomSteps { get; } = false;
private readonly Ruleset ruleset;
protected Player Player;
@ -37,6 +43,17 @@ namespace osu.Game.Tests.Visual
{
base.SetUpSteps();
if (!HasCustomSteps)
CreateTest(null);
}
protected void CreateTest(Action action)
{
if (action != null && !HasCustomSteps)
throw new InvalidOperationException($"Cannot add custom test steps without {nameof(HasCustomSteps)} being set.");
action?.Invoke();
AddStep(ruleset.RulesetInfo.Name, LoadPlayer);
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
}