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
|
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2017-12-22 17:58:35 +08:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
using osu.Game.Users;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneUserProfileOverlay : OsuTestScene
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2019-09-13 16:15:33 +08:00
|
|
|
|
protected override bool UseOnlineAPI => true;
|
2019-08-01 03:44:44 +08:00
|
|
|
|
|
2017-12-25 22:25:47 +08:00
|
|
|
|
private readonly TestUserProfileOverlay profile;
|
2019-04-04 06:57:15 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
public static readonly APIUser TEST_USER = new APIUser
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Username = @"Somebody",
|
|
|
|
|
Id = 1,
|
|
|
|
|
Country = new Country { FullName = @"Alien" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
|
|
|
|
|
JoinDate = DateTimeOffset.Now.AddDays(-1),
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
ProfileOrder = new[] { "me" },
|
|
|
|
|
Statistics = new UserStatistics
|
|
|
|
|
{
|
2021-12-19 19:55:24 +08:00
|
|
|
|
IsRanked = true,
|
2021-02-17 13:50:48 +08:00
|
|
|
|
GlobalRank = 2148,
|
2021-02-18 20:37:52 +08:00
|
|
|
|
CountryRank = 1,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
PP = 4567.89m,
|
|
|
|
|
Level = new UserStatistics.LevelInfo
|
|
|
|
|
{
|
|
|
|
|
Current = 727,
|
|
|
|
|
Progress = 69,
|
2019-08-04 19:35:26 +08:00
|
|
|
|
},
|
2021-11-05 12:38:37 +08:00
|
|
|
|
RankHistory = new APIRankHistory
|
2019-08-04 19:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
Mode = @"osu",
|
|
|
|
|
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
|
|
|
|
},
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
Badges = new[]
|
|
|
|
|
{
|
|
|
|
|
new Badge
|
|
|
|
|
{
|
|
|
|
|
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
|
|
|
|
Description = "Outstanding help by being a voluntary test subject.",
|
|
|
|
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Title = "osu!volunteer",
|
|
|
|
|
Colour = "ff0000",
|
2021-11-05 12:38:37 +08:00
|
|
|
|
Achievements = Array.Empty<APIUserAchievement>(),
|
2019-01-11 08:12:19 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneUserProfileOverlay()
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
2017-12-25 22:25:47 +08:00
|
|
|
|
Add(profile = new TestUserProfileOverlay());
|
2017-12-25 23:52:17 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-25 23:52:17 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-05 12:52:42 +08:00
|
|
|
|
AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
AddStep("Show null dummy", () => profile.ShowUser(new APIUser
|
2018-03-10 23:44:00 +08:00
|
|
|
|
{
|
|
|
|
|
Username = @"Null",
|
|
|
|
|
Id = 1,
|
2021-11-05 12:52:42 +08:00
|
|
|
|
}));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
AddStep("Show ppy", () => profile.ShowUser(new APIUser
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
|
|
|
|
Username = @"peppy",
|
|
|
|
|
Id = 2,
|
2018-04-23 20:41:51 +08:00
|
|
|
|
IsSupporter = true,
|
2017-09-18 21:32:49 +08:00
|
|
|
|
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
2021-11-05 12:52:42 +08:00
|
|
|
|
}));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
AddStep("Show flyte", () => profile.ShowUser(new APIUser
|
2017-09-18 21:32:49 +08:00
|
|
|
|
{
|
|
|
|
|
Username = @"flyte",
|
|
|
|
|
Id = 3103765,
|
|
|
|
|
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
2021-11-05 12:52:42 +08:00
|
|
|
|
}));
|
2019-09-29 20:18:29 +08:00
|
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
|
AddStep("Show bancho", () => profile.ShowUser(new APIUser
|
2019-09-29 19:56:33 +08:00
|
|
|
|
{
|
|
|
|
|
Username = @"BanchoBot",
|
|
|
|
|
Id = 3,
|
|
|
|
|
IsBot = true,
|
|
|
|
|
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
|
2021-11-05 12:52:42 +08:00
|
|
|
|
}));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-05 12:52:42 +08:00
|
|
|
|
AddStep("Show ppy from username", () => profile.ShowUser(new APIUser { Username = @"peppy" }));
|
|
|
|
|
AddStep("Show flyte from username", () => profile.ShowUser(new APIUser { Username = @"flyte" }));
|
2021-09-05 22:11:41 +08:00
|
|
|
|
|
2017-09-18 21:32:49 +08:00
|
|
|
|
AddStep("Hide", profile.Hide);
|
|
|
|
|
AddStep("Show without reload", profile.Show);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-25 23:52:17 +08:00
|
|
|
|
private class TestUserProfileOverlay : UserProfileOverlay
|
|
|
|
|
{
|
2017-12-25 22:25:47 +08:00
|
|
|
|
public new ProfileHeader Header => base.Header;
|
|
|
|
|
}
|
2017-09-18 21:32:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|