mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Add debounce testing
This commit is contained in:
parent
43a1df6e5c
commit
3af7d4939c
@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
public class TestCaseSongProgress : OsuTestCase
|
public class TestCaseSongProgress : OsuTestCase
|
||||||
{
|
{
|
||||||
private readonly SongProgress progress;
|
private readonly SongProgress progress;
|
||||||
private readonly SongProgressGraph graph;
|
private readonly TestSongProgressGraph graph;
|
||||||
|
|
||||||
private readonly StopwatchClock clock;
|
private readonly StopwatchClock clock;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(graph = new SongProgressGraph
|
Add(graph = new TestSongProgressGraph
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 200,
|
Height = 200,
|
||||||
@ -39,13 +39,24 @@ namespace osu.Game.Tests.Visual
|
|||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddWaitStep(5);
|
||||||
|
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
||||||
|
|
||||||
|
AddStep("display values", displayNewValues);
|
||||||
|
AddWaitStep(5);
|
||||||
|
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep(5);
|
AddWaitStep(5);
|
||||||
|
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep(2);
|
AddWaitStep(5);
|
||||||
|
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
||||||
AddRepeatStep("New Values", displayNewValues, 5);
|
AddRepeatStep("New Values", displayNewValues, 5);
|
||||||
|
|
||||||
displayNewValues();
|
AddWaitStep(5);
|
||||||
|
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayNewValues()
|
private void displayNewValues()
|
||||||
@ -60,5 +71,18 @@ namespace osu.Game.Tests.Visual
|
|||||||
progress.AudioClock = clock;
|
progress.AudioClock = clock;
|
||||||
progress.OnSeek = pos => clock.Seek(pos);
|
progress.OnSeek = pos => clock.Seek(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class TestSongProgressGraph : SongProgressGraph
|
||||||
|
{
|
||||||
|
public int CreationCount { get; private set; }
|
||||||
|
|
||||||
|
protected override void RecreateGraph()
|
||||||
|
{
|
||||||
|
base.RecreateGraph();
|
||||||
|
CreationCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Cached layout = new Cached();
|
private Cached layout = new Cached();
|
||||||
|
private ScheduledDelegate scheduledCreate;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
@ -80,27 +81,21 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (values != null && !layout.IsValid)
|
if (values != null && !layout.IsValid)
|
||||||
{
|
{
|
||||||
schedulerRecreateGraph();
|
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
||||||
|
|
||||||
|
scheduledCreate?.Cancel();
|
||||||
|
scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500);
|
||||||
|
|
||||||
layout.Validate();
|
layout.Validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate scheduledCreate;
|
private CancellationTokenSource cts;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recreates the entire graph.
|
/// Recreates the entire graph.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void schedulerRecreateGraph()
|
protected virtual void RecreateGraph()
|
||||||
{
|
|
||||||
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
|
||||||
|
|
||||||
scheduledCreate?.Cancel();
|
|
||||||
scheduledCreate = Scheduler.AddDelayed(recreateGraph, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CancellationTokenSource cts;
|
|
||||||
|
|
||||||
private void recreateGraph()
|
|
||||||
{
|
{
|
||||||
var newColumns = new BufferedContainer<Column>
|
var newColumns = new BufferedContainer<Column>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user