1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 16:57:25 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs

56 lines
1.7 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.
using osu.Game.Overlays.Profile.Sections;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneShowMoreButton : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ShowMoreButton),
};
public TestSceneShowMoreButton()
{
2019-06-04 09:26:35 +08:00
ShowMoreButton button = null;
int fireCount = 0;
2019-05-31 04:22:08 +08:00
2019-05-31 04:07:04 +08:00
Add(button = new ShowMoreButton
{
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
});
2019-06-04 09:26:35 +08:00
AddStep("click button", () => button.Click());
AddAssert("action fired once", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddStep("click button", () => button.Click());
AddAssert("action not fired", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddUntilStep("wait for loaded", () => !button.IsLoading);
AddStep("click button", () => button.Click());
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);
2019-05-31 04:07:04 +08:00
}
}
}