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
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
2022-12-30 23:11:56 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TestSceneUserProfileOverlay : OsuTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-12-30 23:11:56 +08:00
|
|
|
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
2019-08-01 03:44:44 +08:00
|
|
|
|
|
2022-12-30 23:11:56 +08:00
|
|
|
|
private UserProfileOverlay profile = null!;
|
|
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
|
|
|
|
AddStep("create profile overlay", () => Child = profile = new UserProfileOverlay());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestBlank()
|
|
|
|
|
{
|
|
|
|
|
AddStep("show overlay", () => profile.Show());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestActualUser()
|
|
|
|
|
{
|
|
|
|
|
AddStep("set up request handling", () =>
|
|
|
|
|
{
|
|
|
|
|
dummyAPI.HandleRequest = req =>
|
|
|
|
|
{
|
|
|
|
|
if (req is GetUserRequest getUserRequest)
|
|
|
|
|
{
|
|
|
|
|
getUserRequest.TriggerSuccess(TEST_USER);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
|
|
|
|
AddToggleStep("toggle visibility", visible => profile.State.Value = visible ? Visibility.Visible : Visibility.Hidden);
|
2022-12-31 03:13:23 +08:00
|
|
|
|
AddStep("log out", () => dummyAPI.Logout());
|
|
|
|
|
AddStep("log back in", () => dummyAPI.Login("username", "password"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestLoading()
|
|
|
|
|
{
|
|
|
|
|
GetUserRequest pendingRequest = null!;
|
|
|
|
|
|
|
|
|
|
AddStep("set up request handling", () =>
|
|
|
|
|
{
|
|
|
|
|
dummyAPI.HandleRequest = req =>
|
|
|
|
|
{
|
|
|
|
|
if (req is GetUserRequest getUserRequest)
|
|
|
|
|
{
|
|
|
|
|
pendingRequest = getUserRequest;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
|
|
|
|
AddWaitStep("wait some", 3);
|
|
|
|
|
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
2022-12-30 23:11:56 +08:00
|
|
|
|
}
|
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,
|
2023-01-01 02:58:58 +08:00
|
|
|
|
CountryCode = CountryCode.JP,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
|
|
|
|
|
JoinDate = DateTimeOffset.Now.AddDays(-1),
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
2023-01-11 12:11:38 +08:00
|
|
|
|
Groups = new[]
|
|
|
|
|
{
|
|
|
|
|
new APIUserGroup { Colour = "#EB47D0", ShortName = "DEV", Name = "Developers" },
|
2023-01-22 12:36:53 +08:00
|
|
|
|
new APIUserGroup { Colour = "#A347EB", ShortName = "BN", Name = "Beatmap Nominators", Playmodes = new[] { "mania" } },
|
2023-01-23 00:32:05 +08:00
|
|
|
|
new APIUserGroup { Colour = "#A347EB", ShortName = "BN", Name = "Beatmap Nominators", Playmodes = new[] { "osu", "taiko" } },
|
|
|
|
|
new APIUserGroup { Colour = "#A347EB", ShortName = "BN", Name = "Beatmap Nominators", Playmodes = new[] { "osu", "taiko", "fruits", "mania" } },
|
|
|
|
|
new APIUserGroup { Colour = "#A347EB", ShortName = "BN", Name = "Beatmap Nominators (Probationary)", Playmodes = new[] { "osu", "taiko", "fruits", "mania" }, IsProbationary = true }
|
2023-01-11 12:11:38 +08:00
|
|
|
|
},
|
2022-12-31 23:53:03 +08:00
|
|
|
|
ProfileOrder = new[]
|
|
|
|
|
{
|
|
|
|
|
@"me",
|
|
|
|
|
@"recent_activity",
|
|
|
|
|
@"beatmaps",
|
|
|
|
|
@"historical",
|
|
|
|
|
@"kudosu",
|
|
|
|
|
@"top_ranks",
|
|
|
|
|
@"medals"
|
|
|
|
|
},
|
2019-01-11 08:12:19 +08:00
|
|
|
|
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.",
|
2022-11-03 13:30:30 +08:00
|
|
|
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
|
|
|
|
Url = "https://osu.ppy.sh/wiki/en/People/Community_Contributors",
|
|
|
|
|
},
|
|
|
|
|
new Badge
|
|
|
|
|
{
|
|
|
|
|
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
|
|
|
|
Description = "Badge without a url.",
|
|
|
|
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
|
|
|
|
},
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
Title = "osu!volunteer",
|
|
|
|
|
Colour = "ff0000",
|
2021-11-05 12:38:37 +08:00
|
|
|
|
Achievements = Array.Empty<APIUserAchievement>(),
|
2022-12-31 23:53:03 +08:00
|
|
|
|
PlayMode = "osu",
|
|
|
|
|
Kudosu = new APIUser.KudosuCount
|
|
|
|
|
{
|
|
|
|
|
Available = 10,
|
|
|
|
|
Total = 50
|
2023-01-01 02:58:58 +08:00
|
|
|
|
},
|
|
|
|
|
SupportLevel = 2,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|