2022-05-28 22:45:00 +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 NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
|
|
|
{
|
|
|
|
|
public partial class TestSceneTimelineZoom : TimelineTestScene
|
|
|
|
|
{
|
|
|
|
|
public override Drawable CreateTestComponent() => Empty();
|
|
|
|
|
|
|
|
|
|
[Test]
|
2022-06-03 07:22:16 +08:00
|
|
|
|
public void TestVisibleRangeUpdatesOnZoomChange()
|
2022-05-28 22:45:00 +08:00
|
|
|
|
{
|
|
|
|
|
double initialVisibleRange = 0;
|
|
|
|
|
|
|
|
|
|
AddStep("reset zoom", () => TimelineArea.Timeline.Zoom = 100);
|
|
|
|
|
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
|
|
|
|
|
|
|
|
|
AddStep("scale zoom", () => TimelineArea.Timeline.Zoom = 200);
|
2022-07-22 15:05:20 +08:00
|
|
|
|
AddStep("range halved", () => Assert.That(TimelineArea.Timeline.VisibleRange, Is.EqualTo(initialVisibleRange / 2).Within(1)));
|
2022-05-28 22:45:00 +08:00
|
|
|
|
AddStep("descale zoom", () => TimelineArea.Timeline.Zoom = 50);
|
2022-07-22 15:05:20 +08:00
|
|
|
|
AddStep("range doubled", () => Assert.That(TimelineArea.Timeline.VisibleRange, Is.EqualTo(initialVisibleRange * 2).Within(1)));
|
2022-05-28 22:45:00 +08:00
|
|
|
|
|
|
|
|
|
AddStep("restore zoom", () => TimelineArea.Timeline.Zoom = 100);
|
2022-07-22 15:05:20 +08:00
|
|
|
|
AddStep("range restored", () => Assert.That(TimelineArea.Timeline.VisibleRange, Is.EqualTo(initialVisibleRange).Within(1)));
|
2022-05-28 22:45:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2022-06-03 07:22:16 +08:00
|
|
|
|
public void TestVisibleRangeConstantOnSizeChange()
|
2022-05-28 22:45:00 +08:00
|
|
|
|
{
|
|
|
|
|
double initialVisibleRange = 0;
|
|
|
|
|
|
|
|
|
|
AddStep("reset timeline size", () => TimelineArea.Timeline.Width = 1);
|
|
|
|
|
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
|
|
|
|
|
|
|
|
|
AddStep("scale timeline size", () => TimelineArea.Timeline.Width = 2);
|
2022-06-03 07:22:16 +08:00
|
|
|
|
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange);
|
2022-05-28 22:45:00 +08:00
|
|
|
|
AddStep("descale timeline size", () => TimelineArea.Timeline.Width = 0.5f);
|
2022-06-03 07:22:16 +08:00
|
|
|
|
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange);
|
2022-05-28 22:45:00 +08:00
|
|
|
|
|
|
|
|
|
AddStep("restore timeline size", () => TimelineArea.Timeline.Width = 1);
|
2022-06-03 07:22:16 +08:00
|
|
|
|
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange);
|
2022-05-28 22:45:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|