mirror of
https://github.com/ppy/osu.git
synced 2024-09-21 16:07:24 +08:00
Fix failing test cases
This commit is contained in:
parent
ee5ff283d1
commit
7aca0f4a1d
@ -16,7 +16,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCaseLoungeRoomsContainer : OsuTestCase
|
||||
public class TestCaseLoungeRoomsContainer : MultiplayerTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
|
||||
|
||||
AddStep("select first room", () => container.Rooms.First().Action?.Invoke());
|
||||
AddAssert("first room selected", () => roomManager.CurrentRoom.Value == roomManager.Rooms.First());
|
||||
AddAssert("first room selected", () => Room == roomManager.Rooms.First());
|
||||
|
||||
AddStep("join first room", () => container.Rooms.First().Action?.Invoke());
|
||||
AddAssert("first room joined", () => roomManager.Rooms.First().Status.Value is JoinedRoomStatus);
|
||||
@ -73,15 +73,13 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public event Action RoomsUpdated
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
||||
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
||||
|
||||
public Bindable<Room> CurrentRoom { get; } = new Bindable<Room>();
|
||||
|
||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
||||
|
||||
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||
@ -91,10 +89,6 @@ namespace osu.Game.Tests.Visual
|
||||
public void PartRoom()
|
||||
{
|
||||
}
|
||||
|
||||
public void Filter(FilterCriteria criteria)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class JoinedRoomStatus : RoomStatus
|
||||
|
@ -13,7 +13,6 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi;
|
||||
using osu.Game.Screens.Multi.Lounge.Components;
|
||||
using osu.Game.Screens.Multi.Match.Components;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -133,14 +132,12 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public event Action RoomsUpdated
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public IBindableList<Room> Rooms { get; } = null;
|
||||
|
||||
public Bindable<Room> CurrentRoom { get; } = new Bindable<Room>();
|
||||
|
||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||
{
|
||||
if (CreateRequested == null)
|
||||
@ -155,8 +152,6 @@ namespace osu.Game.Tests.Visual
|
||||
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => throw new NotImplementedException();
|
||||
|
||||
public void PartRoom() => throw new NotImplementedException();
|
||||
|
||||
public void Filter(FilterCriteria criteria) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,26 +2,20 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class MultiplayerTestCase : OsuTestCase
|
||||
{
|
||||
private Room room;
|
||||
[Cached]
|
||||
private readonly Bindable<Room> currentRoom = new Bindable<Room>(new Room());
|
||||
|
||||
protected Room Room
|
||||
{
|
||||
get => room;
|
||||
set
|
||||
{
|
||||
if (room == value)
|
||||
return;
|
||||
room = value;
|
||||
|
||||
if (dependencies != null)
|
||||
dependencies.Model.Value = value;
|
||||
}
|
||||
get => currentRoom;
|
||||
set => currentRoom.Value = value;
|
||||
}
|
||||
|
||||
private CachedModelDependencyContainer<Room> dependencies;
|
||||
@ -29,7 +23,7 @@ namespace osu.Game.Tests.Visual
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
||||
dependencies.Model.Value = room;
|
||||
dependencies.Model.BindTo(currentRoom);
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user