diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs index c319d2f7de..dda9543159 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs @@ -2,12 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Profile; +using osu.Game.Users; namespace osu.Game.Tests.Visual.Online { @@ -49,5 +51,42 @@ namespace osu.Game.Tests.Visual.Online IsOnline = false, }); } + + [Test] + public void TestRankedState() + { + AddStep("Show ranked user", () => header.User.Value = new APIUser + { + Id = 2001, + Username = "RankedUser", + Statistics = new UserStatistics + { + IsRanked = true, + GlobalRank = 15000, + CountryRank = 1500, + RankHistory = new APIRankHistory + { + Mode = @"osu", + Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray() + }, + } + }); + + AddStep("Show unranked user", () => header.User.Value = new APIUser + { + Id = 2002, + Username = "UnrankedUser", + Statistics = new UserStatistics + { + IsRanked = false, + // web will sometimes return non-empty rank history even for unranked users. + RankHistory = new APIRankHistory + { + Mode = @"osu", + Data = Enumerable.Range(2345, 85).ToArray() + }, + } + }); + } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs index 1c92bb1e38..78e2ceb45b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs @@ -29,6 +29,7 @@ namespace osu.Game.Tests.Visual.Online ProfileOrder = new[] { "me" }, Statistics = new UserStatistics { + IsRanked = true, GlobalRank = 2148, CountryRank = 1, PP = 4567.89m, diff --git a/osu.Game/Users/UserStatistics.cs b/osu.Game/Users/UserStatistics.cs index c690447256..f8d26fe421 100644 --- a/osu.Game/Users/UserStatistics.cs +++ b/osu.Game/Users/UserStatistics.cs @@ -27,6 +27,9 @@ namespace osu.Game.Users public int Progress; } + [JsonProperty(@"is_ranked")] + public bool IsRanked; + [JsonProperty(@"global_rank")] public int? GlobalRank;