mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Refactor test to allow waveform testing
This commit is contained in:
@ -4,15 +4,15 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Timing;
|
using osu.Game.Screens.Edit.Timing;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -22,9 +22,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneTapTimingControl : EditorClockTestScene
|
public class TestSceneTapTimingControl : EditorClockTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(EditorBeatmap))]
|
private EditorBeatmap editorBeatmap => editorBeatmapContainer?.EditorBeatmap;
|
||||||
[Cached(typeof(IBeatSnapProvider))]
|
|
||||||
private readonly EditorBeatmap editorBeatmap;
|
private TestSceneHitObjectComposer.EditorBeatmapContainer editorBeatmapContainer;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||||
@ -33,26 +33,23 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
||||||
|
|
||||||
private TapTimingControl control;
|
private TapTimingControl control;
|
||||||
|
private OsuSpriteText timingInfo;
|
||||||
|
|
||||||
public TestSceneTapTimingControl()
|
[Resolved]
|
||||||
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
var playableBeatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
AddStep("create beatmap", () =>
|
||||||
|
|
||||||
// Ensure time doesn't end while testing
|
|
||||||
playableBeatmap.BeatmapInfo.Length = 1200000;
|
|
||||||
|
|
||||||
editorBeatmap = new EditorBeatmap(playableBeatmap);
|
|
||||||
|
|
||||||
selectedGroup.Value = editorBeatmap.ControlPointInfo.Groups.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||||
|
});
|
||||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
|
||||||
Beatmap.Disabled = true;
|
|
||||||
|
|
||||||
|
AddStep("Create component", () =>
|
||||||
|
{
|
||||||
|
Child = editorBeatmapContainer = new TestSceneHitObjectComposer.EditorBeatmapContainer(Beatmap.Value)
|
||||||
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
@ -63,8 +60,21 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
Width = 400,
|
Width = 400,
|
||||||
Scale = new Vector2(1.5f),
|
Scale = new Vector2(1.5f),
|
||||||
Child = control = new TapTimingControl(),
|
Child = control = new TapTimingControl(),
|
||||||
|
},
|
||||||
|
timingInfo = new OsuSpriteText(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
selectedGroup.Value = editorBeatmap.ControlPointInfo.Groups.First();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (selectedGroup.Value != null)
|
||||||
|
timingInfo.Text = $"offset: {selectedGroup.Value.Time:N2} bpm: {selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().First().BPM:N2}";
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -104,7 +114,13 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddSliderStep("BPM", 30, 400, 60, bpm => editorBeatmap.ControlPointInfo.TimingPoints.First().BeatLength = 60000f / bpm);
|
AddSliderStep("BPM", 30, 400, 128, bpm =>
|
||||||
|
{
|
||||||
|
if (editorBeatmap == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
editorBeatmap.ControlPointInfo.TimingPoints.First().BeatLength = 60000f / bpm;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
Reference in New Issue
Block a user