1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 07:57:25 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs

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

102 lines
4.3 KiB
C#
Raw Normal View History

// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2021-05-20 04:58:41 +08:00
using System.Linq;
2020-12-25 21:54:21 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2021-05-20 04:58:41 +08:00
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
2021-05-20 04:58:41 +08:00
using osu.Game.Overlays.AccountCreation;
using osu.Game.Overlays.Settings;
using osu.Game.Users;
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Online
{
public partial class TestSceneAccountCreationOverlay : OsuTestScene
{
2019-08-01 03:43:05 +08:00
private readonly Container userPanelArea;
2020-12-25 21:54:21 +08:00
private readonly AccountCreationOverlay accountCreation;
private IBindable<APIUser> localUser;
public TestSceneAccountCreationOverlay()
{
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]
private void load()
2019-08-01 03:43:05 +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());
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);
2021-08-04 16:27:44 +08:00
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().TriggerClick());
AddUntilStep("warning screen is present", () => accountCreation.ChildrenOfType<ScreenWarning>().SingleOrDefault()?.IsPresent == true);
2021-05-20 04:58:41 +08:00
AddStep("log back in", () =>
{
API.Login("dummy", "password");
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
});
2020-12-25 21:54:21 +08:00
AddUntilStep("overlay is hidden", () => accountCreation.State.Value == Visibility.Hidden);
}
[Test]
public void TestFullFlow()
{
AddStep("log out", () => API.Logout());
AddStep("show manually", () => accountCreation.Show());
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().TriggerClick());
AddUntilStep("warning screen is present", () => accountCreation.ChildrenOfType<ScreenWarning>().SingleOrDefault()?.IsPresent == true);
AddStep("proceed", () => accountCreation.ChildrenOfType<DangerousSettingsButton>().Single().TriggerClick());
AddUntilStep("entry screen is present", () => accountCreation.ChildrenOfType<ScreenEntry>().SingleOrDefault()?.IsPresent == true);
AddStep("input details", () =>
{
var entryScreen = accountCreation.ChildrenOfType<ScreenEntry>().Single();
entryScreen.ChildrenOfType<OsuTextBox>().ElementAt(0).Text = "new_user";
entryScreen.ChildrenOfType<OsuTextBox>().ElementAt(1).Text = "new.user@fake.mail";
entryScreen.ChildrenOfType<OsuTextBox>().ElementAt(2).Text = "password";
});
AddStep("click button", () => accountCreation.ChildrenOfType<ScreenEntry>().Single()
.ChildrenOfType<SettingsButton>().Single().TriggerClick());
AddUntilStep("verification screen is present", () => accountCreation.ChildrenOfType<ScreenEmailVerification>().SingleOrDefault()?.IsPresent == true);
AddStep("verify", () => ((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh"));
AddUntilStep("overlay is hidden", () => accountCreation.State.Value == Visibility.Hidden);
}
}
}