mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Move to using test methods for better separation
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user