1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs

56 lines
1.8 KiB
C#
Raw Normal View History

2019-05-31 04:07:04 +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.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-05-31 04:07:04 +08:00
using osu.Framework.Graphics;
2019-10-13 19:43:30 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Framework.Allocation;
2020-07-30 09:51:09 +08:00
using osu.Game.Overlays;
2019-05-31 04:07:04 +08:00
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneShowMoreButton : OsuTestScene
{
2020-07-30 09:51:09 +08:00
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2019-05-31 04:07:04 +08:00
public TestSceneShowMoreButton()
{
2020-07-30 09:51:09 +08:00
ShowMoreButton button = null;
2019-06-04 09:26:35 +08:00
int fireCount = 0;
2019-05-31 04:22:08 +08:00
2020-07-30 09:51:09 +08:00
Add(button = new ShowMoreButton
2019-05-31 04:07:04 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2019-06-04 09:26:35 +08:00
Action = () =>
{
fireCount++;
// ReSharper disable once AccessToModifiedClosure
// ReSharper disable once PossibleNullReferenceException
Scheduler.AddDelayed(() => button.IsLoading = false, 2000);
}
2019-05-31 04:07:04 +08:00
});
2021-08-04 16:27:44 +08:00
AddStep("click button", () => button.TriggerClick());
2019-06-04 09:26:35 +08:00
AddAssert("action fired once", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
2021-08-04 16:27:44 +08:00
AddStep("click button", () => button.TriggerClick());
2019-06-04 09:26:35 +08:00
AddAssert("action not fired", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddUntilStep("wait for loaded", () => !button.IsLoading);
2021-08-04 16:27:44 +08:00
AddStep("click button", () => button.TriggerClick());
2019-06-04 09:26:35 +08:00
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);
2019-05-31 04:07:04 +08:00
}
}
}