Add debounce testing

This commit is contained in:
Dean Herbert
2019-02-27 19:11:09 +09:00
parent 43a1df6e5c
commit 3af7d4939c
2 changed files with 36 additions and 17 deletions

View File

@ -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++;
}
}
}
}