1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 08:52:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Editing/TestSceneTimelineHitObjectBlueprint.cs

56 lines
2.0 KiB
C#
Raw Normal View History

2021-01-22 05:09:42 +08: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-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
{
DragArea dragArea;
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 = 2700,
2021-01-22 05:07:08 +08:00
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".
dragArea = this.ChildrenOfType<DragArea>().Single(bar => bar.HandlePositionalInput);
InputManager.MoveMouseTo(dragArea);
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
}
}
}