mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Merge branch 'master' into fix-editor-hard-crash
This commit is contained in:
commit
e67ac515fc
@ -4,33 +4,27 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public class TestSceneEditorChangeStates : ScreenTestScene
|
||||
public class TestSceneEditorChangeStates : EditorTestScene
|
||||
{
|
||||
public TestSceneEditorChangeStates()
|
||||
: base(new OsuRuleset())
|
||||
{
|
||||
}
|
||||
|
||||
private EditorBeatmap editorBeatmap;
|
||||
private TestEditor editor;
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("load editor", () =>
|
||||
{
|
||||
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());
|
||||
AddStep("get beatmap", () => editorBeatmap = Editor.ChildrenOfType<EditorBeatmap>().Single());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -158,9 +152,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
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
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
HitObjects = baseBeatmap.HitObjects;
|
||||
|
||||
BeatmapInfo.Ruleset = ruleset;
|
||||
BeatmapInfo.RulesetID = ruleset.ID ?? 0;
|
||||
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
||||
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
||||
BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo
|
||||
|
@ -3,9 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@ -13,6 +17,8 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Editor), typeof(EditorScreen) };
|
||||
|
||||
protected Editor Editor { get; private set; }
|
||||
|
||||
private readonly Ruleset ruleset;
|
||||
|
||||
protected EditorTestScene(Ruleset ruleset)
|
||||
@ -30,7 +36,11 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user