2021-11-01 17:52:57 +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.
|
|
|
|
|
2021-11-01 18:25:47 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
2021-11-19 13:46:53 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-11-01 18:25:47 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osuTK.Input;
|
2021-11-01 17:52:57 +08:00
|
|
|
|
2021-11-19 14:43:11 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2021-11-01 17:52:57 +08:00
|
|
|
{
|
2021-11-19 17:28:43 +08:00
|
|
|
public class TestSceneAllPlayersQueueMode : QueueModeTestScene
|
2021-11-01 17:52:57 +08:00
|
|
|
{
|
2021-11-19 17:28:43 +08:00
|
|
|
protected override QueueMode Mode => QueueMode.AllPlayers;
|
2021-11-01 18:25:47 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFirstItemSelectedByDefault()
|
|
|
|
{
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("first item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
2021-11-01 18:25:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestItemAddedToTheEndOfQueue()
|
|
|
|
{
|
|
|
|
addItem(() => OtherBeatmap);
|
|
|
|
AddAssert("playlist has 2 items", () => Client.APIRoom?.Playlist.Count == 2);
|
|
|
|
|
|
|
|
addItem(() => InitialBeatmap);
|
|
|
|
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
|
|
|
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("first item still selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
2021-11-01 18:25:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSingleItemExpiredAfterGameplay()
|
|
|
|
{
|
|
|
|
RunGameplay();
|
|
|
|
|
|
|
|
AddAssert("playlist has only one item", () => Client.APIRoom?.Playlist.Count == 1);
|
|
|
|
AddAssert("playlist item is expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("last item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[0].ID);
|
2021-11-01 18:25:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNextItemSelectedAfterGameplayFinish()
|
|
|
|
{
|
|
|
|
addItem(() => OtherBeatmap);
|
|
|
|
addItem(() => InitialBeatmap);
|
|
|
|
|
|
|
|
RunGameplay();
|
|
|
|
|
|
|
|
AddAssert("first item expired", () => Client.APIRoom?.Playlist[0].Expired == true);
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[1].ID);
|
2021-11-01 18:25:47 +08:00
|
|
|
|
|
|
|
RunGameplay();
|
|
|
|
|
|
|
|
AddAssert("second item expired", () => Client.APIRoom?.Playlist[1].Expired == true);
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("next item selected", () => Client.Room?.Settings.PlaylistItemId == Client.APIRoom?.Playlist[2].ID);
|
2021-11-01 18:25:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2021-11-22 10:20:18 +08:00
|
|
|
public void TestItemsNotClearedWhenSwitchToHostOnlyMode()
|
2021-11-01 18:25:47 +08:00
|
|
|
{
|
|
|
|
addItem(() => OtherBeatmap);
|
|
|
|
addItem(() => InitialBeatmap);
|
|
|
|
|
|
|
|
// Move to the "other" beatmap.
|
|
|
|
RunGameplay();
|
|
|
|
|
2021-11-16 13:53:10 +08:00
|
|
|
AddStep("change queue mode", () => Client.ChangeSettings(queueMode: QueueMode.HostOnly));
|
2021-11-22 10:20:18 +08:00
|
|
|
AddAssert("playlist has 3 items", () => Client.APIRoom?.Playlist.Count == 3);
|
2021-12-10 19:08:59 +08:00
|
|
|
AddAssert("item 2 is not expired", () => Client.APIRoom?.Playlist[1].Expired == false);
|
|
|
|
AddAssert("current item is the other beatmap", () => Client.Room?.Settings.PlaylistItemId == 2);
|
2021-11-01 18:25:47 +08:00
|
|
|
}
|
|
|
|
|
2021-11-24 18:53:21 +08:00
|
|
|
[Test]
|
|
|
|
public void TestCorrectItemSelectedAfterNewItemAdded()
|
|
|
|
{
|
|
|
|
addItem(() => OtherBeatmap);
|
|
|
|
AddAssert("selected beatmap is initial beatmap", () => Beatmap.Value.BeatmapInfo.OnlineID == InitialBeatmap.OnlineID);
|
|
|
|
}
|
|
|
|
|
2021-11-01 18:25:47 +08:00
|
|
|
private void addItem(Func<BeatmapInfo> beatmap)
|
|
|
|
{
|
2021-12-10 00:15:15 +08:00
|
|
|
AddStep("click add button", () =>
|
2021-11-01 18:25:47 +08:00
|
|
|
{
|
2021-12-10 00:15:15 +08:00
|
|
|
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSubScreen.AddItemButton>().Single());
|
2021-11-01 18:25:47 +08:00
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
2021-11-25 20:11:13 +08:00
|
|
|
AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.BeatmapSetsLoaded);
|
2021-11-01 18:25:47 +08:00
|
|
|
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(beatmap()));
|
|
|
|
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
|
|
|
}
|
2021-11-01 17:52:57 +08:00
|
|
|
}
|
|
|
|
}
|