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;
|
2021-12-19 19:48:09 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-12-19 19:48:09 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2023-01-25 06:30:07 +08:00
|
|
|
|
using osu.Game.Configuration;
|
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;
|
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
|
|
|
|
{
|
2022-11-24 13:32:20 +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);
|
|
|
|
|
|
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
|
|
|
|
{
|
2021-12-19 19:48:09 +08:00
|
|
|
|
AddStep("create header", () => Child = header = new ProfileHeader());
|
|
|
|
|
}
|
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));
|
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|