1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

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

@ -39,6 +39,8 @@ namespace osu.Game.Rulesets.Mania.Tests
AccentColour = { Value = OsuColour.Gray(0.3f) }
}
};
AddBlueprint(new HoldNoteSelectionBlueprint(drawableObject));
}
protected override void Update()
@ -52,6 +54,6 @@ namespace osu.Game.Rulesets.Mania.Tests
}
}
protected override SelectionBlueprint CreateBlueprint() => new HoldNoteSelectionBlueprint(drawableObject);
protected override SelectionBlueprint CreateBlueprint() => new HoldNoteSelectionBlueprint(null);
}
}

View File

@ -17,8 +17,6 @@ namespace osu.Game.Rulesets.Mania.Tests
{
public class TestSceneNoteSelectionBlueprint : ManiaSelectionBlueprintTestScene
{
private readonly DrawableNote drawableObject;
protected override Container<Drawable> Content => content ?? base.Content;
private readonly Container content;
@ -27,6 +25,8 @@ namespace osu.Game.Rulesets.Mania.Tests
var note = new Note { Column = 0 };
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
DrawableNote drawableObject;
base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down)
{
Anchor = Anchor.Centre,
@ -34,8 +34,10 @@ namespace osu.Game.Rulesets.Mania.Tests
Size = new Vector2(50, 20),
Child = drawableObject = new DrawableNote(note)
};
AddBlueprint(new NoteSelectionBlueprint(drawableObject));
}
protected override SelectionBlueprint CreateBlueprint() => new NoteSelectionBlueprint(drawableObject);
protected override SelectionBlueprint CreateBlueprint() => new NoteSelectionBlueprint(null);
}
}

View File

@ -25,8 +25,6 @@ namespace osu.Game.Rulesets.Osu.Tests
typeof(SpinnerPiece)
};
private readonly DrawableSpinner drawableSpinner;
public TestSceneSpinnerSelectionBlueprint()
{
var spinner = new Spinner
@ -35,16 +33,21 @@ namespace osu.Game.Rulesets.Osu.Tests
StartTime = -1000,
EndTime = 2000
};
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
DrawableSpinner drawableSpinner;
Add(new Container
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
Child = drawableSpinner = new DrawableSpinner(spinner)
});
AddBlueprint(new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) });
}
protected override SelectionBlueprint CreateBlueprint() => new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) };
protected override SelectionBlueprint CreateBlueprint() => new SpinnerSelectionBlueprint(null) { Size = new Vector2(0.5f) };
}
}

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();