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

Create a base TestCaseEditor for rulests to derive

This commit is contained in:
smoogipoo 2018-03-12 19:38:23 +09:00
parent 13c20438ef
commit d2859d779d
6 changed files with 51 additions and 50 deletions

View File

@ -0,0 +1,16 @@
// 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;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
public class TestCaseEditor : Game.Tests.Visual.TestCaseEditor
{
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 TestCaseEditor : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) };
private readonly Ruleset ruleset;
protected TestCaseEditor(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
{
osuGame.Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo);
Child = new Editor();
}
}
}

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\TestCaseEditor.cs" />
<Compile Include="Tests\Visual\TestCasePerformancePoints.cs" />
<Compile Include="Tests\Visual\ScreenTestCase.cs" />
<Compile Include="Tests\Visual\TestCasePlayer.cs" />