1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 20:47:26 +08:00
osu-lazer/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

144 lines
4.9 KiB
C#
Raw Normal View History

2019-10-09 15:06:16 +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
using System;
using System.Linq;
2019-10-09 15:06:16 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Rulesets.Edit;
2020-01-02 00:23:21 +08:00
using osu.Game.Screens.Edit;
2019-10-09 15:06:16 +08:00
using osu.Game.Screens.Edit.Timing;
using osu.Game.Screens.Edit.Timing.RowAttributes;
using osuTK.Input;
2019-10-09 15:06:16 +08:00
namespace osu.Game.Tests.Visual.Editing
2019-10-09 15:06:16 +08:00
{
[TestFixture]
public partial class TestSceneTimingScreen : EditorClockTestScene
{
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private TimingScreen timingScreen;
private EditorBeatmap editorBeatmap;
protected override bool ScrollUsingMouseWheel => false;
protected override void LoadComplete()
2019-10-09 15:06:16 +08:00
{
base.LoadComplete();
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
Beatmap.Disabled = true;
}
private void reloadEditorBeatmap()
{
editorBeatmap = new EditorBeatmap(Beatmap.Value.GetPlayableBeatmap(Ruleset.Value));
Child = new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[]
{
(typeof(EditorBeatmap), editorBeatmap),
(typeof(IBeatSnapProvider), editorBeatmap)
},
Child = timingScreen = new TimingScreen
{
State = { Value = Visibility.Visible },
},
};
2019-10-09 15:06:16 +08:00
}
[SetUpSteps]
public void SetUpSteps()
{
AddStep("Stop clock", () => EditorClock.Stop());
AddStep("Reload Editor Beatmap", reloadEditorBeatmap);
AddUntilStep("Wait for rows to load", () => Child.ChildrenOfType<EffectRowAttribute>().Any());
}
[Test]
public void TestTrackingCurrentTimeWhileRunning()
{
AddStep("Select first effect point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<EffectRowAttribute>().First());
InputManager.Click(MouseButton.Left);
});
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
AddStep("Seek to just before next point", () => EditorClock.Seek(69000));
AddStep("Start clock", () => EditorClock.Start());
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
}
[Test]
public void TestTrackingCurrentTimeWhilePaused()
{
AddStep("Select first effect point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<EffectRowAttribute>().First());
InputManager.Click(MouseButton.Left);
});
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
AddStep("Seek to later", () => EditorClock.Seek(80000));
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
}
[Test]
public void TestScrollControlGroupIntoView()
{
AddStep("Add many control points", () =>
{
editorBeatmap.ControlPointInfo.Clear();
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint());
for (int i = 0; i < 100; i++)
{
editorBeatmap.ControlPointInfo.Add((i + 1) * 1000, new EffectControlPoint
{
KiaiMode = Convert.ToBoolean(i % 2),
});
}
});
AddStep("Select first effect point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<EffectRowAttribute>().First());
InputManager.Click(MouseButton.Left);
});
AddStep("Seek to beginning", () => EditorClock.Seek(0));
AddStep("Seek to last point", () => EditorClock.Seek(101 * 1000));
AddUntilStep("Scrolled to end", () => timingScreen.ChildrenOfType<OsuScrollContainer>().First().IsScrolledToEnd());
}
protected override void Dispose(bool isDisposing)
{
Beatmap.Disabled = false;
base.Dispose(isDisposing);
}
2019-10-09 15:06:16 +08:00
}
}