2021-08-17 05:39:08 +00: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 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2021-08-17 05:39:08 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2021-11-12 16:53:19 +00:00
|
|
|
using osu.Framework.Screens;
|
2021-08-17 05:39:08 +00:00
|
|
|
using osu.Framework.Testing;
|
2021-11-12 16:53:19 +00:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-12-10 11:08:59 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-08-17 05:39:08 +00:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
2023-10-10 08:55:35 +00:00
|
|
|
using osu.Game.Screens.Play;
|
2021-08-17 05:39:08 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
{
|
|
|
|
public partial class TestSceneMultiplayerPlayer : MultiplayerTestScene
|
|
|
|
{
|
|
|
|
private MultiplayerPlayer player;
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddStep("set beatmap", () =>
|
|
|
|
{
|
|
|
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
|
|
|
});
|
|
|
|
|
2023-10-10 08:55:35 +00:00
|
|
|
AddStep("Start track playing", () =>
|
|
|
|
{
|
|
|
|
Beatmap.Value.Track.Start();
|
|
|
|
});
|
|
|
|
|
2021-08-17 05:39:08 +00:00
|
|
|
AddStep("initialise gameplay", () =>
|
|
|
|
{
|
2022-07-01 10:46:46 +00:00
|
|
|
Stack.Push(player = new MultiplayerPlayer(MultiplayerClient.ServerAPIRoom, new PlaylistItem(Beatmap.Value.BeatmapInfo)
|
2021-12-10 11:08:59 +00:00
|
|
|
{
|
2022-02-15 07:01:14 +00:00
|
|
|
RulesetID = Beatmap.Value.BeatmapInfo.Ruleset.OnlineID,
|
2022-07-01 09:58:22 +00:00
|
|
|
}, MultiplayerClient.ServerRoom?.Users.ToArray()));
|
2021-08-17 05:39:08 +00:00
|
|
|
});
|
2021-11-12 16:53:19 +00:00
|
|
|
|
|
|
|
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen() && player.IsLoaded);
|
2023-10-10 08:55:35 +00:00
|
|
|
|
|
|
|
AddAssert("gameplay clock is paused", () => player.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value);
|
|
|
|
AddAssert("gameplay clock is not running", () => !player.ChildrenOfType<GameplayClockContainer>().Single().IsRunning);
|
|
|
|
|
2022-04-21 13:37:26 +00:00
|
|
|
AddStep("start gameplay", () => ((IMultiplayerClient)MultiplayerClient).GameplayStarted());
|
2023-10-10 08:55:35 +00:00
|
|
|
|
|
|
|
AddUntilStep("gameplay clock is not paused", () => !player.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value);
|
|
|
|
AddAssert("gameplay clock is running", () => player.ChildrenOfType<GameplayClockContainer>().Single().IsRunning);
|
2021-08-17 05:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestGameplay()
|
|
|
|
{
|
|
|
|
AddUntilStep("wait for gameplay start", () => player.LocalUserPlaying.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|