2020-12-19 01:59: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.
|
|
|
|
|
2022-03-17 18:26:42 +08:00
|
|
|
using System;
|
2020-12-19 01:59:11 +08:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
2021-01-17 04:04:28 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-01-03 16:02:15 +08:00
|
|
|
using osu.Framework.Extensions;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Framework.Graphics;
|
2022-03-17 18:05:28 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2022-03-24 13:26:31 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Framework.Platform;
|
2020-12-29 03:59:38 +08:00
|
|
|
using osu.Framework.Testing;
|
2020-12-24 16:17:45 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-12-29 03:59:38 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-11-04 17:02:44 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2022-03-17 18:26:42 +08:00
|
|
|
using osu.Game.Online.Multiplayer.Countdown;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Game.Rulesets;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
2020-12-19 01:59:11 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
using osuTK;
|
2022-03-17 18:26:42 +08:00
|
|
|
using osuTK.Input;
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2020-12-25 12:20:37 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-19 01:59:11 +08:00
|
|
|
{
|
2022-03-23 09:37:53 +08:00
|
|
|
public class TestSceneMatchStartControl : MultiplayerTestScene
|
2020-12-19 01:59:11 +08:00
|
|
|
{
|
2022-03-23 09:37:53 +08:00
|
|
|
private MatchStartControl control;
|
2021-01-05 11:00:15 +08:00
|
|
|
private BeatmapSetInfo importedSet;
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2021-01-17 04:04:28 +08:00
|
|
|
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
|
|
|
|
2020-12-19 01:59:11 +08:00
|
|
|
private BeatmapManager beatmaps;
|
|
|
|
private RulesetStore rulesets;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host, AudioManager audio)
|
|
|
|
{
|
2022-02-16 16:13:51 +08:00
|
|
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
2022-01-25 11:58:15 +08:00
|
|
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
|
|
|
Dependencies.Cache(Realm);
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public new void Setup() => Schedule(() =>
|
|
|
|
{
|
2021-06-25 14:00:10 +08:00
|
|
|
AvailabilityTracker.SelectedItem.BindTo(selectedItem);
|
|
|
|
|
2022-03-08 23:48:03 +08:00
|
|
|
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
2021-12-17 17:26:12 +08:00
|
|
|
importedSet = beatmaps.GetAllUsableBeatmapSets().First();
|
2021-01-05 11:00:15 +08:00
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
|
2022-03-08 23:48:03 +08:00
|
|
|
|
2022-02-15 22:33:26 +08:00
|
|
|
selectedItem.Value = new PlaylistItem(Beatmap.Value.BeatmapInfo)
|
2021-01-17 04:04:28 +08:00
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
RulesetID = Beatmap.Value.BeatmapInfo.Ruleset.OnlineID
|
2021-01-17 04:04:28 +08:00
|
|
|
};
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2022-03-17 18:05:28 +08:00
|
|
|
Child = new PopoverContainer
|
2020-12-19 01:59:11 +08:00
|
|
|
{
|
2022-03-17 18:05:28 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-03-23 09:37:53 +08:00
|
|
|
Child = control = new MatchStartControl
|
2022-03-17 18:05:28 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(200, 50),
|
|
|
|
}
|
|
|
|
};
|
2020-12-19 01:59:11 +08:00
|
|
|
});
|
|
|
|
|
2022-03-17 18:26:42 +08:00
|
|
|
[Test]
|
|
|
|
public void TestStartWithCountdown()
|
|
|
|
{
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
AddUntilStep("countdown button shown", () => this.ChildrenOfType<MultiplayerCountdownButton>().SingleOrDefault()?.IsPresent == true);
|
|
|
|
ClickButtonWhenEnabled<MultiplayerCountdownButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddStep("click the first countdown button", () =>
|
|
|
|
{
|
2022-03-24 13:26:31 +08:00
|
|
|
var popoverButton = this.ChildrenOfType<Popover>().Single().ChildrenOfType<OsuButton>().First();
|
2022-03-17 18:26:42 +08:00
|
|
|
InputManager.MoveMouseTo(popoverButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
AddAssert("countdown button not visible", () => !this.ChildrenOfType<MultiplayerCountdownButton>().Single().IsPresent);
|
2022-03-22 15:50:13 +08:00
|
|
|
AddStep("finish countdown", () => MultiplayerClient.FinishCountdown());
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("match started", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.WaitingForLoad);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCancelCountdown()
|
|
|
|
{
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
AddUntilStep("countdown button shown", () => this.ChildrenOfType<MultiplayerCountdownButton>().SingleOrDefault()?.IsPresent == true);
|
|
|
|
ClickButtonWhenEnabled<MultiplayerCountdownButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddStep("click the first countdown button", () =>
|
|
|
|
{
|
2022-03-24 13:26:31 +08:00
|
|
|
var popoverButton = this.ChildrenOfType<Popover>().Single().ChildrenOfType<OsuButton>().First();
|
2022-03-17 18:26:42 +08:00
|
|
|
InputManager.MoveMouseTo(popoverButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
|
2022-03-22 15:50:13 +08:00
|
|
|
AddStep("finish countdown", () => MultiplayerClient.FinishCountdown());
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("match not started", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Ready);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestReadyAndUnReadyDuringCountdown()
|
|
|
|
{
|
|
|
|
AddStep("add second user as host", () =>
|
|
|
|
{
|
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
|
|
|
MultiplayerClient.TransferHost(2);
|
|
|
|
});
|
|
|
|
|
2022-03-23 14:21:16 +08:00
|
|
|
AddStep("start with countdown", () => MultiplayerClient.SendMatchRequest(new StartMatchCountdownRequest { Duration = TimeSpan.FromMinutes(2) }).WaitSafely());
|
2022-03-17 18:26:42 +08:00
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("user is idle", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Idle);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCountdownButtonEnablementAndVisibilityWhileSpectating()
|
|
|
|
{
|
|
|
|
AddStep("set spectating", () => MultiplayerClient.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
|
|
|
|
AddUntilStep("local user is spectating", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
AddAssert("countdown button is visible", () => this.ChildrenOfType<MultiplayerCountdownButton>().Single().IsPresent);
|
|
|
|
AddAssert("countdown button disabled", () => !this.ChildrenOfType<MultiplayerCountdownButton>().Single().Enabled.Value);
|
2022-03-17 18:26:42 +08:00
|
|
|
|
|
|
|
AddStep("add second user", () => MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" }));
|
2022-03-24 13:28:38 +08:00
|
|
|
AddAssert("countdown button disabled", () => !this.ChildrenOfType<MultiplayerCountdownButton>().Single().Enabled.Value);
|
2022-03-17 18:26:42 +08:00
|
|
|
|
|
|
|
AddStep("set second user ready", () => MultiplayerClient.ChangeUserState(2, MultiplayerUserState.Ready));
|
2022-03-24 13:28:38 +08:00
|
|
|
AddAssert("countdown button enabled", () => this.ChildrenOfType<MultiplayerCountdownButton>().Single().Enabled.Value);
|
2022-03-17 18:26:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSpectatingDuringCountdownWithNoReadyUsersCancelsCountdown()
|
|
|
|
{
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
AddUntilStep("countdown button shown", () => this.ChildrenOfType<MultiplayerCountdownButton>().SingleOrDefault()?.IsPresent == true);
|
|
|
|
ClickButtonWhenEnabled<MultiplayerCountdownButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddStep("click the first countdown button", () =>
|
|
|
|
{
|
2022-03-24 13:26:31 +08:00
|
|
|
var popoverButton = this.ChildrenOfType<Popover>().Single().ChildrenOfType<OsuButton>().First();
|
2022-03-17 18:26:42 +08:00
|
|
|
InputManager.MoveMouseTo(popoverButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("set spectating", () => MultiplayerClient.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
|
|
|
|
AddUntilStep("local user is spectating", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);
|
|
|
|
|
2022-03-22 15:50:13 +08:00
|
|
|
AddStep("finish countdown", () => MultiplayerClient.FinishCountdown());
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("match not started", () => MultiplayerClient.Room?.State == MultiplayerRoomState.Open);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestReadyButtonEnabledWhileSpectatingDuringCountdown()
|
|
|
|
{
|
|
|
|
AddStep("add second user", () => MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" }));
|
|
|
|
AddStep("set second user ready", () => MultiplayerClient.ChangeUserState(2, MultiplayerUserState.Ready));
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
|
|
|
AddUntilStep("countdown button shown", () => this.ChildrenOfType<MultiplayerCountdownButton>().SingleOrDefault()?.IsPresent == true);
|
|
|
|
ClickButtonWhenEnabled<MultiplayerCountdownButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddStep("click the first countdown button", () =>
|
|
|
|
{
|
2022-03-24 13:26:31 +08:00
|
|
|
var popoverButton = this.ChildrenOfType<Popover>().Single().ChildrenOfType<OsuButton>().First();
|
2022-03-17 18:26:42 +08:00
|
|
|
InputManager.MoveMouseTo(popoverButton);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("set spectating", () => MultiplayerClient.ChangeUserState(API.LocalUser.Value.OnlineID, MultiplayerUserState.Spectating));
|
|
|
|
AddUntilStep("local user is spectating", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Spectating);
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
AddAssert("ready button enabled", () => this.ChildrenOfType<MultiplayerReadyButton>().Single().Enabled.Value);
|
2022-03-17 18:26:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBecomeHostDuringCountdownAndReady()
|
|
|
|
{
|
|
|
|
AddStep("add second user as host", () =>
|
|
|
|
{
|
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
|
|
|
MultiplayerClient.TransferHost(2);
|
|
|
|
});
|
|
|
|
|
2022-03-23 14:21:16 +08:00
|
|
|
AddStep("start countdown", () => MultiplayerClient.SendMatchRequest(new StartMatchCountdownRequest { Duration = TimeSpan.FromMinutes(1) }).WaitSafely());
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("countdown started", () => MultiplayerClient.Room?.Countdown != null);
|
|
|
|
|
|
|
|
AddStep("transfer host to local user", () => MultiplayerClient.TransferHost(API.LocalUser.Value.OnlineID));
|
|
|
|
AddUntilStep("local user is host", () => MultiplayerClient.Room?.Host?.Equals(MultiplayerClient.LocalUser) == true);
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-03-17 18:26:42 +08:00
|
|
|
AddUntilStep("local user became ready", () => MultiplayerClient.LocalUser?.State == MultiplayerUserState.Ready);
|
|
|
|
AddAssert("countdown still active", () => MultiplayerClient.Room?.Countdown != null);
|
|
|
|
}
|
|
|
|
|
2021-01-05 11:00:15 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDeletedBeatmapDisableReady()
|
|
|
|
{
|
|
|
|
OsuButton readyButton = null;
|
|
|
|
|
2022-03-08 23:48:12 +08:00
|
|
|
AddUntilStep("ensure ready button enabled", () =>
|
2021-01-05 11:00:15 +08:00
|
|
|
{
|
2022-03-23 09:37:53 +08:00
|
|
|
readyButton = control.ChildrenOfType<OsuButton>().Single();
|
2021-01-05 11:00:15 +08:00
|
|
|
return readyButton.Enabled.Value;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("delete beatmap", () => beatmaps.Delete(importedSet));
|
2022-03-08 23:48:12 +08:00
|
|
|
AddUntilStep("ready button disabled", () => !readyButton.Enabled.Value);
|
2021-01-05 11:00:15 +08:00
|
|
|
AddStep("undelete beatmap", () => beatmaps.Undelete(importedSet));
|
2022-03-08 23:48:12 +08:00
|
|
|
AddUntilStep("ready button enabled back", () => readyButton.Enabled.Value);
|
2021-01-05 11:00:15 +08:00
|
|
|
}
|
|
|
|
|
2020-12-19 01:59:11 +08:00
|
|
|
[Test]
|
|
|
|
public void TestToggleStateWhenNotHost()
|
|
|
|
{
|
|
|
|
AddStep("add second user as host", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
|
|
|
MultiplayerClient.TransferHost(2);
|
2020-12-19 01:59:11 +08:00
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is idle", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Idle);
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestToggleStateWhenHost(bool allReady)
|
|
|
|
{
|
|
|
|
AddStep("setup", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[0].UserID ?? 0);
|
2020-12-19 01:59:11 +08:00
|
|
|
|
|
|
|
if (!allReady)
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
2020-12-19 01:59:11 +08:00
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2020-12-29 03:59:38 +08:00
|
|
|
verifyGameplayStartFlow();
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBecomeHostWhileReady()
|
|
|
|
{
|
2020-12-20 17:44:41 +08:00
|
|
|
AddStep("add host", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
|
|
|
MultiplayerClient.TransferHost(2);
|
2020-12-20 17:44:41 +08:00
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddStep("make user host", () => MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[0].UserID ?? 0));
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2020-12-29 03:59:38 +08:00
|
|
|
verifyGameplayStartFlow();
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLoseHostWhileReady()
|
|
|
|
{
|
|
|
|
AddStep("setup", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[0].UserID ?? 0);
|
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = 2, Username = "Another user" });
|
2020-12-19 01:59:11 +08:00
|
|
|
});
|
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
|
2021-12-20 16:46:20 +08:00
|
|
|
|
2022-02-16 08:43:28 +08:00
|
|
|
AddStep("transfer host", () => MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[1].UserID ?? 0));
|
2020-12-19 01:59:11 +08:00
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is idle (match not started)", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Idle);
|
2022-03-23 14:40:50 +08:00
|
|
|
AddUntilStep("ready button enabled", () => control.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
|
2020-12-24 16:17:45 +08:00
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestManyUsersChangingState(bool isHost)
|
|
|
|
{
|
|
|
|
const int users = 10;
|
|
|
|
AddStep("setup", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.TransferHost(MultiplayerClient.Room?.Users[0].UserID ?? 0);
|
2020-12-24 16:17:45 +08:00
|
|
|
for (int i = 0; i < users; i++)
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.AddUser(new APIUser { Id = i, Username = "Another user" });
|
2020-12-24 16:17:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!isHost)
|
2022-02-16 08:43:28 +08:00
|
|
|
AddStep("transfer host", () => MultiplayerClient.TransferHost(2));
|
2020-12-24 16:17:45 +08:00
|
|
|
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2020-12-24 16:17:45 +08:00
|
|
|
|
|
|
|
AddRepeatStep("change user ready state", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.ChangeUserState(RNG.Next(0, users), RNG.NextBool() ? MultiplayerUserState.Ready : MultiplayerUserState.Idle);
|
2020-12-24 16:17:45 +08:00
|
|
|
}, 20);
|
|
|
|
|
|
|
|
AddRepeatStep("ready all users", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
var nextUnready = MultiplayerClient.Room?.Users.FirstOrDefault(c => c.State == MultiplayerUserState.Idle);
|
2020-12-24 16:17:45 +08:00
|
|
|
if (nextUnready != null)
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.ChangeUserState(nextUnready.UserID, MultiplayerUserState.Ready);
|
2020-12-24 16:17:45 +08:00
|
|
|
}, users);
|
|
|
|
}
|
|
|
|
|
2020-12-29 03:59:38 +08:00
|
|
|
private void verifyGameplayStartFlow()
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user is ready", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.Ready);
|
2022-03-24 13:28:38 +08:00
|
|
|
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
2022-02-16 08:43:28 +08:00
|
|
|
AddUntilStep("user waiting for load", () => MultiplayerClient.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
2020-12-29 03:59:38 +08:00
|
|
|
|
2021-04-08 15:29:11 +08:00
|
|
|
AddStep("finish gameplay", () =>
|
|
|
|
{
|
2022-02-16 08:43:28 +08:00
|
|
|
MultiplayerClient.ChangeUserState(MultiplayerClient.Room?.Users[0].UserID ?? 0, MultiplayerUserState.Loaded);
|
|
|
|
MultiplayerClient.ChangeUserState(MultiplayerClient.Room?.Users[0].UserID ?? 0, MultiplayerUserState.FinishedPlay);
|
2021-04-08 15:29:11 +08:00
|
|
|
});
|
|
|
|
|
2022-03-23 09:37:53 +08:00
|
|
|
AddUntilStep("ready button enabled", () => control.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
2020-12-29 03:59:38 +08:00
|
|
|
}
|
2020-12-19 01:59:11 +08:00
|
|
|
}
|
|
|
|
}
|