2020-09-29 06:29:56 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-09-29 06:29:56 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2021-01-19 08:11:40 +00:00
|
|
|
using osu.Game.Skinning;
|
2020-09-29 06:29:56 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
|
|
{
|
|
|
|
public partial class TestSceneEditorSamplePlayback : EditorTestScene
|
|
|
|
{
|
|
|
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSlidingSampleStopsOnSeek()
|
|
|
|
{
|
|
|
|
DrawableSlider slider = null;
|
2021-01-20 05:05:35 +00:00
|
|
|
PoolableSkinnableSample[] loopingSamples = null;
|
|
|
|
PoolableSkinnableSample[] onceOffSamples = null;
|
2020-09-29 06:29:56 +00:00
|
|
|
|
|
|
|
AddStep("get first slider", () =>
|
|
|
|
{
|
|
|
|
slider = Editor.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
2021-01-20 05:05:35 +00:00
|
|
|
onceOffSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => !s.Looping).ToArray();
|
|
|
|
loopingSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => s.Looping).ToArray();
|
2020-09-29 06:29:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("start playback", () => EditorClock.Start());
|
|
|
|
|
|
|
|
AddUntilStep("wait for slider sliding then seek", () =>
|
|
|
|
{
|
|
|
|
if (!slider.Tracking.Value)
|
|
|
|
return false;
|
|
|
|
|
2021-01-20 05:05:35 +00:00
|
|
|
if (!loopingSamples.Any(s => s.Playing))
|
2020-09-29 06:29:56 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
EditorClock.Seek(20000);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2021-01-20 05:05:35 +00:00
|
|
|
AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.Played || s.Playing));
|
|
|
|
AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.Played && !s.Playing));
|
2020-09-29 06:29:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|