<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 System.Net;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Ranking;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources;

namespace osu.Game.Tests.Visual.Playlists
{
    public class TestScenePlaylistsResultsScreen : ScreenTestScene
    {
        private const int scores_per_result = 10;
        private const int real_user_position = 200;

        private TestResultsScreen resultsScreen;

        private int currentScoreId;
        private bool requestComplete;
        private int totalCount;

        [SetUp]
        public void Setup() => Schedule(() =>
        {
            currentScoreId = 1;
            requestComplete = false;
            totalCount = 0;
            bindHandler();
        });

        [Test]
        public void TestShowWithUserScore()
        {
            ScoreInfo userScore = null;

            AddStep("bind user score info handler", () =>
            {
                userScore = TestResources.CreateTestScoreInfo();
                userScore.OnlineID = currentScoreId++;

                bindHandler(userScore: userScore);
            });

            createResults(() => userScore);

            AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
            AddAssert($"score panel position is {real_user_position}",
                () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).ScorePosition.Value == real_user_position);
        }

        [Test]
        public void TestShowNullUserScore()
        {
            createResults();<commit_msg>Fix `PLaylistsResultsScreen` tests falling over due to missing beatmap<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 System.Net;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Ranking;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources;

namespace osu.Game.Tests.Visual.Playlists
{
    public class TestScenePlaylistsResultsScreen : ScreenTestScene
    {
        private const int scores_per_result = 10;
        private const int real_user_position = 200;

        private TestResultsScreen resultsScreen;

        private int currentScoreId;
        private bool requestComplete;
        private int totalCount;

        [SetUp]
        public void Setup() => Schedule(() =>
        {
            currentScoreId = 1;
            requestComplete = false;
            totalCount = 0;
            bindHandler();

            // beatmap is required to be an actual beatmap so the scores can get their scores correctly calculated for standardised scoring.
            // else the tests that rely on ordering will fall over.
            Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
        });

        [Test]
        public void TestShowWithUserScore()
        {
            ScoreInfo userScore = null;

            AddStep("bind user score info handler", () =>
            {
                userScore = TestResources.CreateTestScoreInfo();
                userScore.OnlineID = currentScoreId++;

                bindHandler(userScore: userScore);
            });

            createResults(() => userScore);

            AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
            AddAssert($"score panel position is {real_user_position}",
                () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).ScorePosition.Value == real_user_position);
        }

        [Test]
        public void TestShowNullUserScore()
        {
            createResults();
{'fraction_non_alphanumeric': 0.09912420382165606, 'fraction_numerical': 0.002786624203821656, 'mean_word_length': 2.7416232315711095, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '5325635', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1369, 'n_words': 337}