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
|
|
|
|
|
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;
|
2020-03-17 16:43:16 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
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;
|
|
|
|
|
|
2020-03-17 16:43:16 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-03-17 16:43:16 +08:00
|
|
|
|
public class TestSceneResultsScreen : ScreenTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
|
|
|
|
|
|
[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
|
|
|
|
|
2020-06-03 10:06:59 +08:00
|
|
|
|
private TestResultsScreen createResultsScreen() => new TestResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
|
|
|
|
|
|
|
|
|
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
2019-11-04 08:52:26 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ResultsWithoutPlayer()
|
|
|
|
|
{
|
2020-06-03 10:06:59 +08:00
|
|
|
|
TestResultsScreen 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()
|
|
|
|
|
{
|
2020-06-03 10:06:59 +08:00
|
|
|
|
TestResultsScreen screen = null;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
|
|
|
|
|
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
|
|
|
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
|
|
|
|
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 10:06:59 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void ResultsForUnranked()
|
|
|
|
|
{
|
|
|
|
|
UnrankedSoloResultsScreen screen = null;
|
|
|
|
|
|
|
|
|
|
AddStep("load results", () => Child = new TestResultsContainer(screen = createUnrankedSoloResultsScreen()));
|
|
|
|
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
|
|
|
|
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-04 08:52:26 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 10:06:59 +08:00
|
|
|
|
private class TestResultsScreen : ResultsScreen
|
|
|
|
|
{
|
|
|
|
|
public HotkeyRetryOverlay RetryOverlay;
|
|
|
|
|
|
|
|
|
|
public TestResultsScreen(ScoreInfo score)
|
|
|
|
|
: base(score)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class UnrankedSoloResultsScreen : SoloResultsScreen
|
2019-11-04 08:52:26 +08:00
|
|
|
|
{
|
|
|
|
|
public HotkeyRetryOverlay RetryOverlay;
|
|
|
|
|
|
2020-06-03 10:06:59 +08:00
|
|
|
|
public UnrankedSoloResultsScreen(ScoreInfo score)
|
2019-11-04 08:52:26 +08:00
|
|
|
|
: base(score)
|
|
|
|
|
{
|
2020-06-03 10:06:59 +08:00
|
|
|
|
Score.Beatmap.OnlineBeatmapID = 0;
|
|
|
|
|
Score.Beatmap.Status = BeatmapSetOnlineStatus.Pending;
|
2019-11-04 08:52:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|