mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Remove now unnecessary test
This commit is contained in:
parent
806ca5d4de
commit
10932dd282
@ -1,216 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMultiplayerQueueList : MultiplayerTestScene
|
||||
{
|
||||
private MultiplayerQueueList list;
|
||||
private int currentItemId;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = list = new MultiplayerQueueList
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.4f,
|
||||
Height = 0.6f
|
||||
};
|
||||
});
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
// Not inside a step since this is used to affect steps added by the current test.
|
||||
currentItemId = 0;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemsAddedToEndInHostOnlyMode()
|
||||
{
|
||||
changeQueueModeStep(QueueMode.HostOnly);
|
||||
|
||||
// User 1.
|
||||
|
||||
PlaylistItem item1 = addItemStep(1);
|
||||
assertPositionStep(item1, 0);
|
||||
|
||||
PlaylistItem item2 = addItemStep(1);
|
||||
assertPositionStep(item2, 1);
|
||||
|
||||
// User 2.
|
||||
|
||||
PlaylistItem item3 = addItemStep(2);
|
||||
assertPositionStep(item3, 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemsAddedToEndInAllPlayersMode()
|
||||
{
|
||||
changeQueueModeStep(QueueMode.AllPlayers);
|
||||
|
||||
// User 1.
|
||||
|
||||
PlaylistItem item1 = addItemStep(1);
|
||||
assertPositionStep(item1, 0);
|
||||
|
||||
PlaylistItem item2 = addItemStep(1);
|
||||
assertPositionStep(item2, 1);
|
||||
|
||||
// User 2.
|
||||
|
||||
PlaylistItem item3 = addItemStep(2);
|
||||
assertPositionStep(item3, 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemsInsertedInCorrectPositionInRoundRobinMode()
|
||||
{
|
||||
changeQueueModeStep(QueueMode.AllPlayersRoundRobin);
|
||||
|
||||
// User 1.
|
||||
|
||||
PlaylistItem item1 = addItemStep(1);
|
||||
assertPositionStep(item1, 0);
|
||||
|
||||
PlaylistItem item2 = addItemStep(1);
|
||||
assertPositionStep(item2, 1);
|
||||
|
||||
// User 2.
|
||||
|
||||
PlaylistItem item3 = addItemStep(2);
|
||||
assertPositionStep(item3, 1);
|
||||
assertPositionStep(item2, 2);
|
||||
|
||||
PlaylistItem item4 = addItemStep(2);
|
||||
assertPositionStep(item4, 3);
|
||||
|
||||
PlaylistItem item5 = addItemStep(2);
|
||||
assertPositionStep(item5, 4);
|
||||
|
||||
// User 1.
|
||||
|
||||
// This item is added to the end rather than injected between item4 and item5, since both users have an equal number
|
||||
// of added items at this point and this user was the last of the two to add an item.
|
||||
PlaylistItem item6 = addItemStep(1);
|
||||
assertPositionStep(item6, 5);
|
||||
|
||||
// User 3.
|
||||
|
||||
PlaylistItem item7 = addItemStep(3);
|
||||
assertPositionStep(item7, 2);
|
||||
|
||||
PlaylistItem item8 = addItemStep(3);
|
||||
assertPositionStep(item8, 5);
|
||||
|
||||
PlaylistItem item9 = addItemStep(3);
|
||||
assertPositionStep(item9, 8);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemsReorderedWhenQueueModeChanged()
|
||||
{
|
||||
changeQueueModeStep(QueueMode.AllPlayers);
|
||||
|
||||
var items = new List<PlaylistItem>();
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
items.Add(addItemStep(i <= 3 ? 1 : 2));
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
assertPositionStep(items[i], i);
|
||||
|
||||
changeQueueModeStep(QueueMode.AllPlayersRoundRobin);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
assertPositionStep(items[i], i * 2); // Items by user 1.
|
||||
assertPositionStep(items[i + 4], i * 2 + 1); // Items by user 2.
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreviouslyExpiredItemsConsideredInRoundRobinMode()
|
||||
{
|
||||
changeQueueModeStep(QueueMode.AllPlayersRoundRobin);
|
||||
|
||||
// User 1.
|
||||
|
||||
addItemStep(1, true);
|
||||
addItemStep(1, true);
|
||||
PlaylistItem item3 = addItemStep(1);
|
||||
PlaylistItem item4 = addItemStep(1);
|
||||
|
||||
// User2.
|
||||
|
||||
PlaylistItem item5 = addItemStep(2);
|
||||
PlaylistItem item6 = addItemStep(2);
|
||||
|
||||
assertPositionStep(item5, 0);
|
||||
assertPositionStep(item6, 1);
|
||||
assertPositionStep(item3, 2);
|
||||
assertPositionStep(item4, 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a step to create a new playlist item.
|
||||
/// </summary>
|
||||
/// <param name="ownerId">The item owner.</param>
|
||||
/// <param name="expired">Whether the item should be added in an expired state.</param>
|
||||
/// <returns>The playlist item's ID.</returns>
|
||||
private PlaylistItem addItemStep(int ownerId, bool expired = false)
|
||||
{
|
||||
var item = new PlaylistItem
|
||||
{
|
||||
ID = ++currentItemId,
|
||||
OwnerID = ownerId,
|
||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo, false).BeatmapInfo },
|
||||
Expired = expired
|
||||
};
|
||||
|
||||
AddStep($"add {{ item: {item.ID}, user: {ownerId} }}", () =>
|
||||
{
|
||||
SelectedRoom.Value.Playlist.Add(item);
|
||||
if (!expired)
|
||||
list.Items.Add(item);
|
||||
});
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts the position of a given playlist item in the visual layout of the list.
|
||||
/// </summary>
|
||||
/// <param name="item">The playlist item.</param>
|
||||
/// <param name="visualIndex">The index at which the item should appear visually. The item with index 0 is at the top of the list.</param>
|
||||
private void assertPositionStep(PlaylistItem item, int visualIndex)
|
||||
{
|
||||
AddUntilStep($"item {item.ID} has pos = {visualIndex}", () =>
|
||||
{
|
||||
return this.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.OrderBy(drawable => drawable.Position.Y)
|
||||
.TakeWhile(drawable => drawable.Item.ID != item.ID)
|
||||
.Count() == visualIndex;
|
||||
});
|
||||
}
|
||||
|
||||
private void changeQueueModeStep(QueueMode newMode) => AddStep($"change queue mode to {newMode}", () => SelectedRoom.Value.QueueMode.Value = newMode);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user