1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 04:47:38 +08:00
osu-lazer/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs

110 lines
3.5 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
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
2019-04-22 12:58:05 +08:00
using osu.Framework.Audio.Track;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2019-04-22 12:58:05 +08:00
using osu.Game.Beatmaps;
2018-04-13 17:19:50 +08:00
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
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Editor
2018-04-13 17:19:50 +08:00
{
[TestFixture]
public class TestSceneWaveform : OsuTestScene
2018-04-13 17:19:50 +08:00
{
2019-04-22 12:58:05 +08:00
private WorkingBeatmap waveformBeatmap;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
2018-04-13 17:19:50 +08:00
{
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", () =>
2018-04-13 17:19:50 +08:00
{
2019-04-22 12:58:05 +08:00
Child = new Container
2018-04-13 17:19:50 +08:00
{
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,
},
2018-04-13 17:19:50 +08:00
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}"
2018-04-13 17:19:50 +08:00
}
}
}
}
2019-04-22 12:58:05 +08:00
};
});
AddUntilStep("wait for load", () => graph.ResampledWaveform != null);
}
[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
},
};
});
AddUntilStep("wait for load", () => graph.ResampledWaveform != null);
}
public class TestWaveformGraph : WaveformGraph
{
public new Waveform ResampledWaveform => base.ResampledWaveform;
2018-04-13 17:19:50 +08:00
}
}
}