<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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play;
using osuTK;

namespace osu.Game.Tests.Visual.SongSelect
{
    public class TestSceneBeatmapMetadataDisplay : OsuTestScene
    {
        private BeatmapMetadataDisplay display;

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

        [Test]
        public void TestLocal([Values("Beatmap", "Some long title and stuff")]
                              string title,
                              [Values("Trial", "Some1's very hardest difficulty")]
                              string version)
        {
            showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
            {
                BeatmapInfo =
                {
                    Metadata = new BeatmapMetadata
                    {
                        Title = title,
                    },
                    Version = version,
                    StarDifficulty = RNG.NextDouble(0, 10),
                }
            }));
        }

        [Test]
        public void TestRandomFromDatabase()
        {
            showMetadataForBeatmap(() =>
            {
                var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
                if (allBeatmapSets.Count == 0)
                    return manager.DefaultBeatmap;

                var randomBeatmapSet = allBeatmapSets[RNG.Next(0, allBeatmapSets.Count - 1)];
                var randomBeatmap = randomBeatmapSet.Beatmaps[RNG.Next(0, randomBeatmapSet.Beatmaps.Count - 1)];

                return manager.GetWorkingBeatmap(randomBeatmap);
            });
        }

        private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap)
        {
            AddStep("setup display", () =>
            {
                var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();

                Child = display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), Empty())
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Scale = new Vector2(1.5f),
                    Alpha = 0f,
                };

                display.FadeIn(400, Easing.OutQuint);
            });

            AddWaitStep("wait a bit", 5);

            AddStep("finish loading", () => display.Loading = false);
        }
    }
}<commit_msg>Add the osu! logo to the test scene<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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
using osuTK;

namespace osu.Game.Tests.Visual.SongSelect
{
    public class TestSceneBeatmapMetadataDisplay : OsuTestScene
    {
        private BeatmapMetadataDisplay display;

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

        [Test]
        public void TestLocal([Values("Beatmap", "Some long title and stuff")]
                              string title,
                              [Values("Trial", "Some1's very hardest difficulty")]
                              string version)
        {
            showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
            {
                BeatmapInfo =
                {
                    Metadata = new BeatmapMetadata
                    {
                        Title = title,
                    },
                    Version = version,
                    StarDifficulty = RNG.NextDouble(0, 10),
                }
            }));
        }

        [Test]
        public void TestRandomFromDatabase()
        {
            showMetadataForBeatmap(() =>
            {
                var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
                if (allBeatmapSets.Count == 0)
                    return manager.DefaultBeatmap;

                var randomBeatmapSet = allBeatmapSets[RNG.Next(0, allBeatmapSets.Count - 1)];
                var randomBeatmap = randomBeatmapSet.Beatmaps[RNG.Next(0, randomBeatmapSet.Beatmaps.Count - 1)];

                return manager.GetWorkingBeatmap(randomBeatmap);
            });
        }

        private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap)
        {
            AddStep("setup display", () =>
            {
                var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();

                OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };

                Children = new Drawable[]
                {
                    display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), logo)
                    {
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Alpha = 0f,
                    }
                };

                display.FadeIn(400, Easing.OutQuint);
            });

            AddWaitStep("wait a bit", 5);

            AddStep("finish loading", () => display.Loading = false);
        }
    }
}
{'fraction_non_alphanumeric': 0.09404496310279732, 'fraction_numerical': 0.0063497511584005495, 'mean_word_length': 1.6454834316840672, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '6000542', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1485, 'n_words': 327}