Exemple #1
0
        public void TestSlidingSampleStopsOnSeek()
        {
            DrawableSlider slider = null;

            PoolableSkinnableSample[] loopingSamples = null;
            PoolableSkinnableSample[] onceOffSamples = null;

            AddStep("get first slider", () =>
            {
                slider         = Editor.ChildrenOfType <DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
                onceOffSamples = slider.ChildrenOfType <PoolableSkinnableSample>().Where(s => !s.Looping).ToArray();
                loopingSamples = slider.ChildrenOfType <PoolableSkinnableSample>().Where(s => s.Looping).ToArray();
            });

            AddStep("start playback", () => EditorClock.Start());

            AddUntilStep("wait for slider sliding then seek", () =>
            {
                if (!slider.Tracking.Value)
                {
                    return(false);
                }

                if (!loopingSamples.Any(s => s.Playing))
                {
                    return(false);
                }

                EditorClock.Seek(20000);
                return(true);
            });

            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));
        }
        public void TestSlidingSampleStopsOnSeek()
        {
            DrawableSlider slider = null;

            DrawableSample[] samples = null;

            AddStep("get first slider", () =>
            {
                slider  = Editor.ChildrenOfType <DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
                samples = slider.ChildrenOfType <DrawableSample>().ToArray();
            });

            AddStep("start playback", () => EditorClock.Start());

            AddUntilStep("wait for slider sliding then seek", () =>
            {
                if (!slider.Tracking.Value)
                {
                    return(false);
                }

                if (!samples.Any(s => s.Playing))
                {
                    return(false);
                }

                EditorClock.Seek(20000);
                return(true);
            });

            AddAssert("slider samples are not playing", () => samples.Length == 5 && samples.All(s => s.Played && !s.Playing));
        }
        public void TestAllSamplesStopDuringSeek()
        {
            DrawableSlider slider = null;

            PoolableSkinnableSample[] samples        = null;
            ISamplePlaybackDisabler   sampleDisabler = null;

            AddUntilStep("get variables", () =>
            {
                sampleDisabler = Player;
                slider         = Player.ChildrenOfType <DrawableSlider>().MinBy(s => s.HitObject.StartTime);
                samples        = slider?.ChildrenOfType <PoolableSkinnableSample>().ToArray();

                return(slider != null);
            });

            AddUntilStep("wait for slider sliding then seek", () =>
            {
                if (!slider.Tracking.Value)
                {
                    return(false);
                }

                if (!samples.Any(s => s.Playing))
                {
                    return(false);
                }

                Player.ChildrenOfType <GameplayClockContainer>().First().Seek(40000);
                return(true);
            });

            AddAssert("sample playback disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);

            // because we are in frame stable context, it's quite likely that not all samples are "played" at this point.
            // the important thing is that at least one started, and that sample has since stopped.
            AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
            AddUntilStep("all samples stopped eventually", () => allStopped(allSounds));

            AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);

            AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
            AddUntilStep("any sample is playing", () => Player.ChildrenOfType <PausableSkinnableSound>().Any(s => s.IsPlaying));
        }