2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Screens;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
using osu.Game.Screens;
|
2018-12-21 15:28:33 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2018-12-21 15:28:33 +08:00
|
|
|
|
using osu.Game.Screens.Ranking.Pages;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneResults : ScreenTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
|
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(Results),
|
|
|
|
|
typeof(ResultsPage),
|
2018-12-21 15:28:33 +08:00
|
|
|
|
typeof(ScoreResultsPage),
|
2019-11-01 14:32:06 +08:00
|
|
|
|
typeof(RetryButton),
|
2019-11-01 14:06:36 +08:00
|
|
|
|
typeof(ReplayDownloadButton),
|
2019-11-04 08:52:26 +08:00
|
|
|
|
typeof(LocalLeaderboardPage),
|
|
|
|
|
typeof(TestPlayer)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(BeatmapManager beatmaps)
|
|
|
|
|
{
|
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2018-05-23 16:37:39 +08:00
|
|
|
|
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
|
|
|
|
|
if (beatmapInfo != null)
|
|
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
|
2019-11-04 08:52:26 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-11-04 08:52:26 +08: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 17:19:50 +08:00
|
|
|
|
{
|
2019-11-04 08:52:26 +08: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;
|
2020-01-31 18:10:44 +08:00
|
|
|
|
OsuScreenStack stack;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
|
2020-01-31 18:10:44 +08:00
|
|
|
|
AddStep("load results", () =>
|
2019-11-04 08:52:26 +08:00
|
|
|
|
{
|
2020-01-31 18:10:44 +08:00
|
|
|
|
Child = stack = new OsuScreenStack
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
stack.Push(screen = createResultsScreen());
|
2019-11-04 08:52:26 +08:00
|
|
|
|
});
|
|
|
|
|
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;
|
2020-01-31 18:10:44 +08:00
|
|
|
|
OsuScreenStack stack;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
|
2020-01-31 18:10:44 +08:00
|
|
|
|
InternalChild = stack = new OsuScreenStack
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-04 08:52:26 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
2020-01-31 18:10:44 +08:00
|
|
|
|
|
|
|
|
|
stack.Push(screen);
|
2019-11-04 08:52:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|