2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
2020-10-09 10:02:53 +00:00
|
|
|
using System.Threading;
|
2018-04-13 09:19:50 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2019-05-31 05:40:53 +00:00
|
|
|
using osu.Framework.Audio;
|
2019-04-22 04:58:05 +00:00
|
|
|
using osu.Framework.Audio.Track;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics;
|
2018-06-11 11:08:17 +00:00
|
|
|
using osu.Framework.Graphics.Audio;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-04-22 04:58:05 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-05-31 05:51:12 +00:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2019-03-24 16:02:36 +00:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-04-23 08:07:55 +00:00
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
public class TestSceneWaveform : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-04-22 04:58:05 +00:00
|
|
|
private WorkingBeatmap waveformBeatmap;
|
|
|
|
|
2018-05-23 08:37:39 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2019-06-04 02:04:28 +00:00
|
|
|
private void load(AudioManager audio)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-05-31 05:40:53 +00:00
|
|
|
waveformBeatmap = new WaveformTestBeatmap(audio);
|
2019-04-22 04:58:05 +00:00
|
|
|
}
|
2018-06-13 06:09:03 +00:00
|
|
|
|
2019-04-22 04:58:05 +00: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 09:19:50 +00:00
|
|
|
|
2019-04-22 04:58:05 +00:00
|
|
|
AddStep("add graph", () =>
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-04-22 04:58:05 +00:00
|
|
|
Child = new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 100,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-04-22 04:58:05 +00:00
|
|
|
graph = new TestWaveformGraph
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Resolution = resolution,
|
|
|
|
Waveform = waveformBeatmap.Waveform,
|
|
|
|
},
|
2018-04-13 09:19:50 +00: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 04:58:05 +00:00
|
|
|
Text = $"Resolution: {resolution:0.00}"
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-22 04:58:05 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-10-09 10:02:53 +00:00
|
|
|
AddUntilStep("wait for load", () => graph.Loaded.IsSet);
|
2019-04-22 04:58:05 +00: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,
|
2019-05-31 05:51:12 +00:00
|
|
|
Waveform = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).Waveform,
|
2019-04-22 04:58:05 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-10-09 10:02:53 +00:00
|
|
|
AddUntilStep("wait for load", () => graph.Loaded.IsSet);
|
2019-04-22 04:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class TestWaveformGraph : WaveformGraph
|
|
|
|
{
|
2020-10-09 10:02:53 +00:00
|
|
|
public readonly ManualResetEventSlim Loaded = new ManualResetEventSlim();
|
|
|
|
|
|
|
|
protected override void OnWaveformRegenerated(Waveform waveform)
|
|
|
|
{
|
|
|
|
base.OnWaveformRegenerated(waveform);
|
|
|
|
Loaded.Set();
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|