1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs

138 lines
4.2 KiB
C#
Raw Normal View History

// 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.Linq;
2018-04-13 17:19:50 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
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;
using osu.Game.Screens;
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();
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
}
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));
[Test]
public void ResultsWithoutPlayer()
{
2020-06-03 10:06:59 +08:00
TestResultsScreen screen = null;
OsuScreenStack stack;
AddStep("load results", () =>
{
Child = stack = new OsuScreenStack
{
RelativeSizeAxes = Axes.Both
};
stack.Push(screen = createResultsScreen());
});
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;
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);
}
private class TestResultsContainer : Container
{
[Cached(typeof(Player))]
private readonly Player player = new TestPlayer();
public TestResultsContainer(IScreen screen)
{
RelativeSizeAxes = Axes.Both;
OsuScreenStack stack;
InternalChild = stack = new OsuScreenStack
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
};
stack.Push(screen);
}
}
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
{
public HotkeyRetryOverlay RetryOverlay;
2020-06-03 10:06:59 +08:00
public UnrankedSoloResultsScreen(ScoreInfo score)
: base(score)
{
2020-06-03 10:06:59 +08:00
Score.Beatmap.OnlineBeatmapID = 0;
Score.Beatmap.Status = BeatmapSetOnlineStatus.Pending;
}
protected override void LoadComplete()
{
base.LoadComplete();
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
}
2018-04-13 17:19:50 +08:00
}
}
}