2020-07-09 17:07:34 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Game.Beatmaps;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-07-09 17:07:34 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Screens.Multi;
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
{
|
2020-12-25 12:38:11 +08:00
|
|
|
public abstract class RoomManagerTestScene : RoomTestScene
|
2020-07-09 17:07:34 +08:00
|
|
|
{
|
|
|
|
[Cached(Type = typeof(IRoomManager))]
|
|
|
|
protected TestRoomManager RoomManager { get; } = new TestRoomManager();
|
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddStep("clear rooms", () => RoomManager.Rooms.Clear());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void AddRooms(int count, RulesetInfo ruleset = null)
|
|
|
|
{
|
|
|
|
AddStep("add rooms", () =>
|
|
|
|
{
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
var room = new Room
|
|
|
|
{
|
|
|
|
RoomID = { Value = i },
|
|
|
|
Name = { Value = $"Room {i}" },
|
|
|
|
Host = { Value = new User { Username = "Host" } },
|
2020-07-10 18:37:27 +08:00
|
|
|
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) },
|
|
|
|
Category = { Value = i % 2 == 0 ? RoomCategory.Spotlight : RoomCategory.Normal }
|
2020-07-09 17:07:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
if (ruleset != null)
|
|
|
|
{
|
|
|
|
room.Playlist.Add(new PlaylistItem
|
|
|
|
{
|
|
|
|
Ruleset = { Value = ruleset },
|
|
|
|
Beatmap =
|
|
|
|
{
|
|
|
|
Value = new BeatmapInfo
|
|
|
|
{
|
|
|
|
Metadata = new BeatmapMetadata()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomManager.Rooms.Add(room);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|