2019-08-02 02:26:59 +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-08-13 13:09:10 +08:00
|
|
|
|
using System;
|
2019-08-02 02:26:59 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2023-09-12 07:34:17 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-08-13 13:07:40 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2019-08-02 02:26:59 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-08-13 13:09:10 +08:00
|
|
|
|
public partial class TestSceneUserProfilePreviousUsernames : OsuTestScene
|
2019-08-02 02:26:59 +08:00
|
|
|
|
{
|
2022-12-30 22:05:04 +08:00
|
|
|
|
private PreviousUsernames container = null!;
|
2023-09-12 07:34:17 +08:00
|
|
|
|
private OverlayColourProvider colourProvider = null!;
|
2019-08-03 09:45:41 +08:00
|
|
|
|
|
2021-10-20 15:32:00 +08:00
|
|
|
|
[SetUp]
|
2021-10-20 15:54:08 +08:00
|
|
|
|
public void SetUp() => Schedule(() =>
|
2019-08-02 02:26:59 +08:00
|
|
|
|
{
|
2023-09-12 07:34:17 +08:00
|
|
|
|
colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
|
|
|
|
|
Child = new DependencyProvidingContainer
|
2019-08-02 02:26:59 +08:00
|
|
|
|
{
|
2023-09-12 07:34:17 +08:00
|
|
|
|
Child = container = new PreviousUsernames
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
CachedDependencies = new (Type, object)[] { (typeof(OverlayColourProvider), colourProvider) },
|
2019-08-02 02:26:59 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
};
|
2021-10-20 15:54:08 +08:00
|
|
|
|
});
|
2019-08-02 02:26:59 +08:00
|
|
|
|
|
2021-10-20 15:32:00 +08:00
|
|
|
|
[Test]
|
2021-10-20 16:27:24 +08:00
|
|
|
|
public void TestVisibility()
|
2021-10-20 15:32:00 +08:00
|
|
|
|
{
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddAssert("Is Hidden", () => container.Alpha == 0);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("1 username", () => container.User.Value = users[0]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is visible", () => container.Alpha == 1);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("2 usernames", () => container.User.Value = users[1]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is visible", () => container.Alpha == 1);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("3 usernames", () => container.User.Value = users[2]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is visible", () => container.Alpha == 1);
|
2019-08-02 12:44:09 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("4 usernames", () => container.User.Value = users[3]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is visible", () => container.Alpha == 1);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("No username", () => container.User.Value = users[4]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is hidden", () => container.Alpha == 0);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
|
2021-10-20 15:54:08 +08:00
|
|
|
|
AddStep("Null user", () => container.User.Value = users[5]);
|
2021-10-20 16:27:24 +08:00
|
|
|
|
AddUntilStep("Is hidden", () => container.Alpha == 0);
|
2021-10-20 15:32:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 22:05:04 +08:00
|
|
|
|
private static readonly APIUser?[] users =
|
2021-10-20 15:32:00 +08:00
|
|
|
|
{
|
2021-11-04 17:02:44 +08:00
|
|
|
|
new APIUser { Id = 1, PreviousUsernames = new[] { "username1" } },
|
|
|
|
|
new APIUser { Id = 2, PreviousUsernames = new[] { "longusername", "longerusername" } },
|
|
|
|
|
new APIUser { Id = 3, PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
|
|
|
|
new APIUser { Id = 4, PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
|
|
|
|
new APIUser { Id = 5, PreviousUsernames = Array.Empty<string>() },
|
2021-10-20 15:32:00 +08:00
|
|
|
|
null
|
|
|
|
|
};
|
2019-08-02 02:26:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|