2021-01-22 04:14:24 +08:00
|
|
|
|
using System.Linq;
|
2021-01-22 00:54:26 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-01-22 04:14:24 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2021-01-22 05:07:08 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2021-01-22 00:54:26 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
|
|
|
|
using osuTK;
|
2021-01-22 04:14:24 +08:00
|
|
|
|
using osuTK.Input;
|
|
|
|
|
using static osu.Game.Screens.Edit.Compose.Components.Timeline.TimelineHitObjectBlueprint;
|
2021-01-22 00:54:26 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
|
|
|
{
|
|
|
|
|
public class TestSceneTimelineHitObjectBlueprint : TimelineTestScene
|
|
|
|
|
{
|
2021-01-22 05:07:08 +08:00
|
|
|
|
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer(Composer);
|
2021-01-22 00:54:26 +08:00
|
|
|
|
|
2021-01-22 05:07:08 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDisallowZeroDurationObjects()
|
2021-01-22 00:54:26 +08:00
|
|
|
|
{
|
2021-01-22 05:07:08 +08:00
|
|
|
|
DragBar dragBar;
|
2021-01-22 00:54:26 +08:00
|
|
|
|
|
2021-01-22 05:07:08 +08:00
|
|
|
|
AddStep("add spinner", () =>
|
|
|
|
|
{
|
|
|
|
|
EditorBeatmap.Clear();
|
|
|
|
|
EditorBeatmap.Add(new Spinner
|
|
|
|
|
{
|
|
|
|
|
Position = new Vector2(256, 256),
|
|
|
|
|
StartTime = 150,
|
|
|
|
|
Duration = 500
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-01-22 00:54:26 +08:00
|
|
|
|
|
2021-01-22 05:07:08 +08:00
|
|
|
|
AddStep("hold down drag bar", () =>
|
2021-01-22 04:14:24 +08:00
|
|
|
|
{
|
2021-01-22 05:07:08 +08:00
|
|
|
|
// distinguishes between the actual drag bar and its "underlay shadow".
|
|
|
|
|
dragBar = this.ChildrenOfType<DragBar>().Single(bar => bar.HandlePositionalInput);
|
|
|
|
|
InputManager.MoveMouseTo(dragBar);
|
2021-01-22 04:14:24 +08:00
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
2021-01-22 05:07:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("try to drag bar past start", () =>
|
|
|
|
|
{
|
|
|
|
|
var blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
|
|
|
|
|
InputManager.MoveMouseTo(blueprint.SelectionQuad.TopLeft - new Vector2(100, 0));
|
2021-01-22 04:14:24 +08:00
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
|
});
|
2021-01-22 05:07:08 +08:00
|
|
|
|
|
|
|
|
|
AddAssert("object has non-zero duration", () => EditorBeatmap.HitObjects.OfType<IHasDuration>().Single().Duration > 0);
|
2021-01-22 00:54:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|