2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
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;
|
2018-06-11 19:08:17 +08:00
|
|
|
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;
|
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 TestCaseWaveform : OsuTestCase
|
|
|
|
{
|
2019-04-22 12:58:05 +08:00
|
|
|
private WorkingBeatmap waveformBeatmap;
|
|
|
|
|
2018-05-23 16:37:39 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-04-22 12:58:05 +08:00
|
|
|
waveformBeatmap = new WaveformTestBeatmap();
|
|
|
|
}
|
2018-06-13 14:09:03 +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 = new DummyWorkingBeatmap().Waveform,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|