1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 00:02:55 +08:00

Merge branch 'master' into fix-skin-layout-editor-crash

This commit is contained in:
Dean Herbert 2021-10-21 13:05:05 +09:00
commit 7a1be99999

View File

@ -3,11 +3,7 @@
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; 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.Overlays.Profile.Header.Components;
using osu.Game.Users; using osu.Game.Users;
@ -16,48 +12,50 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture] [TestFixture]
public class TestSceneUserProfilePreviousUsernames : OsuTestScene public class TestSceneUserProfilePreviousUsernames : OsuTestScene
{ {
[Resolved] private PreviousUsernames container;
private IAPIProvider api { get; set; }
private readonly Bindable<User> user = new Bindable<User>(); [SetUp]
public void SetUp() => Schedule(() =>
public TestSceneUserProfilePreviousUsernames()
{ {
Child = new PreviousUsernames Child = container = new PreviousUsernames
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
User = { BindTarget = user },
}; };
});
User[] users = [Test]
public void TestVisibility()
{ {
new User { PreviousUsernames = new[] { "username1" } }, AddAssert("Is Hidden", () => container.Alpha == 0);
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } }, AddStep("1 username", () => container.User.Value = users[0]);
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } }, AddUntilStep("Is visible", () => container.Alpha == 1);
new User { PreviousUsernames = Array.Empty<string>() },
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<string>() },
null 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()
{
base.LoadComplete();
AddStep("online user (Angelsim)", () =>
{
var request = new GetUserRequest(1777162);
request.Success += user => this.user.Value = user;
api.Queue(request);
});
}
} }
} }