2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-11-04 00:52:26 +00:00
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-11-04 00:52:26 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Screens;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-11-28 07:12:57 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2019-11-04 00:52:26 +00:00
|
|
|
|
using osu.Game.Screens;
|
2018-12-21 07:28:33 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2018-12-21 07:28:33 +00:00
|
|
|
|
using osu.Game.Screens.Ranking.Pages;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public class TestSceneResults : ScreenTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
|
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(Results),
|
|
|
|
|
typeof(ResultsPage),
|
2018-12-21 07:28:33 +00:00
|
|
|
|
typeof(ScoreResultsPage),
|
2019-11-01 06:32:06 +00:00
|
|
|
|
typeof(RetryButton),
|
2019-11-01 06:06:36 +00:00
|
|
|
|
typeof(ReplayDownloadButton),
|
2019-11-04 00:52:26 +00:00
|
|
|
|
typeof(LocalLeaderboardPage),
|
|
|
|
|
typeof(TestPlayer)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(BeatmapManager beatmaps)
|
|
|
|
|
{
|
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2018-05-23 08:37:39 +00:00
|
|
|
|
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
|
|
|
|
|
if (beatmapInfo != null)
|
|
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
|
2019-11-04 00:52:26 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-04 00:52:26 +00:00
|
|
|
|
private TestSoloResults createResultsScreen() => new TestSoloResults(new ScoreInfo
|
|
|
|
|
{
|
|
|
|
|
TotalScore = 2845370,
|
|
|
|
|
Accuracy = 0.98,
|
|
|
|
|
MaxCombo = 123,
|
|
|
|
|
Rank = ScoreRank.A,
|
|
|
|
|
Date = DateTimeOffset.Now,
|
|
|
|
|
Statistics = new Dictionary<HitResult, int>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-04 00:52:26 +00:00
|
|
|
|
{ HitResult.Great, 50 },
|
|
|
|
|
{ HitResult.Good, 20 },
|
|
|
|
|
{ HitResult.Meh, 50 },
|
|
|
|
|
{ HitResult.Miss, 1 }
|
|
|
|
|
},
|
|
|
|
|
User = new User
|
|
|
|
|
{
|
|
|
|
|
Username = "peppy",
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ResultsWithoutPlayer()
|
|
|
|
|
{
|
|
|
|
|
TestSoloResults screen = null;
|
|
|
|
|
|
|
|
|
|
AddStep("load results", () => Child = new OsuScreenStack(screen = createResultsScreen())
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
});
|
|
|
|
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
|
|
|
|
AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ResultsWithPlayer()
|
|
|
|
|
{
|
|
|
|
|
TestSoloResults screen = null;
|
|
|
|
|
|
|
|
|
|
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
|
|
|
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
|
|
|
|
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestResultsContainer : Container
|
|
|
|
|
{
|
|
|
|
|
[Cached(typeof(Player))]
|
|
|
|
|
private readonly Player player = new TestPlayer();
|
|
|
|
|
|
|
|
|
|
public TestResultsContainer(IScreen screen)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChild = new OsuScreenStack(screen)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-04 00:52:26 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestSoloResults : SoloResults
|
|
|
|
|
{
|
|
|
|
|
public HotkeyRetryOverlay RetryOverlay;
|
|
|
|
|
|
|
|
|
|
public TestSoloResults(ScoreInfo score)
|
|
|
|
|
: base(score)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|