1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 03:37:51 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneUserProfilePreviousUsernamesDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.8 KiB
C#
Raw Normal View History

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;
using osu.Game.Online.API.Requests.Responses;
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]
public partial class TestSceneUserProfilePreviousUsernamesDisplay : OsuTestScene
2019-08-02 02:26:59 +08:00
{
private PreviousUsernamesDisplay container = null!;
private OverlayColourProvider colourProvider = null!;
2019-08-03 09:45:41 +08:00
[SetUp]
2021-10-20 15:54:08 +08:00
public void SetUp() => Schedule(() =>
2019-08-02 02:26:59 +08:00
{
colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
Child = new DependencyProvidingContainer
2019-08-02 02:26:59 +08:00
{
Child = container = new PreviousUsernamesDisplay
{
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
[Test]
public void TestVisibility()
{
AddAssert("Is Hidden", () => container.Alpha == 0);
2021-10-20 15:54:08 +08:00
AddStep("1 username", () => container.User.Value = users[0]);
AddUntilStep("Is visible", () => container.Alpha == 1);
2021-10-20 15:54:08 +08:00
AddStep("2 usernames", () => container.User.Value = users[1]);
AddUntilStep("Is visible", () => container.Alpha == 1);
2021-10-20 15:54:08 +08:00
AddStep("3 usernames", () => container.User.Value = users[2]);
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]);
AddUntilStep("Is visible", () => container.Alpha == 1);
2021-10-20 15:54:08 +08:00
AddStep("No username", () => container.User.Value = users[4]);
AddUntilStep("Is hidden", () => container.Alpha == 0);
2021-10-20 15:54:08 +08:00
AddStep("Null user", () => container.User.Value = users[5]);
AddUntilStep("Is hidden", () => container.Alpha == 0);
}
private static readonly APIUser?[] users =
{
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>() },
null
};
2019-08-02 02:26:59 +08:00
}
}