2020-12-29 04:39:11 +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.
|
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
using System;
|
2020-12-29 04:39:11 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
{
|
|
|
|
public class TestSceneCreateMultiplayerMatchButton : MultiplayerTestScene
|
|
|
|
{
|
|
|
|
private CreateMultiplayerMatchButton button;
|
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
AddStep("create button", () => Child = button = new CreateMultiplayerMatchButton
|
|
|
|
{
|
|
|
|
Width = 200,
|
|
|
|
Height = 100,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestButtonEnableStateChanges()
|
|
|
|
{
|
2020-12-29 15:20:43 +08:00
|
|
|
IDisposable joiningRoomOperation = null;
|
|
|
|
|
2020-12-29 04:39:11 +08:00
|
|
|
assertButtonEnableState(true);
|
|
|
|
|
2021-01-10 04:38:20 +08:00
|
|
|
AddStep("begin joining room", () => joiningRoomOperation = OngoingOperationTracker.BeginOperation());
|
2020-12-29 04:39:11 +08:00
|
|
|
assertButtonEnableState(false);
|
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
AddStep("end joining room", () => joiningRoomOperation.Dispose());
|
2020-12-29 04:39:11 +08:00
|
|
|
assertButtonEnableState(true);
|
|
|
|
|
|
|
|
AddStep("disconnect client", () => Client.Disconnect());
|
|
|
|
assertButtonEnableState(false);
|
|
|
|
|
|
|
|
AddStep("re-connect client", () => Client.Connect());
|
|
|
|
assertButtonEnableState(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void assertButtonEnableState(bool enabled)
|
|
|
|
=> AddAssert($"button {(enabled ? "enabled" : "disabled")}", () => button.Enabled.Value == enabled);
|
|
|
|
}
|
|
|
|
}
|