// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using NUnit.Framework; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens.Multi.Ranking; using osu.Game.Tests.Beatmaps; using osu.Game.Users; namespace osu.Game.Tests.Visual.Multiplayer { public class TestSceneTimeshiftResultsScreen : ScreenTestScene { [Test] public void TestShowResults() { var score = new TestScoreInfo(new OsuRuleset().RulesetInfo); var roomScores = new List(); for (int i = 0; i < 10; i++) { roomScores.Add(new RoomScore { ID = i, Accuracy = 0.9 - 0.01 * i, EndedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromHours(i)), Passed = true, Rank = ScoreRank.B, MaxCombo = 999, TotalScore = 999999 - i * 1000, User = new User { Id = 2, Username = $"peppy{i}", CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", }, Statistics = { { HitResult.Miss, 1 }, { HitResult.Meh, 50 }, { HitResult.Good, 100 }, { HitResult.Great, 300 }, } }); } AddStep("bind request handler", () => ((DummyAPIAccess)API).HandleRequest = request => { switch (request) { case GetRoomPlaylistScoresRequest r: r.TriggerSuccess(roomScores); break; } }); AddStep("load results", () => { LoadScreen(new TimeshiftResultsScreen(score, 1, new PlaylistItem { Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo }, Ruleset = { Value = new OsuRuleset().RulesetInfo } })); }); AddWaitStep("wait for display", 10); } } }