2019-01-28 06:45:00 +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.
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2021-12-19 19:55:24 +08:00
|
|
|
|
using System.Linq;
|
2024-11-01 13:58:08 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-12-19 19:48:09 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2023-10-30 11:19:52 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-12-19 19:48:09 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2023-01-25 06:30:07 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2023-10-30 11:19:52 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2024-11-01 13:58:08 +08:00
|
|
|
|
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;
|
2019-05-21 12:36:21 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
2024-11-01 13:58:08 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2022-12-31 00:53:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2021-12-19 19:55:24 +08:00
|
|
|
|
using osu.Game.Users;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-04-04 06:24:42 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public partial class TestSceneUserProfileHeader : OsuTestScene
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2020-01-24 17:42:48 +08:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
|
|
|
|
|
2024-11-01 13:58:08 +08:00
|
|
|
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
|
|
|
|
|
|
|
|
|
private readonly ManualResetEventSlim requestLock = new ManualResetEventSlim();
|
|
|
|
|
|
2023-01-25 06:30:07 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuConfigManager configManager { get; set; } = null!;
|
|
|
|
|
|
2022-12-30 22:05:04 +08:00
|
|
|
|
private ProfileHeader header = null!;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2021-12-19 19:48:09 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2023-10-30 11:19:52 +08:00
|
|
|
|
AddStep("create header", () =>
|
|
|
|
|
{
|
|
|
|
|
Child = new OsuScrollContainer(Direction.Vertical)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = header = new ProfileHeader()
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-12-19 19:48:09 +08:00
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2021-12-19 19:48:09 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestBasic()
|
|
|
|
|
{
|
2023-01-12 02:11:40 +08:00
|
|
|
|
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
2021-12-19 19:48:09 +08:00
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2023-01-25 06:30:07 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestProfileCoverExpanded()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Set cover to expanded", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, true));
|
|
|
|
|
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
|
|
|
|
AddUntilStep("Cover is expanded", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.GreaterThan(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestProfileCoverCollapsed()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Set cover to collapsed", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, false));
|
|
|
|
|
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
|
|
|
|
|
AddUntilStep("Cover is collapsed", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.EqualTo(0));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 19:48:09 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnlineState()
|
|
|
|
|
{
|
2023-01-11 02:24:54 +08:00
|
|
|
|
AddStep("Show online user", () => header.User.Value = new UserProfileData(new APIUser
|
2019-06-19 17:34:01 +08:00
|
|
|
|
{
|
2021-12-19 19:48:09 +08:00
|
|
|
|
Id = 1001,
|
2019-06-19 17:34:01 +08:00
|
|
|
|
Username = "IAmOnline",
|
|
|
|
|
LastVisit = DateTimeOffset.Now,
|
|
|
|
|
IsOnline = true,
|
2022-12-31 00:53:50 +08:00
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
2019-06-19 17:34:01 +08:00
|
|
|
|
|
2023-01-11 02:24:54 +08:00
|
|
|
|
AddStep("Show offline user", () => header.User.Value = new UserProfileData(new APIUser
|
2019-06-19 17:34:01 +08:00
|
|
|
|
{
|
2021-12-19 19:48:09 +08:00
|
|
|
|
Id = 1002,
|
2019-06-19 17:34:01 +08:00
|
|
|
|
Username = "IAmOffline",
|
2021-12-19 19:48:09 +08:00
|
|
|
|
LastVisit = DateTimeOffset.Now.AddDays(-10),
|
2019-06-19 17:34:01 +08:00
|
|
|
|
IsOnline = false,
|
2022-12-31 00:53:50 +08:00
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
2021-12-19 19:55:24 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestRankedState()
|
|
|
|
|
{
|
2023-01-11 02:24:54 +08:00
|
|
|
|
AddStep("Show ranked user", () => header.User.Value = new UserProfileData(new APIUser
|
2021-12-19 19:55:24 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 2001,
|
|
|
|
|
Username = "RankedUser",
|
2023-01-11 15:50:37 +08:00
|
|
|
|
Groups = new[] { new APIUserGroup { Colour = "#EB47D0", ShortName = "DEV", Name = "Developers" } },
|
2021-12-19 19:55:24 +08:00
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
}
|
2022-12-31 00:53:50 +08:00
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
2021-12-19 19:55:24 +08:00
|
|
|
|
|
2023-01-11 02:24:54 +08:00
|
|
|
|
AddStep("Show unranked user", () => header.User.Value = new UserProfileData(new APIUser
|
2021-12-19 19:55:24 +08:00
|
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
}
|
2022-12-31 00:53:50 +08:00
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
2021-12-19 19:55:24 +08:00
|
|
|
|
}
|
2023-09-11 21:02:19 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestPreviousUsernames()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Show user w/ previous usernames", () => header.User.Value = new UserProfileData(new APIUser
|
|
|
|
|
{
|
|
|
|
|
Id = 727,
|
|
|
|
|
Username = "SomeoneIndecisive",
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
|
|
|
|
|
Groups = new[]
|
|
|
|
|
{
|
|
|
|
|
new APIUserGroup { Colour = "#EB47D0", ShortName = "DEV", Name = "Developers" },
|
|
|
|
|
},
|
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
PreviousUsernames = new[] { "tsrk.", "quoicoubeh", "apagnan", "epita" }
|
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
|
|
|
|
}
|
2023-10-30 11:19:52 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestManyTournamentBanners()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Show user w/ many tournament banners", () => header.User.Value = new UserProfileData(new APIUser
|
|
|
|
|
{
|
|
|
|
|
Id = 728,
|
|
|
|
|
Username = "Certain Guy",
|
|
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TournamentBanners = new[]
|
|
|
|
|
{
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15329,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_HK.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_HK@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15588,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CN.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CN@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15589,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PH.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PH@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15590,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CL.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CL@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15591,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_JP.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_JP@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15592,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_RU.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_RU@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15593,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_KR.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_KR@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15594,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NZ.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NZ@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15595,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_TH.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_TH@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15596,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_TW.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_TW@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15603,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_ID.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_ID@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15604,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_KZ.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_KZ@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15605,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_AR.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_AR@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15606,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_BR.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_BR@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15607,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PL.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PL@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15639,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_MX.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_MX@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15640,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_AU.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_AU@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15641,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_IT.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_IT@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15642,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_UA.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_UA@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15643,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NL.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NL@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15644,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_FI.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_FI@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15645,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_RO.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_RO@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15646,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_SG.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_SG@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15647,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_DE.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_DE@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15648,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_ES.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_ES@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15649,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_SE.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_SE@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15650,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CA.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_CA@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15651,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NO.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_NO@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15652,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_GB.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_GB@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15653,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_US.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_US@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15654,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PL.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_PL@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15655,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_FR.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_FR@2x.jpg"
|
|
|
|
|
},
|
|
|
|
|
new TournamentBanner
|
|
|
|
|
{
|
|
|
|
|
Id = 15686,
|
|
|
|
|
TournamentId = 41,
|
|
|
|
|
ImageLowRes = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_HK.jpg",
|
|
|
|
|
Image = "https://assets.ppy.sh/tournament-banners/official/owc2023/profile/supporter_HK@2x.jpg"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, new OsuRuleset().RulesetInfo));
|
|
|
|
|
}
|
2024-11-01 13:58:08 +08:00
|
|
|
|
|
2024-11-01 14:24:54 +08:00
|
|
|
|
private APIUser nonFriend => new APIUser
|
|
|
|
|
{
|
|
|
|
|
Id = 727,
|
|
|
|
|
Username = "Whatever",
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-01 13:58:08 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestAddFriend()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Setup request", () =>
|
|
|
|
|
{
|
|
|
|
|
requestLock.Reset();
|
|
|
|
|
|
2024-11-01 14:24:54 +08:00
|
|
|
|
dummyAPI.HandleRequest = request =>
|
2024-11-01 13:58:08 +08:00
|
|
|
|
{
|
2024-11-01 19:16:56 +08:00
|
|
|
|
if (request is not AddFriendRequest req)
|
2024-11-01 13:58:08 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2024-11-01 14:24:54 +08:00
|
|
|
|
if (req.TargetId != nonFriend.OnlineID)
|
2024-11-01 13:58:08 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2024-11-01 19:24:58 +08:00
|
|
|
|
var apiRelation = new APIRelation
|
|
|
|
|
{
|
|
|
|
|
TargetID = nonFriend.OnlineID,
|
|
|
|
|
Mutual = true,
|
|
|
|
|
RelationType = RelationType.Friend,
|
|
|
|
|
TargetUser = nonFriend
|
|
|
|
|
};
|
2024-11-01 13:58:08 +08:00
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
requestLock.Wait(3000);
|
2024-11-01 14:24:54 +08:00
|
|
|
|
dummyAPI.Friends.Add(apiRelation);
|
2024-11-05 15:47:25 +08:00
|
|
|
|
req.TriggerSuccess(new AddFriendResponse
|
|
|
|
|
{
|
|
|
|
|
UserRelation = apiRelation
|
|
|
|
|
});
|
2024-11-01 13:58:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-11-01 14:24:54 +08:00
|
|
|
|
AddStep("clear friend list", () => dummyAPI.Friends.Clear());
|
|
|
|
|
AddStep("Show non-friend user", () => header.User.Value = new UserProfileData(nonFriend, new OsuRuleset().RulesetInfo));
|
2024-11-01 13:58:08 +08:00
|
|
|
|
AddStep("Click followers button", () => this.ChildrenOfType<FollowersButton>().First().TriggerClick());
|
|
|
|
|
AddStep("Complete request", () => requestLock.Set());
|
2024-11-01 14:24:54 +08:00
|
|
|
|
AddUntilStep("Friend added", () => API.Friends.Any(f => f.TargetID == nonFriend.OnlineID));
|
2024-11-01 13:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestAddFriendNonMutual()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Setup request", () =>
|
|
|
|
|
{
|
|
|
|
|
requestLock.Reset();
|
|
|
|
|
|
2024-11-01 14:24:54 +08:00
|
|
|
|
dummyAPI.HandleRequest = request =>
|
2024-11-01 13:58:08 +08:00
|
|
|
|
{
|
2024-11-01 19:16:56 +08:00
|
|
|
|
if (request is not AddFriendRequest req)
|
2024-11-01 13:58:08 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2024-11-01 14:24:54 +08:00
|
|
|
|
if (req.TargetId != nonFriend.OnlineID)
|
2024-11-01 13:58:08 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2024-11-01 19:24:58 +08:00
|
|
|
|
var apiRelation = new APIRelation
|
|
|
|
|
{
|
|
|
|
|
TargetID = nonFriend.OnlineID,
|
|
|
|
|
Mutual = false,
|
|
|
|
|
RelationType = RelationType.Friend,
|
|
|
|
|
TargetUser = nonFriend
|
|
|
|
|
};
|
2024-11-01 13:58:08 +08:00
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
requestLock.Wait(3000);
|
2024-11-01 14:24:54 +08:00
|
|
|
|
dummyAPI.Friends.Add(apiRelation);
|
2024-11-05 15:47:25 +08:00
|
|
|
|
req.TriggerSuccess(new AddFriendResponse
|
|
|
|
|
{
|
|
|
|
|
UserRelation = apiRelation
|
|
|
|
|
});
|
2024-11-01 13:58:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-11-01 14:24:54 +08:00
|
|
|
|
AddStep("clear friend list", () => dummyAPI.Friends.Clear());
|
|
|
|
|
AddStep("Show non-friend user", () => header.User.Value = new UserProfileData(nonFriend, new OsuRuleset().RulesetInfo));
|
2024-11-01 13:58:08 +08:00
|
|
|
|
AddStep("Click followers button", () => this.ChildrenOfType<FollowersButton>().First().TriggerClick());
|
|
|
|
|
AddStep("Complete request", () => requestLock.Set());
|
2024-11-01 14:24:54 +08:00
|
|
|
|
AddUntilStep("Friend added", () => API.Friends.Any(f => f.TargetID == nonFriend.OnlineID));
|
2024-11-01 13:58:08 +08:00
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|