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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-01-22 05:09:42 +08:00
|
|
|
|
using System.Linq;
|
2021-01-22 00:54:26 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2022-05-29 20:22:23 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2021-01-22 04:14:24 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2022-05-29 20:22:23 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
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
|
|
|
|
|
2022-05-29 20:22:23 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestContextMenu()
|
|
|
|
|
{
|
2022-05-29 22:06:01 +08:00
|
|
|
|
TimelineHitObjectBlueprint blueprint;
|
2022-05-29 20:22:23 +08:00
|
|
|
|
|
|
|
|
|
AddStep("add object", () =>
|
|
|
|
|
{
|
|
|
|
|
EditorBeatmap.Clear();
|
|
|
|
|
EditorBeatmap.Add(new HitCircle { StartTime = 3000 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("click object", () =>
|
|
|
|
|
{
|
|
|
|
|
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
|
|
|
|
|
InputManager.MoveMouseTo(blueprint);
|
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
|
|
|
|
AddAssert("context menu open", () => this.ChildrenOfType<OsuContextMenu>().SingleOrDefault()?.State == MenuState.Open);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-22 05:07:08 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDisallowZeroDurationObjects()
|
2021-01-22 00:54:26 +08:00
|
|
|
|
{
|
2021-04-13 17:12:46 +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),
|
2021-04-13 16:39:12 +08:00
|
|
|
|
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".
|
2021-04-13 17:12:46 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|