mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Fix spinner presense check & field click
This commit is contained in:
@ -1,12 +1,17 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Comments;
|
using osu.Game.Overlays.Comments;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -44,15 +49,16 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("click on text box", () =>
|
AddStep("click on text box", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(commentEditor);
|
InputManager.MoveMouseTo(commentEditor.ChildrenOfType<TextBox>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddStep("enter text", () => commentEditor.Current.Value = "text");
|
AddStep("enter text", () => commentEditor.Current.Value = "text");
|
||||||
|
|
||||||
AddStep("press Enter", () => InputManager.Key(Key.Enter));
|
AddStep("press Enter", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddUntilStep("button is loading", () => commentEditor.ButtonLoading);
|
||||||
AddAssert("text committed", () => commentEditor.CommittedText == "text");
|
AddAssert("text committed", () => commentEditor.CommittedText == "text");
|
||||||
AddAssert("button is loading", () => commentEditor.IsSubmitting);
|
AddUntilStep("button is not loading", () => !commentEditor.ButtonLoading);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -60,14 +66,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("click on text box", () =>
|
AddStep("click on text box", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(commentEditor);
|
InputManager.MoveMouseTo(commentEditor.ChildrenOfType<TextBox>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("press Enter", () => InputManager.Key(Key.Enter));
|
AddStep("press Enter", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddAssert("button is not loading", () => !commentEditor.ButtonLoading);
|
||||||
AddAssert("no text committed", () => commentEditor.CommittedText.Length == 0);
|
AddAssert("no text committed", () => commentEditor.CommittedText.Length == 0);
|
||||||
AddAssert("button is not loading", () => !commentEditor.IsSubmitting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -75,7 +81,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("click on text box", () =>
|
AddStep("click on text box", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(commentEditor);
|
InputManager.MoveMouseTo(commentEditor.ChildrenOfType<TextBox>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddStep("enter text", () => commentEditor.Current.Value = "some other text");
|
AddStep("enter text", () => commentEditor.Current.Value = "some other text");
|
||||||
@ -86,8 +92,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("button is loading", () => commentEditor.ButtonLoading);
|
||||||
AddAssert("text committed", () => commentEditor.CommittedText == "some other text");
|
AddAssert("text committed", () => commentEditor.CommittedText == "some other text");
|
||||||
AddAssert("button is loading", () => commentEditor.IsSubmitting);
|
AddUntilStep("button is not loading", () => !commentEditor.ButtonLoading);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -109,6 +116,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
public string CommittedText { get; private set; } = string.Empty;
|
public string CommittedText { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public bool ButtonLoading => CommitButton.ChildrenOfType<LoadingSpinner>().Single().IsPresent && !CommitButton.ChildrenOfType<SpriteText>().Single().IsPresent;
|
||||||
|
|
||||||
public TestCommentEditor()
|
public TestCommentEditor()
|
||||||
{
|
{
|
||||||
OnCommit = onCommit;
|
OnCommit = onCommit;
|
||||||
|
@ -25,11 +25,6 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
public Action<string>? OnCommit;
|
public Action<string>? OnCommit;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether editor is waiting for submit action to complete.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSubmitting => CommitButton.IsLoadingSpinnerShown;
|
|
||||||
|
|
||||||
protected abstract LocalisableString FooterText { get; }
|
protected abstract LocalisableString FooterText { get; }
|
||||||
|
|
||||||
protected abstract LocalisableString CommitButtonText { get; }
|
protected abstract LocalisableString CommitButtonText { get; }
|
||||||
|
Reference in New Issue
Block a user