Make selection blueprints a bit more testable

This commit is contained in:
smoogipoo
2019-10-01 19:32:47 +09:00
parent afb6023309
commit a310c4b65f
4 changed files with 20 additions and 27 deletions

View File

@ -1,10 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit;
@ -12,8 +10,6 @@ namespace osu.Game.Tests.Visual
{
public abstract class SelectionBlueprintTestScene : OsuTestScene
{
private SelectionBlueprint blueprint;
protected override Container<Drawable> Content => content ?? base.Content;
private readonly Container content;
@ -26,23 +22,13 @@ namespace osu.Game.Tests.Visual
});
}
[BackgroundDependencyLoader]
private void load()
protected void AddBlueprint(SelectionBlueprint blueprint)
{
blueprint = CreateBlueprint();
blueprint.Depth = float.MinValue;
blueprint.SelectionRequested += (_, __) => blueprint.Select();
Add(blueprint);
AddStep("Select", () => blueprint.Select());
AddStep("Deselect", () => blueprint.Deselect());
}
protected override bool OnClick(ClickEvent e)
{
blueprint.Deselect();
return true;
Add(blueprint.With(d =>
{
d.Depth = float.MinValue;
d.Select();
}));
}
protected abstract SelectionBlueprint CreateBlueprint();