<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 System;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Music;
using osuTK;

namespace osu.Game.Tests.Visual.UserInterface
{
    public class TestScenePlaylistOverlay : OsuTestScene
    {
        private readonly BindableList<BeatmapSetInfo> beatmapSets = new BindableList<BeatmapSetInfo>();

        [SetUp]
        public void Setup() => Schedule(() =>
        {
            PlaylistOverlay overlay;

            Child = new Container
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(300, 500),
                Child = overlay = new PlaylistOverlay
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    RelativeSizeAxes = Axes.X,
                    State = { Value = Visibility.Visible }
                }
            };

            beatmapSets.Clear();

            for (int i = 0; i < 100; i++)
            {
                beatmapSets.Add(new BeatmapSetInfo
                {
                    Metadata = new BeatmapMetadata
                    {
                        // Create random metadata, then we can check if sorting works based on these
                        Artist = "Some Artist " + RNG.Next(0, 9),
                        Title = $"Some Song {i + 1}",
                        AuthorString = "<NAME> " + RNG.Next(0, 9),
                    },
                    DateAdded = DateTimeOffset.UtcNow,
                });
            }

            overlay.BeatmapSets.BindTo(beatmapSets);
        });
    }
}<commit_msg>Add regression test coverage<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 System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Music;
using osuTK;
using osuTK.Input;

namespace osu.Game.Tests.Visual.UserInterface
{
    public class TestScenePlaylistOverlay : OsuManualInputManagerTestScene
    {
        private readonly BindableList<BeatmapSetInfo> beatmapSets = new BindableList<BeatmapSetInfo>();

        private PlaylistOverlay playlistOverlay;

        [SetUp]
        public void Setup() => Schedule(() =>
        {
            Child = new Container
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(300, 500),
                Child = playlistOverlay = new PlaylistOverlay
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    RelativeSizeAxes = Axes.X,
                    State = { Value = Visibility.Visible }
                }
            };

            beatmapSets.Clear();

            for (int i = 0; i < 100; i++)
            {
                beatmapSets.Add(new BeatmapSetInfo
                {
                    Metadata = new BeatmapMetadata
                    {
                        // Create random metadata, then we can check if sorting works based on these
                        Artist = "Some Artist " + RNG.Next(0, 9),
                        Title = $"Some Song {i + 1}",
                        AuthorString = "<NAME> " + RNG.Next(0, 9),
                    },
                    DateAdded = DateTimeOffset.UtcNow,
                });
            }

            playlistOverlay.BeatmapSets.BindTo(beatmapSets);
        });

        [Test]
        public void TestRearrangeItems()
        {
            AddUntilStep("wait for animations to complete", () => !playlistOverlay.Transforms.Any());

            AddStep("hold 1st item handle", () =>
            {
                var handle = this.ChildrenOfType<PlaylistItem.PlaylistItemHandle>().First();
                InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre);
                InputManager.PressButton(MouseButton.Left);
            });

            AddStep("drag to 5th", () =>
            {
                var item = this.ChildrenOfType<PlaylistItem>().ElementAt(4);
                InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.Centre);
            });

            AddAssert("song 1 is 5th", () => beatmapSets[4].Metadata.Title == "Some Song 1");

            AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
        }

        [Test]
        public void TestFiltering()
        {
            AddStep("set filter to \"10\"", () =>
            {
                var filterControl = playlistOverlay.ChildrenOfType<FilterControl>().Single();
                filterControl.Search.Current.Value = "10";
            });

            AddAssert("results filtered correctly",
                () => playlistOverlay.ChildrenOfType<PlaylistItem>()
                                     .Where(item => item.MatchingFilter)
                                     .All(item => item.FilterTerms.Any(term => term.Contains("10"))));
        }
    }
}
{'fraction_non_alphanumeric': 0.09827649431609828, 'fraction_numerical': 0.00825082508250825, 'mean_word_length': 1.5634398496240602, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, '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': '5043371', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1382, 'n_words': 325}