diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfilePreviousUsernames.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfilePreviousUsernames.cs index 1e9d62f379..b5d2d15392 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfilePreviousUsernames.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfilePreviousUsernames.cs @@ -3,11 +3,7 @@ using System; using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Users; @@ -16,48 +12,50 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestSceneUserProfilePreviousUsernames : OsuTestScene { - [Resolved] - private IAPIProvider api { get; set; } + private PreviousUsernames container; - private readonly Bindable user = new Bindable(); - - public TestSceneUserProfilePreviousUsernames() + [SetUp] + public void SetUp() => Schedule(() => { - Child = new PreviousUsernames + Child = container = new PreviousUsernames { Anchor = Anchor.Centre, Origin = Anchor.Centre, - User = { BindTarget = user }, }; + }); - User[] users = - { - new User { PreviousUsernames = new[] { "username1" } }, - new User { PreviousUsernames = new[] { "longusername", "longerusername" } }, - new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } }, - new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } }, - new User { PreviousUsernames = Array.Empty() }, - null - }; - - AddStep("single username", () => user.Value = users[0]); - AddStep("two usernames", () => user.Value = users[1]); - AddStep("three usernames", () => user.Value = users[2]); - AddStep("four usernames", () => user.Value = users[3]); - AddStep("no username", () => user.Value = users[4]); - AddStep("null user", () => user.Value = users[5]); - } - - protected override void LoadComplete() + [Test] + public void TestVisibility() { - base.LoadComplete(); + AddAssert("Is Hidden", () => container.Alpha == 0); - AddStep("online user (Angelsim)", () => - { - var request = new GetUserRequest(1777162); - request.Success += user => this.user.Value = user; - api.Queue(request); - }); + AddStep("1 username", () => container.User.Value = users[0]); + AddUntilStep("Is visible", () => container.Alpha == 1); + + AddStep("2 usernames", () => container.User.Value = users[1]); + AddUntilStep("Is visible", () => container.Alpha == 1); + + AddStep("3 usernames", () => container.User.Value = users[2]); + AddUntilStep("Is visible", () => container.Alpha == 1); + + AddStep("4 usernames", () => container.User.Value = users[3]); + AddUntilStep("Is visible", () => container.Alpha == 1); + + AddStep("No username", () => container.User.Value = users[4]); + AddUntilStep("Is hidden", () => container.Alpha == 0); + + AddStep("Null user", () => container.User.Value = users[5]); + AddUntilStep("Is hidden", () => container.Alpha == 0); } + + private static readonly User[] users = + { + new User { Id = 1, PreviousUsernames = new[] { "username1" } }, + new User { Id = 2, PreviousUsernames = new[] { "longusername", "longerusername" } }, + new User { Id = 3, PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } }, + new User { Id = 4, PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } }, + new User { Id = 5, PreviousUsernames = Array.Empty() }, + null + }; } }