<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 System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Multi;
using osuTK;

namespace osu.Game.Tests.Visual.Multiplayer
{
    public class TestSceneDrawableRoomPlaylist : OsuTestScene
    {
        public override IReadOnlyList<Type> RequiredTypes => new[]
        {
            typeof(DrawableRoomPlaylist),
            typeof(DrawableRoomPlaylistItem)
        };

        [Resolved]
        private BeatmapManager beatmapManager { get; set; }

        [Resolved]
        private RulesetStore rulesetStore { get; set; }

        private DrawableRoomPlaylist playlist;

        [Test]
        public void TestNonEditableNonSelectable()
        {
            createPlaylist(false, false);
        }

        [Test]
        public void TestEditable()
        {
            createPlaylist(true, false);
        }

        [Test]
        public void TestSelectable()
        {
            createPlaylist(false, true);
        }

        [Test]
        public void TestEditableSelectable()
        {
            createPlaylist(true, true);
        }

        private void createPlaylist(bool allowEdit, bool allowSelection) => AddStep("create playlist", () =>
        {
            Child = playlist = new DrawableRoomPlaylist(allowEdit, allowSelection)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(500, 300)
            };

            var beatmapSets = beatmapManager.GetAllUsableBeatmapSets();
            var rulesets = rulesetStore.AvailableRulesets.ToList();

            for (int i = 0; i < 20; i++)
            {
                var set = beatmapSets[RNG.Next(0, beatmapSets.Count)];
                var beatmap = set.Beatmaps[RNG.Next(0, set.Beatmaps.Count)];

                beatmap.BeatmapSet = set;
                beatmap.Metadata = set.Metadata;

                playlist.Items.Add(new PlaylistItem
                {
                    Beatmap = { Value = beatmap },
                    Ruleset = { Value = rulesets[RNG.Next(0, rulesets.Count)] },<commit_msg>Make test playlist items unique<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.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Multi;
using osuTK;

namespace osu.Game.Tests.Visual.Multiplayer
{
    public class TestSceneDrawableRoomPlaylist : OsuTestScene
    {
        public override IReadOnlyList<Type> RequiredTypes => new[]
        {
            typeof(DrawableRoomPlaylist),
            typeof(DrawableRoomPlaylistItem)
        };

        [Resolved]
        private BeatmapManager beatmapManager { get; set; }

        [Resolved]
        private RulesetStore rulesetStore { get; set; }

        private DrawableRoomPlaylist playlist;

        [Test]
        public void TestNonEditableNonSelectable()
        {
            createPlaylist(false, false);
        }

        [Test]
        public void TestEditable()
        {
            createPlaylist(true, false);
        }

        [Test]
        public void TestSelectable()
        {
            createPlaylist(false, true);
        }

        [Test]
        public void TestEditableSelectable()
        {
            createPlaylist(true, true);
        }

        private void createPlaylist(bool allowEdit, bool allowSelection) => AddStep("create playlist", () =>
        {
            Child = playlist = new DrawableRoomPlaylist(allowEdit, allowSelection)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(500, 300)
            };

            var beatmapSets = beatmapManager.GetAllUsableBeatmapSets();
            var rulesets = rulesetStore.AvailableRulesets.ToList();

            for (int i = 0; i < 20; i++)
            {
                var set = beatmapSets[RNG.Next(0, beatmapSets.Count)];
                var beatmap = set.Beatmaps[RNG.Next(0, set.Beatmaps.Count)];

                beatmap.BeatmapSet = set;
                beatmap.Metadata = set.Metadata;

                playlist.Items.Add(new PlaylistItem
                {
                    ID = i,
                    Beatmap = { Value = beatmap },
                    Ruleset = { Value = rulesets[RNG.Next(0, rulesets.Count)] },
{'fraction_non_alphanumeric': 0.0912, 'fraction_numerical': 0.0052, 'mean_word_length': 1.9732461355529132, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6987641', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1375, 'n_words': 320}