2019-06-29 06:56:37 +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.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
2019-06-29 05:25:30 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-06-29 06:56:37 +00:00
|
|
|
|
using osu.Game.Online;
|
2019-06-29 05:25:30 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
using osu.Game.Users;
|
2019-12-03 06:28:10 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Rulesets;
|
2020-03-17 08:43:16 +00:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2019-06-29 05:25:30 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestSceneReplayDownloadButton : OsuTestScene
|
|
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
|
2019-06-29 06:56:37 +00:00
|
|
|
|
private TestReplayDownloadButton downloadButton;
|
2019-06-29 05:25:30 +00:00
|
|
|
|
|
|
|
|
|
public TestSceneReplayDownloadButton()
|
|
|
|
|
{
|
2019-06-29 07:19:03 +00:00
|
|
|
|
createButton(true);
|
2019-06-29 06:56:37 +00:00
|
|
|
|
AddStep(@"downloading state", () => downloadButton.SetDownloadState(DownloadState.Downloading));
|
|
|
|
|
AddStep(@"locally available state", () => downloadButton.SetDownloadState(DownloadState.LocallyAvailable));
|
|
|
|
|
AddStep(@"not downloaded state", () => downloadButton.SetDownloadState(DownloadState.NotDownloaded));
|
2019-06-29 07:19:03 +00:00
|
|
|
|
createButton(false);
|
2020-05-28 12:46:02 +00:00
|
|
|
|
createButtonNoScore();
|
2019-06-29 06:56:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-29 07:19:03 +00:00
|
|
|
|
private void createButton(bool withReplay)
|
2019-06-29 06:56:37 +00:00
|
|
|
|
{
|
2019-06-29 07:19:03 +00:00
|
|
|
|
AddStep(withReplay ? @"create button with replay" : "create button without replay", () =>
|
2019-06-29 05:25:30 +00:00
|
|
|
|
{
|
2019-06-29 07:19:03 +00:00
|
|
|
|
Child = downloadButton = new TestReplayDownloadButton(getScoreInfo(withReplay))
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
};
|
2019-06-29 05:25:30 +00:00
|
|
|
|
});
|
2020-05-28 12:46:02 +00:00
|
|
|
|
|
|
|
|
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createButtonNoScore()
|
|
|
|
|
{
|
|
|
|
|
AddStep("create button with null score", () =>
|
|
|
|
|
{
|
|
|
|
|
Child = downloadButton = new TestReplayDownloadButton(null)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
2019-06-29 05:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-29 07:19:03 +00:00
|
|
|
|
private ScoreInfo getScoreInfo(bool replayAvailable)
|
2019-06-29 05:25:30 +00:00
|
|
|
|
{
|
|
|
|
|
return new APILegacyScoreInfo
|
|
|
|
|
{
|
|
|
|
|
OnlineScoreID = 2553163309,
|
2019-12-03 06:28:10 +00:00
|
|
|
|
OnlineRulesetID = 0,
|
2019-06-29 07:19:03 +00:00
|
|
|
|
Replay = replayAvailable,
|
2019-06-29 05:25:30 +00:00
|
|
|
|
User = new User
|
|
|
|
|
{
|
|
|
|
|
Id = 39828,
|
|
|
|
|
Username = @"WubWoofWolf",
|
|
|
|
|
}
|
2019-12-03 06:28:10 +00:00
|
|
|
|
}.CreateScoreInfo(rulesets);
|
2019-06-29 05:25:30 +00:00
|
|
|
|
}
|
2019-06-29 06:56:37 +00:00
|
|
|
|
|
|
|
|
|
private class TestReplayDownloadButton : ReplayDownloadButton
|
|
|
|
|
{
|
|
|
|
|
public void SetDownloadState(DownloadState state) => State.Value = state;
|
|
|
|
|
|
2019-06-29 06:59:12 +00:00
|
|
|
|
public TestReplayDownloadButton(ScoreInfo score)
|
|
|
|
|
: base(score)
|
2019-06-29 06:56:37 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-29 05:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|