2021-09-17 16:36:17 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-10-04 14:40:24 +08:00
|
|
|
using osu.Game.Online.API;
|
2021-09-17 16:36:17 +08:00
|
|
|
using osu.Game.Overlays.Login;
|
2022-01-21 20:58:30 +08:00
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
using osuTK.Input;
|
2021-09-17 16:36:17 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Menus
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneLoginPanel : OsuManualInputManagerTestScene
|
|
|
|
{
|
|
|
|
private LoginPanel loginPanel;
|
2022-01-21 20:58:30 +08:00
|
|
|
private int hideCount;
|
2021-09-17 16:36:17 +08:00
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("create login dialog", () =>
|
|
|
|
{
|
|
|
|
Add(loginPanel = new LoginPanel
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Width = 0.5f,
|
2022-01-21 20:58:30 +08:00
|
|
|
RequestHide = () => hideCount++,
|
2021-09-17 16:36:17 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2021-10-04 14:40:24 +08:00
|
|
|
public void TestLoginSuccess()
|
2021-09-17 16:36:17 +08:00
|
|
|
{
|
|
|
|
AddStep("logout", () => API.Logout());
|
|
|
|
|
|
|
|
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
|
|
|
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
|
|
|
}
|
2021-10-04 14:40:24 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLoginFailure()
|
|
|
|
{
|
|
|
|
AddStep("logout", () =>
|
|
|
|
{
|
|
|
|
API.Logout();
|
|
|
|
((DummyAPIAccess)API).FailNextLogin();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
|
|
|
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
|
|
|
}
|
2022-01-21 20:58:30 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestClickingOnFlagClosesPanel()
|
|
|
|
{
|
|
|
|
AddStep("reset hide count", () => hideCount = 0);
|
|
|
|
|
|
|
|
AddStep("logout", () => API.Logout());
|
|
|
|
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
|
|
|
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
|
|
|
|
|
|
|
AddStep("click on flag", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(loginPanel.ChildrenOfType<UpdateableFlag>().First());
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
AddAssert("hide requested", () => hideCount == 1);
|
|
|
|
}
|
2021-09-17 16:36:17 +08:00
|
|
|
}
|
|
|
|
}
|