mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:57:52 +08:00
Add test case for the editor
This commit is contained in:
parent
cecfd7b0f3
commit
2a9edcbb4f
47
osu.Game/Tests/Visual/TestCaseEditor.cs
Normal file
47
osu.Game/Tests/Visual/TestCaseEditor.cs
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2007-2017 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.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Edit;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCaseEditor : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor) };
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -742,6 +742,7 @@
|
||||
<Compile Include="Tests\Visual\TestCaseDirect.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseDrawableRoom.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseDrawings.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseEditor.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseEditorMenuBar.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseEditorSummaryTimeline.cs" />
|
||||
<Compile Include="Tests\Visual\TestCaseGamefield.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user