2019-01-27 23:45:00 +01: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.
|
2019-01-11 01:12:19 +01:00
|
|
|
|
|
|
|
|
|
using System;
|
2021-12-19 12:55:24 +01:00
|
|
|
|
using System.Linq;
|
2021-12-19 12:48:09 +01:00
|
|
|
|
using NUnit.Framework;
|
2019-01-11 01:12:19 +01:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-12-19 12:48:09 +01:00
|
|
|
|
using osu.Framework.Testing;
|
2021-11-04 18:02:44 +09:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2019-05-21 13:36:21 +09:00
|
|
|
|
using osu.Game.Overlays;
|
2019-01-11 01:12:19 +01:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
2021-12-19 12:55:24 +01:00
|
|
|
|
using osu.Game.Users;
|
2019-01-11 01:12:19 +01:00
|
|
|
|
|
2019-04-04 00:24:42 +02:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2019-01-11 01:12:19 +01:00
|
|
|
|
{
|
2019-05-14 22:37:25 +03:00
|
|
|
|
public partial class TestSceneUserProfileHeader : OsuTestScene
|
2019-01-11 01:12:19 +01:00
|
|
|
|
{
|
2020-01-24 12:42:48 +03:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
|
|
|
|
|
2022-12-30 15:05:04 +01:00
|
|
|
|
private ProfileHeader header = null!;
|
2019-01-11 01:12:19 +01:00
|
|
|
|
|
2021-12-19 12:48:09 +01:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
2019-01-11 01:12:19 +01:00
|
|
|
|
{
|
2021-12-19 12:48:09 +01:00
|
|
|
|
AddStep("create header", () => Child = header = new ProfileHeader());
|
|
|
|
|
}
|
2019-01-11 01:12:19 +01:00
|
|
|
|
|
2021-12-19 12:48:09 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBasic()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Show example user", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
|
|
|
|
|
}
|
2019-01-11 01:12:19 +01:00
|
|
|
|
|
2021-12-19 12:48:09 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnlineState()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Show online user", () => header.User.Value = new APIUser
|
2019-06-19 12:34:01 +03:00
|
|
|
|
{
|
2021-12-19 12:48:09 +01:00
|
|
|
|
Id = 1001,
|
2019-06-19 12:34:01 +03:00
|
|
|
|
Username = "IAmOnline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = true,
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-19 12:48:09 +01:00
|
|
|
|
AddStep("Show offline user", () => header.User.Value = new APIUser
|
2019-06-19 12:34:01 +03:00
|
|
|
|
{
|
2021-12-19 12:48:09 +01:00
|
|
|
|
Id = 1002,
|
2019-06-19 12:34:01 +03:00
|
|
|
|
Username = "IAmOffline",
|
2021-12-19 12:48:09 +01:00
|
|
|
|
LastVisit = DateTimeOffset.Now.AddDays(-10),
|
2019-06-19 12:34:01 +03:00
|
|
|
|
IsOnline = false,
|
|
|
|
|
});
|
2019-01-11 01:12:19 +01:00
|
|
|
|
}
|
2021-12-19 12:55:24 +01:00
|
|
|
|
|
|
|
|
|
[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()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-01-11 01:12:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|