1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:35:35 +08:00

Merge pull request #2206 from smoogipoo/base-editor-testcase

Create a base TestCaseEditor for rulesets to derive
This commit is contained in:
Dean Herbert 2018-03-13 16:44:12 +09:00 committed by GitHub
commit c332233a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 50 deletions

View File

@ -0,0 +1,17 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
public class TestCaseEditor : EditorTestCase
{
public TestCaseEditor()
: base(new OsuRuleset())
{
}
}
}

View File

@ -130,6 +130,7 @@
<Compile Include="Replays\OsuReplayFrame.cs" />
<Compile Include="Replays\OsuReplayInputHandler.cs" />
<Compile Include="Tests\OsuBeatmapConversionTest.cs" />
<Compile Include="Tests\TestCaseEditor.cs" />
<Compile Include="Tests\TestCaseHitCircle.cs" />
<Compile Include="Tests\TestCaseHitCircleHidden.cs" />
<Compile Include="Tests\TestCasePerformancePoints.cs" />

View File

@ -1,49 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Screens;
namespace osu.Game.Tests.Visual
{
[TestFixture]
public class TestCaseEditor : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) };
private readonly Random rng;
private BeatmapManager beatmaps;
private OsuGameBase osuGame;
public TestCaseEditor()
{
rng = new Random(1337);
Add(new Editor());
AddStep("Next beatmap", nextBeatmap);
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, BeatmapManager beatmaps)
{
this.osuGame = osuGame;
this.beatmaps = beatmaps;
}
private void nextBeatmap()
{
var sets = beatmaps.GetAllUsableBeatmapSets();
if (sets.Count == 0)
return;
BeatmapInfo info = sets[rng.Next(0, sets.Count)].Beatmaps[0];
osuGame.Beatmap.Value = beatmaps.GetWorkingBeatmap(info);
}
}
}

View File

@ -126,7 +126,6 @@
<Compile Include="Visual\TestCaseDirect.cs" />
<Compile Include="Visual\TestCaseDrawableRoom.cs" />
<Compile Include="Visual\TestCaseDrawings.cs" />
<Compile Include="Visual\TestCaseEditor.cs" />
<Compile Include="Visual\TestCaseEditorCompose.cs" />
<Compile Include="Visual\TestCaseEditorComposeRadioButtons.cs" />
<Compile Include="Visual\TestCaseEditorComposeTimeline.cs" />

View File

@ -0,0 +1,33 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Rulesets;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Screens;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual
{
public abstract class EditorTestCase : ScreenTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) };
private readonly Ruleset ruleset;
protected EditorTestCase(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
{
osuGame.Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo);
LoadComponentAsync(new Editor(), LoadScreen);
}
}
}

View File

@ -902,6 +902,7 @@
<Compile Include="Tests\Platform\TestStorage.cs" />
<Compile Include="Tests\TestTestCase.cs" />
<Compile Include="Tests\Visual\OsuTestCase.cs" />
<Compile Include="Tests\Visual\EditorTestCase.cs" />
<Compile Include="Tests\Visual\TestCasePerformancePoints.cs" />
<Compile Include="Tests\Visual\ScreenTestCase.cs" />
<Compile Include="Tests\Visual\TestCasePlayer.cs" />