mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into beatmap-listing-expanded
This commit is contained in:
157
osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs
Normal file
157
osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs
Normal file
@ -0,0 +1,157 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Comments;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneCommentEditor : ManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(CommentEditor),
|
||||
typeof(CancellableCommentEditor),
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||
|
||||
private TestCommentEditor commentEditor;
|
||||
private TestCancellableCommentEditor cancellableCommentEditor;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 800,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
commentEditor = new TestCommentEditor(),
|
||||
cancellableCommentEditor = new TestCancellableCommentEditor()
|
||||
}
|
||||
}));
|
||||
|
||||
[Test]
|
||||
public void TestCommitViaKeyboard()
|
||||
{
|
||||
AddStep("click on text box", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(commentEditor);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddStep("enter text", () => commentEditor.Current.Value = "text");
|
||||
|
||||
AddStep("press Enter", () => press(Key.Enter));
|
||||
|
||||
AddAssert("text committed", () => commentEditor.CommittedText == "text");
|
||||
AddAssert("button is loading", () => commentEditor.IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCommitViaKeyboardWhenEmpty()
|
||||
{
|
||||
AddStep("click on text box", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(commentEditor);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("press Enter", () => press(Key.Enter));
|
||||
|
||||
AddAssert("no text committed", () => commentEditor.CommittedText == null);
|
||||
AddAssert("button is not loading", () => !commentEditor.IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCommitViaButton()
|
||||
{
|
||||
AddStep("click on text box", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(commentEditor);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddStep("enter text", () => commentEditor.Current.Value = "some other text");
|
||||
|
||||
AddStep("click submit", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(commentEditor.ButtonsContainer);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("text committed", () => commentEditor.CommittedText == "some other text");
|
||||
AddAssert("button is loading", () => commentEditor.IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCancelAction()
|
||||
{
|
||||
AddStep("click cancel button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(cancellableCommentEditor.ButtonsContainer);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("cancel action fired", () => cancellableCommentEditor.Cancelled);
|
||||
}
|
||||
|
||||
private void press(Key key)
|
||||
{
|
||||
InputManager.PressKey(key);
|
||||
InputManager.ReleaseKey(key);
|
||||
}
|
||||
|
||||
private class TestCommentEditor : CommentEditor
|
||||
{
|
||||
public new Bindable<string> Current => base.Current;
|
||||
public new FillFlowContainer ButtonsContainer => base.ButtonsContainer;
|
||||
|
||||
public string CommittedText { get; private set; }
|
||||
|
||||
public TestCommentEditor()
|
||||
{
|
||||
OnCommit = onCommit;
|
||||
}
|
||||
|
||||
private void onCommit(string value)
|
||||
{
|
||||
CommittedText = value;
|
||||
Scheduler.AddDelayed(() => IsLoading = false, 1000);
|
||||
}
|
||||
|
||||
protected override string FooterText => @"Footer text. And it is pretty long. Cool.";
|
||||
protected override string CommitButtonText => @"Commit";
|
||||
protected override string TextBoxPlaceholder => @"This text box is empty";
|
||||
}
|
||||
|
||||
private class TestCancellableCommentEditor : CancellableCommentEditor
|
||||
{
|
||||
public new FillFlowContainer ButtonsContainer => base.ButtonsContainer;
|
||||
protected override string FooterText => @"Wow, another one. Sicc";
|
||||
|
||||
public bool Cancelled { get; private set; }
|
||||
|
||||
public TestCancellableCommentEditor()
|
||||
{
|
||||
OnCancel = () => Cancelled = true;
|
||||
}
|
||||
|
||||
protected override string CommitButtonText => @"Save";
|
||||
protected override string TextBoxPlaceholder => @"Multiline textboxes soon";
|
||||
}
|
||||
}
|
||||
}
|
106
osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs
Normal file
106
osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs
Normal file
@ -0,0 +1,106 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLoadingLayer : OsuTestScene
|
||||
{
|
||||
private Drawable dimContent;
|
||||
private LoadingLayer overlay;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(LoadingSpinner) };
|
||||
|
||||
private Container content;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
content = new Container
|
||||
{
|
||||
Size = new Vector2(300),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.SlateGray,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
dimContent = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.9f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText { Text = "Sample content" },
|
||||
new TriangleButton { Text = "can't puush me", Width = 200, },
|
||||
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
|
||||
}
|
||||
},
|
||||
overlay = new LoadingLayer(dimContent),
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestShowHide()
|
||||
{
|
||||
AddAssert("not visible", () => !overlay.IsPresent);
|
||||
|
||||
AddStep("show", () => overlay.Show());
|
||||
|
||||
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
||||
|
||||
AddStep("hide", () => overlay.Hide());
|
||||
|
||||
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContentRestoreOnDispose()
|
||||
{
|
||||
AddAssert("not visible", () => !overlay.IsPresent);
|
||||
|
||||
AddStep("show", () => overlay.Show());
|
||||
|
||||
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
||||
|
||||
AddStep("expire", () => overlay.Expire());
|
||||
|
||||
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLargeArea()
|
||||
{
|
||||
AddStep("show", () =>
|
||||
{
|
||||
content.RelativeSizeAxes = Axes.Both;
|
||||
content.Size = new Vector2(1);
|
||||
|
||||
overlay.Show();
|
||||
});
|
||||
|
||||
AddStep("hide", () => overlay.Hide());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,12 +8,12 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLoadingAnimation : OsuGridTestScene
|
||||
public class TestSceneLoadingSpinner : OsuGridTestScene
|
||||
{
|
||||
public TestSceneLoadingAnimation()
|
||||
public TestSceneLoadingSpinner()
|
||||
: base(2, 2)
|
||||
{
|
||||
LoadingAnimation loading;
|
||||
LoadingSpinner loading;
|
||||
|
||||
Cell(0).AddRange(new Drawable[]
|
||||
{
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
loading = new LoadingSpinner()
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
loading = new LoadingSpinner(true)
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
@ -46,14 +46,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Colour = Color4.Gray,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
loading = new LoadingSpinner()
|
||||
});
|
||||
|
||||
loading.Show();
|
||||
|
||||
Cell(3).AddRange(new Drawable[]
|
||||
{
|
||||
loading = new LoadingAnimation()
|
||||
loading = new LoadingSpinner()
|
||||
});
|
||||
|
||||
Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true);
|
@ -0,0 +1,57 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Home.Friends;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneUserListToolbar : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(UserSortTabControl),
|
||||
typeof(OverlaySortTabControl<>),
|
||||
typeof(OverlayPanelDisplayStyleControl),
|
||||
typeof(UserListToolbar),
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
public TestSceneUserListToolbar()
|
||||
{
|
||||
UserListToolbar toolbar;
|
||||
OsuSpriteText sort;
|
||||
OsuSpriteText displayStyle;
|
||||
|
||||
Add(toolbar = new UserListToolbar
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
sort = new OsuSpriteText(),
|
||||
displayStyle = new OsuSpriteText()
|
||||
}
|
||||
});
|
||||
|
||||
toolbar.SortCriteria.BindValueChanged(criteria => sort.Text = $"Criteria: {criteria.NewValue}", true);
|
||||
toolbar.DisplayStyle.BindValueChanged(style => displayStyle.Text = $"Style: {style.NewValue}", true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user