mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Add selection mask test cases
This commit is contained in:
parent
ea3c960b5b
commit
ce9b400c4c
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestCaseHitCircleSelectionMask : HitObjectSelectionMaskTestCase
|
||||||
|
{
|
||||||
|
private readonly DrawableHitCircle drawableObject;
|
||||||
|
|
||||||
|
public TestCaseHitCircleSelectionMask()
|
||||||
|
{
|
||||||
|
var hitCircle = new HitCircle { Position = new Vector2(256, 192) };
|
||||||
|
hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||||
|
|
||||||
|
Add(drawableObject = new DrawableHitCircle(hitCircle));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override SelectionMask CreateMask() => new HitCircleSelectionMask(drawableObject);
|
||||||
|
}
|
||||||
|
}
|
42
osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs
Normal file
42
osu.Game.Rulesets.Osu.Tests/TestCaseSliderSelectionMask.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestCaseSliderSelectionMask : HitObjectSelectionMaskTestCase
|
||||||
|
{
|
||||||
|
private readonly DrawableSlider drawableObject;
|
||||||
|
|
||||||
|
public TestCaseSliderSelectionMask()
|
||||||
|
{
|
||||||
|
var slider = new Slider
|
||||||
|
{
|
||||||
|
Position = new Vector2(256, 192),
|
||||||
|
ControlPoints = new[]
|
||||||
|
{
|
||||||
|
Vector2.Zero,
|
||||||
|
new Vector2(150, 150),
|
||||||
|
new Vector2(300, 0)
|
||||||
|
},
|
||||||
|
CurveType = CurveType.Bezier,
|
||||||
|
Distance = 350
|
||||||
|
};
|
||||||
|
|
||||||
|
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||||
|
|
||||||
|
Add(drawableObject = new DrawableSlider(slider));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override SelectionMask CreateMask() => new SliderSelectionMask(drawableObject);
|
||||||
|
}
|
||||||
|
}
|
47
osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs
Normal file
47
osu.Game/Tests/Visual/HitObjectSelectionMaskTestCase.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public abstract class HitObjectSelectionMaskTestCase : OsuTestCase
|
||||||
|
{
|
||||||
|
private SelectionMask mask;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => content ?? base.Content;
|
||||||
|
private readonly Container content;
|
||||||
|
|
||||||
|
protected HitObjectSelectionMaskTestCase()
|
||||||
|
{
|
||||||
|
base.Content.Add(content = new Container
|
||||||
|
{
|
||||||
|
Clock = new FramedClock(new StopwatchClock()),
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
base.Content.Add(mask = CreateMask());
|
||||||
|
mask.SelectionRequested += (_, __) => mask.Select();
|
||||||
|
|
||||||
|
AddStep("Select", () => mask.Select());
|
||||||
|
AddStep("Deselect", () => mask.Deselect());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
mask.Deselect();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract SelectionMask CreateMask();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user