Merge branch 'master' into fix-editor-hard-crash

This commit is contained in:
Dan Balasescu
2020-04-24 12:29:48 +09:00
committed by GitHub
3 changed files with 23 additions and 16 deletions

View File

@ -4,33 +4,27 @@
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
namespace osu.Game.Tests.Visual.Editing namespace osu.Game.Tests.Visual.Editing
{ {
public class TestSceneEditorChangeStates : ScreenTestScene public class TestSceneEditorChangeStates : EditorTestScene
{ {
public TestSceneEditorChangeStates()
: base(new OsuRuleset())
{
}
private EditorBeatmap editorBeatmap; private EditorBeatmap editorBeatmap;
private TestEditor editor;
public override void SetUpSteps() public override void SetUpSteps()
{ {
base.SetUpSteps(); base.SetUpSteps();
AddStep("load editor", () => AddStep("get beatmap", () => editorBeatmap = Editor.ChildrenOfType<EditorBeatmap>().Single());
{
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
LoadScreen(editor = new TestEditor());
});
AddUntilStep("wait for editor to load", () => editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true
&& editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true);
AddStep("get beatmap", () => editorBeatmap = editor.ChildrenOfType<EditorBeatmap>().Single());
} }
[Test] [Test]
@ -158,9 +152,11 @@ namespace osu.Game.Tests.Visual.Editing
AddAssert("no hitobject added", () => addedObject == null); AddAssert("no hitobject added", () => addedObject == null);
} }
private void addUndoSteps() => AddStep("undo", () => editor.Undo()); private void addUndoSteps() => AddStep("undo", () => ((TestEditor)Editor).Undo());
private void addRedoSteps() => AddStep("redo", () => editor.Redo()); private void addRedoSteps() => AddStep("redo", () => ((TestEditor)Editor).Redo());
protected override Editor CreateEditor() => new TestEditor();
private class TestEditor : Editor private class TestEditor : Editor
{ {

View File

@ -23,6 +23,7 @@ namespace osu.Game.Tests.Beatmaps
HitObjects = baseBeatmap.HitObjects; HitObjects = baseBeatmap.HitObjects;
BeatmapInfo.Ruleset = ruleset; BeatmapInfo.Ruleset = ruleset;
BeatmapInfo.RulesetID = ruleset.ID ?? 0;
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata; BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo }; BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo

View File

@ -3,9 +3,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
@ -13,6 +17,8 @@ namespace osu.Game.Tests.Visual
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) }; public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) };
protected Editor Editor { get; private set; }
private readonly Ruleset ruleset; private readonly Ruleset ruleset;
protected EditorTestScene(Ruleset ruleset) protected EditorTestScene(Ruleset ruleset)
@ -30,7 +36,11 @@ namespace osu.Game.Tests.Visual
{ {
base.SetUpSteps(); base.SetUpSteps();
AddStep("Load editor", () => LoadScreen(new Editor())); AddStep("load editor", () => LoadScreen(Editor = CreateEditor()));
AddUntilStep("wait for editor to load", () => Editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true);
} }
protected virtual Editor CreateEditor() => new Editor();
} }
} }