mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 16:12:54 +08:00
Fix scheduled tasks not being cleaned up between test steps
This commit is contained in:
parent
d4054c87d3
commit
a26b0915b4
@ -1,8 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
@ -10,6 +13,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public class TestSceneShaking : TestSceneHitCircle
|
public class TestSceneShaking : TestSceneHitCircle
|
||||||
{
|
{
|
||||||
|
private readonly List<ScheduledDelegate> scheduledTasks = new List<ScheduledDelegate>();
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmapForSkinProvider()
|
||||||
|
{
|
||||||
|
// best way to run cleanup before a new step is run
|
||||||
|
foreach (var task in scheduledTasks)
|
||||||
|
task.Cancel();
|
||||||
|
|
||||||
|
scheduledTasks.Clear();
|
||||||
|
|
||||||
|
return base.CreateBeatmapForSkinProvider();
|
||||||
|
}
|
||||||
|
|
||||||
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto)
|
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto)
|
||||||
{
|
{
|
||||||
var drawableHitObject = base.CreateDrawableHitCircle(circle, auto);
|
var drawableHitObject = base.CreateDrawableHitCircle(circle, auto);
|
||||||
@ -17,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Debug.Assert(drawableHitObject.HitObject.HitWindows != null);
|
Debug.Assert(drawableHitObject.HitObject.HitWindows != null);
|
||||||
|
|
||||||
double delay = drawableHitObject.HitObject.StartTime - (drawableHitObject.HitObject.HitWindows.WindowFor(HitResult.Miss) + RNG.Next(0, 300)) - Time.Current;
|
double delay = drawableHitObject.HitObject.StartTime - (drawableHitObject.HitObject.HitWindows.WindowFor(HitResult.Miss) + RNG.Next(0, 300)) - Time.Current;
|
||||||
Scheduler.AddDelayed(() => drawableHitObject.TriggerJudgement(), delay);
|
scheduledTasks.Add(Scheduler.AddDelayed(() => drawableHitObject.TriggerJudgement(), delay));
|
||||||
|
|
||||||
return drawableHitObject;
|
return drawableHitObject;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user