mirror of
https://github.com/osukey/osukey.git
synced 2025-06-03 20:07:18 +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
|
||||
{
|
||||
private readonly SongProgress progress;
|
||||
private readonly SongProgressGraph graph;
|
||||
private readonly TestSongProgressGraph graph;
|
||||
|
||||
private readonly StopwatchClock clock;
|
||||
|
||||
@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual
|
||||
Origin = Anchor.BottomLeft,
|
||||
});
|
||||
|
||||
Add(graph = new SongProgressGraph
|
||||
Add(graph = new TestSongProgressGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 200,
|
||||
@ -39,13 +39,24 @@ namespace osu.Game.Tests.Visual
|
||||
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);
|
||||
AddWaitStep(5);
|
||||
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
||||
|
||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||
AddWaitStep(2);
|
||||
AddWaitStep(5);
|
||||
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
|
||||
AddRepeatStep("New Values", displayNewValues, 5);
|
||||
|
||||
displayNewValues();
|
||||
AddWaitStep(5);
|
||||
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
||||
}
|
||||
|
||||
private void displayNewValues()
|
||||
@ -60,5 +71,18 @@ namespace osu.Game.Tests.Visual
|
||||
progress.AudioClock = clock;
|
||||
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 ScheduledDelegate scheduledCreate;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
@ -80,27 +81,21 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
if (values != null && !layout.IsValid)
|
||||
{
|
||||
schedulerRecreateGraph();
|
||||
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
||||
|
||||
scheduledCreate?.Cancel();
|
||||
scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500);
|
||||
|
||||
layout.Validate();
|
||||
}
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledCreate;
|
||||
private CancellationTokenSource cts;
|
||||
|
||||
/// <summary>
|
||||
/// Recreates the entire graph.
|
||||
/// </summary>
|
||||
private void schedulerRecreateGraph()
|
||||
{
|
||||
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
||||
|
||||
scheduledCreate?.Cancel();
|
||||
scheduledCreate = Scheduler.AddDelayed(recreateGraph, 500);
|
||||
}
|
||||
|
||||
private CancellationTokenSource cts;
|
||||
|
||||
private void recreateGraph()
|
||||
protected virtual void RecreateGraph()
|
||||
{
|
||||
var newColumns = new BufferedContainer<Column>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user