1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 22:07:28 +08:00
osu-lazer/osu.Game.Tests/Visual/Multiplayer/TestSceneTimeshiftResultsScreen.cs
2020-05-28 22:09:11 +09:00

77 lines
2.5 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<RoomScore>();
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);
}
}
}