mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 01:37:31 +08:00
Fix tests
This commit is contained in:
parent
7847ce6253
commit
1152c4e8e9
@ -22,6 +22,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMultiplayerPlaylist : MultiplayerTestScene
|
||||
{
|
||||
private MultiplayerPlaylist list;
|
||||
private BeatmapManager beatmaps;
|
||||
private RulesetStore rulesets;
|
||||
private BeatmapSetInfo importedSet;
|
||||
@ -37,7 +38,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = new MultiplayerPlaylist
|
||||
Child = list = new MultiplayerPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -175,47 +176,57 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
/// </summary>
|
||||
/// <param name="playlistItemId">The item id.</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 assertItemInQueueListStep(int playlistItemId, int visualIndex) => AddUntilStep($"{playlistItemId} in queue at pos = {visualIndex}", () =>
|
||||
private void assertItemInQueueListStep(int playlistItemId, int visualIndex)
|
||||
{
|
||||
return !inHistoryList(playlistItemId)
|
||||
&& this.ChildrenOfType<MultiplayerQueueList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.OrderBy(drawable => drawable.Position.Y)
|
||||
.TakeWhile(drawable => drawable.Item.ID != playlistItemId)
|
||||
.Count() == visualIndex;
|
||||
});
|
||||
changeDisplayModeStep(MultiplayerPlaylistDisplayMode.Queue);
|
||||
|
||||
AddUntilStep($"{playlistItemId} in queue at pos = {visualIndex}", () =>
|
||||
{
|
||||
return !inHistoryList(playlistItemId)
|
||||
&& this.ChildrenOfType<MultiplayerQueueList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.OrderBy(drawable => drawable.Position.Y)
|
||||
.TakeWhile(drawable => drawable.Item.ID != playlistItemId)
|
||||
.Count() == visualIndex;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts the position of a given playlist item in the history list.
|
||||
/// </summary>
|
||||
/// <param name="playlistItemId">The item id.</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 assertItemInHistoryListStep(int playlistItemId, int visualIndex) => AddUntilStep($"{playlistItemId} in history at pos = {visualIndex}", () =>
|
||||
private void assertItemInHistoryListStep(int playlistItemId, int visualIndex)
|
||||
{
|
||||
return !inQueueList(playlistItemId)
|
||||
&& this.ChildrenOfType<MultiplayerHistoryList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.OrderBy(drawable => drawable.Position.Y)
|
||||
.TakeWhile(drawable => drawable.Item.ID != playlistItemId)
|
||||
.Count() == visualIndex;
|
||||
});
|
||||
changeDisplayModeStep(MultiplayerPlaylistDisplayMode.History);
|
||||
|
||||
AddUntilStep($"{playlistItemId} in history at pos = {visualIndex}", () =>
|
||||
{
|
||||
return !inQueueList(playlistItemId)
|
||||
&& this.ChildrenOfType<MultiplayerHistoryList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.OrderBy(drawable => drawable.Position.Y)
|
||||
.TakeWhile(drawable => drawable.Item.ID != playlistItemId)
|
||||
.Count() == visualIndex;
|
||||
});
|
||||
}
|
||||
|
||||
private void changeDisplayModeStep(MultiplayerPlaylistDisplayMode mode) => AddStep($"change list to {mode}", () => list.DisplayMode.Value = mode);
|
||||
|
||||
private bool inQueueList(int playlistItemId)
|
||||
{
|
||||
return this.ChildrenOfType<MultiplayerQueueList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.Any(i => i.Item.ID == playlistItemId);
|
||||
.Items.Any(i => i.ID == playlistItemId);
|
||||
}
|
||||
|
||||
private bool inHistoryList(int playlistItemId)
|
||||
{
|
||||
return this.ChildrenOfType<MultiplayerHistoryList>()
|
||||
.Single()
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem>()
|
||||
.Any(i => i.Item.ID == playlistItemId);
|
||||
.Items.Any(i => i.ID == playlistItemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
@ -14,6 +13,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
{
|
||||
public class MultiplayerPlaylist : MultiplayerRoomComposite
|
||||
{
|
||||
public readonly Bindable<MultiplayerPlaylistDisplayMode> DisplayMode = new Bindable<MultiplayerPlaylistDisplayMode>();
|
||||
|
||||
private MultiplayerQueueList queueList;
|
||||
private MultiplayerHistoryList historyList;
|
||||
private bool firstPopulation = true;
|
||||
@ -21,14 +22,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
TabControl<DisplayMode> displayModeTabControl;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
displayModeTabControl = new OsuTabControl<DisplayMode>
|
||||
new OsuTabControl<MultiplayerPlaylistDisplayMode>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 25
|
||||
Height = 25,
|
||||
Current = { BindTarget = DisplayMode }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -49,14 +49,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
displayModeTabControl.Current.BindValueChanged(onDisplayModeChanged, true);
|
||||
}
|
||||
|
||||
private void onDisplayModeChanged(ValueChangedEvent<DisplayMode> mode)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
historyList.FadeTo(mode.NewValue == DisplayMode.History ? 1 : 0, 100);
|
||||
queueList.FadeTo(mode.NewValue == DisplayMode.Queue ? 1 : 0, 100);
|
||||
base.LoadComplete();
|
||||
|
||||
DisplayMode.BindValueChanged(onDisplayModeChanged, true);
|
||||
}
|
||||
|
||||
private void onDisplayModeChanged(ValueChangedEvent<MultiplayerPlaylistDisplayMode> mode)
|
||||
{
|
||||
historyList.FadeTo(mode.NewValue == MultiplayerPlaylistDisplayMode.History ? 1 : 0, 100);
|
||||
queueList.FadeTo(mode.NewValue == MultiplayerPlaylistDisplayMode.Queue ? 1 : 0, 100);
|
||||
}
|
||||
|
||||
protected override void OnRoomUpdated()
|
||||
@ -107,11 +112,5 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
PlaylistItemRemoved(item.ID);
|
||||
PlaylistItemAdded(item);
|
||||
}
|
||||
|
||||
private enum DisplayMode
|
||||
{
|
||||
Queue,
|
||||
History,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
{
|
||||
public enum MultiplayerPlaylistDisplayMode
|
||||
{
|
||||
Queue,
|
||||
History,
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user