osu/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs

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