1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 10:32:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Editing/TestSceneWaveform.cs

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

119 lines
3.8 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2020-10-09 18:02:53 +08:00
using System.Threading;
2018-03-02 14:34:31 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
2019-04-22 12:58:05 +08:00
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2019-04-22 12:58:05 +08:00
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu;
2019-03-25 00:02:36 +08:00
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Tests.Visual.Editing
{
2018-03-02 14:34:31 +08:00
[TestFixture]
public partial class TestSceneWaveform : OsuTestScene
{
private IWorkingBeatmap waveformBeatmap;
2019-04-22 12:58:05 +08:00
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
waveformBeatmap = new WaveformTestBeatmap(audio);
2019-04-22 12:58:05 +08:00
}
2019-04-22 12:58:05 +08:00
[TestCase(1f)]
[TestCase(1f / 2)]
[TestCase(1f / 4)]
[TestCase(1f / 8)]
[TestCase(1f / 16)]
[TestCase(0f)]
public void TestResolution(float resolution)
{
TestWaveformGraph graph = null;
2018-04-13 17:19:50 +08:00
2019-04-22 12:58:05 +08:00
AddStep("add graph", () =>
{
2019-04-22 12:58:05 +08:00
Child = new Container
{
RelativeSizeAxes = Axes.X,
Height = 100,
Children = new Drawable[]
{
2019-04-22 12:58:05 +08:00
graph = new TestWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Resolution = resolution,
Waveform = waveformBeatmap.Waveform,
},
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.75f
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2019-04-22 12:58:05 +08:00
Text = $"Resolution: {resolution:0.00}"
}
}
}
}
2019-04-22 12:58:05 +08:00
};
});
2020-10-09 18:02:53 +08:00
AddUntilStep("wait for load", () => graph.Loaded.IsSet);
2019-04-22 12:58:05 +08:00
}
[Test]
public void TestDefaultBeatmap()
{
TestWaveformGraph graph = null;
AddStep("add graph", () =>
{
Child = new Container
{
RelativeSizeAxes = Axes.X,
Height = 100,
Child = graph = new TestWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Waveform = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).Waveform,
2019-04-22 12:58:05 +08:00
},
};
});
2020-10-09 18:02:53 +08:00
AddUntilStep("wait for load", () => graph.Loaded.IsSet);
2019-04-22 12:58:05 +08:00
}
public partial class TestWaveformGraph : WaveformGraph
{
2020-10-09 18:02:53 +08:00
public readonly ManualResetEventSlim Loaded = new ManualResetEventSlim();
protected override void OnWaveformRegenerated(Waveform waveform)
{
base.OnWaveformRegenerated(waveform);
Loaded.Set();
}
}
}
}