mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:47:52 +08:00
Assert that test is run headless when required
This commit is contained in:
parent
57b2f8189c
commit
e64b2b1682
@ -8,6 +8,7 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -26,8 +27,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected virtual bool HasCustomSteps => false;
|
protected virtual bool HasCustomSteps => false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WARNING: ONLY WORKS IF RUN HEADLESS because reasons.
|
/// Import the beatmap to the database before starting gameplay. Handy for testing local score storage and the likes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Only works under headless operation currently due to realm isolation difficulties.
|
||||||
|
/// If this is ever needed to change, consideration needs to be given to the fact that BeatmapManager is attached to the global realm.
|
||||||
|
/// </remarks>
|
||||||
protected virtual bool ImportBeatmapToDatabase => false;
|
protected virtual bool ImportBeatmapToDatabase => false;
|
||||||
|
|
||||||
protected TestPlayer Player;
|
protected TestPlayer Player;
|
||||||
@ -77,6 +82,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
if (ImportBeatmapToDatabase)
|
if (ImportBeatmapToDatabase)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(DebugUtils.IsNUnitRunning, $@"Importing beatmaps in {nameof(PlayerTestScene)} requires headless environment.");
|
||||||
|
|
||||||
Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
|
Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
|
||||||
|
|
||||||
var imported = beatmaps.Import(beatmap.BeatmapInfo.BeatmapSet);
|
var imported = beatmaps.Import(beatmap.BeatmapInfo.BeatmapSet);
|
||||||
|
Loading…
Reference in New Issue
Block a user