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