2019-01-24 16:43:03 +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.
|
2018-12-04 19:33:29 +08:00
|
|
|
|
2021-05-20 04:58:41 +08:00
|
|
|
using System.Linq;
|
2020-12-25 21:54:21 +08:00
|
|
|
using NUnit.Framework;
|
2019-03-22 10:55:35 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-09-13 16:15:33 +08:00
|
|
|
using osu.Framework.Bindables;
|
2019-03-22 10:55:35 +08:00
|
|
|
using osu.Framework.Graphics;
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-05-20 04:58:41 +08:00
|
|
|
using osu.Framework.Testing;
|
2021-11-04 17:02:44 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-05-20 04:58:41 +08:00
|
|
|
using osu.Game.Overlays.AccountCreation;
|
|
|
|
using osu.Game.Overlays.Settings;
|
2019-03-22 10:55:35 +08:00
|
|
|
using osu.Game.Users;
|
2018-12-04 19:33:29 +08:00
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public class TestSceneAccountCreationOverlay : OsuTestScene
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
2019-08-01 03:43:05 +08:00
|
|
|
private readonly Container userPanelArea;
|
2020-12-25 21:54:21 +08:00
|
|
|
private readonly AccountCreationOverlay accountCreation;
|
2019-03-22 10:55:35 +08:00
|
|
|
|
2021-11-04 17:02:44 +08:00
|
|
|
private IBindable<APIUser> localUser;
|
2019-09-13 16:15:33 +08:00
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
public TestSceneAccountCreationOverlay()
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
2019-03-22 10:55:35 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
accountCreation = new AccountCreationOverlay(),
|
|
|
|
userPanelArea = new Container
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
},
|
|
|
|
};
|
2019-08-01 03:43:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-09-13 16:15:33 +08:00
|
|
|
private void load()
|
2019-08-01 03:43:05 +08:00
|
|
|
{
|
2019-09-13 16:15:33 +08:00
|
|
|
localUser = API.LocalUser.GetBoundCopy();
|
2020-03-04 19:58:15 +08:00
|
|
|
localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue) { Width = 200 }; }, true);
|
2020-12-25 21:54:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestOverlayVisibility()
|
|
|
|
{
|
|
|
|
AddStep("start hidden", () => accountCreation.Hide());
|
2021-05-20 12:19:00 +08:00
|
|
|
AddStep("log out", () => API.Logout());
|
2020-12-25 21:54:21 +08:00
|
|
|
|
|
|
|
AddStep("show manually", () => accountCreation.Show());
|
|
|
|
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
|
2018-12-04 19:33:29 +08:00
|
|
|
|
2021-08-04 16:27:44 +08:00
|
|
|
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
2021-05-20 12:19:00 +08:00
|
|
|
AddUntilStep("warning screen is present", () => accountCreation.ChildrenOfType<ScreenWarning>().SingleOrDefault()?.IsPresent == true);
|
2021-05-20 04:58:41 +08:00
|
|
|
|
2020-12-25 21:54:21 +08:00
|
|
|
AddStep("log back in", () => API.Login("dummy", "password"));
|
|
|
|
AddUntilStep("overlay is hidden", () => accountCreation.State.Value == Visibility.Hidden);
|
2018-12-04 19:33:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|