<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Tests.Visual.Clocks;

namespace osu.Framework.Tests.Visual.Platform
{
    public class TestSceneTrackBass : FrameworkTestScene
    {
        private TrackBass track;

        [BackgroundDependencyLoader]
        private void load(Game game, AudioManager audio)
        {
            var stream = game.Resources.GetStream("Tracks/sample-track.mp3");
            track = new TrackBass(stream);
            audio.Track.AddItem(track);

            Child = new TestSceneClock.VisualClock(track)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                RelativePositionAxes = Axes.Both,
            };
        }

        [SetUpSteps]
        public void SetUpSteps()
        {
            AddStep("Seek to 1 second", () => track.Seek(1000));
        }

        /// <summary>
        /// Bass does not allow seeking to the end of the track. It should fail and the current time should not change.
        /// </summary>
        [Test]
        public void TestTrackSeekingToEndFails()
        {
            AddStep("Attempt to seek to the end of the track", () => track.Seek(track.Length));
            AddAssert("Track did not seek", () => track.CurrentTime == 1000);
        }

        /// <summary>
        /// Bass restarts the track from the beginning if Start is called when the track has been completed.
        /// This is blocked locally in <see cref="TrackBass"/>, so this test expects the track to not restart.
        /// </summary>
        [Test]
        public void TestTrackPlaybackBlocksAtTrackEnd()
        {
            AddStep("Seek to right before end of track", () => track.Seek(track.Length - 1));
            AddStep("Play", () => track.Start());
            AddUntilStep("Track stopped playing", () => !track.IsRunning);
            AddStep("Start track again", () => track.Start());
            AddAssert("Track did not restart", () => track.CurrentTime == track.Length);
        }
    }
}<commit_msg>Add additional assert<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Tests.Visual.Clocks;

namespace osu.Framework.Tests.Visual.Platform
{
    public class TestSceneTrackBass : FrameworkTestScene
    {
        private TrackBass track;

        [BackgroundDependencyLoader]
        private void load(Game game, AudioManager audio)
        {
            var stream = game.Resources.GetStream("Tracks/sample-track.mp3");
            track = new TrackBass(stream);
            audio.Track.AddItem(track);

            Child = new TestSceneClock.VisualClock(track)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                RelativePositionAxes = Axes.Both,
            };
        }

        [SetUpSteps]
        public void SetUpSteps()
        {
            AddStep("Seek to 1 second", () => track.Seek(1000));
            AddAssert("Initial seek was successful", () => track.CurrentTime == 1000);
        }

        /// <summary>
        /// Bass does not allow seeking to the end of the track. It should fail and the current time should not change.
        /// </summary>
        [Test]
        public void TestTrackSeekingToEndFails()
        {
            AddStep("Attempt to seek to the end of the track", () => track.Seek(track.Length));
            AddAssert("Track did not seek", () => track.CurrentTime == 1000);
        }

        /// <summary>
        /// Bass restarts the track from the beginning if Start is called when the track has been completed.
        /// This is blocked locally in <see cref="TrackBass"/>, so this test expects the track to not restart.
        /// </summary>
        [Test]
        public void TestTrackPlaybackBlocksAtTrackEnd()
        {
            AddStep("Seek to right before end of track", () => track.Seek(track.Length - 1));
            AddStep("Play", () => track.Start());
            AddUntilStep("Track stopped playing", () => !track.IsRunning);
            AddStep("Start track again", () => track.Start());
            AddAssert("Track did not restart", () => track.CurrentTime == track.Length);
        }
    }
}
{'fraction_non_alphanumeric': 0.11200168740771989, 'fraction_numerical': 0.005484075089643535, 'mean_word_length': 2.1592271818787476, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '528548', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1244, 'n_words': 380}