osu/osu.Game.Tests/Visual/Multiplayer/TestSceneHostOnlyQueueMode.cs

95 lines
3.7 KiB
C#
Raw Normal View History

2021-10-29 04:56:07 +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.
2021-10-29 06:44:48 +00:00
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
2021-11-19 05:46:53 +00:00
using osu.Game.Online.Multiplayer;
2021-10-29 06:44:48 +00:00
using osu.Game.Screens.OnlinePlay.Multiplayer;
using osuTK.Input;
2021-10-29 04:56:07 +00:00
2021-11-19 06:43:11 +00:00
namespace osu.Game.Tests.Visual.Multiplayer
2021-10-29 04:56:07 +00:00
{
2021-10-29 07:45:30 +00:00
public class TestSceneHostOnlyQueueMode : QueueModeTestScene
2021-10-29 04:56:07 +00:00
{
2021-11-16 05:53:10 +00:00
protected override QueueMode Mode => QueueMode.HostOnly;
2021-10-29 06:44:48 +00:00
2021-11-01 09:55:42 +00:00
[Test]
public void TestFirstItemSelectedByDefault()
{
AddAssert("first item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
2021-11-01 09:55:42 +00:00
}
2021-10-29 06:44:48 +00:00
[Test]
2021-10-29 07:44:39 +00:00
public void TestItemStillSelectedAfterChangeToSameBeatmap()
{
selectNewItem(() => InitialBeatmap);
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
2021-10-29 07:44:39 +00:00
}
[Test]
public void TestItemStillSelectedAfterChangeToOtherBeatmap()
2021-10-29 06:44:48 +00:00
{
selectNewItem(() => OtherBeatmap);
2021-10-29 07:44:39 +00:00
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[0].ID);
2021-10-29 06:44:48 +00:00
}
[Test]
public void TestNewItemCreatedAfterGameplayFinished()
{
RunGameplay();
AddAssert("playlist contains two items", () => Client.APIRoom?.Playlist.Count == 2);
AddAssert("first playlist item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
AddAssert("second playlist item not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
AddAssert("second playlist item selected", () => Client.CurrentMatchPlayingItem.Value?.ID == Client.APIRoom?.Playlist[1].ID);
2021-10-29 06:44:48 +00:00
}
[Test]
public void TestOnlyLastItemChangedAfterGameplayFinished()
{
RunGameplay();
2021-11-05 06:57:32 +00:00
IBeatmapInfo firstBeatmap = null;
2021-10-29 06:44:48 +00:00
AddStep("get first playlist item beatmap", () => firstBeatmap = Client.APIRoom?.Playlist[0].Beatmap.Value);
selectNewItem(() => OtherBeatmap);
AddAssert("first playlist item hasn't changed", () => Client.APIRoom?.Playlist[0].Beatmap.Value == firstBeatmap);
AddAssert("second playlist item changed", () => Client.APIRoom?.Playlist[1].Beatmap.Value != firstBeatmap);
}
[Test]
public void TestSettingsUpdatedWhenChangingQueueMode()
{
AddStep("change queue mode", () => Client.ChangeSettings(new MultiplayerRoomSettings
{
QueueMode = QueueMode.AllPlayers
}));
AddUntilStep("api room updated", () => Client.APIRoom?.QueueMode.Value == QueueMode.AllPlayers);
}
2021-10-29 06:44:48 +00:00
private void selectNewItem(Func<BeatmapInfo> beatmap)
{
AddStep("click edit button", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen>().Single().AddOrEditPlaylistButton);
InputManager.Click(MouseButton.Left);
});
2021-11-25 12:11:13 +00:00
AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.BeatmapSetsLoaded);
2021-10-29 06:44:48 +00:00
2021-10-29 07:44:39 +00:00
BeatmapInfo otherBeatmap = null;
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
2021-10-29 06:44:48 +00:00
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
2021-10-29 07:44:39 +00:00
AddUntilStep("selected item is new beatmap", () => Client.CurrentMatchPlayingItem.Value?.Beatmap.Value?.OnlineID == otherBeatmap.OnlineID);
2021-10-29 06:44:48 +00:00
}
2021-10-29 04:56:07 +00:00
}
}