1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:43:01 +08:00

Fix test failure

This commit is contained in:
smoogipoo 2021-08-23 14:29:15 +09:00
parent f85d3665d8
commit 4f3a5fbad5
2 changed files with 21 additions and 14 deletions

View File

@ -3,10 +3,11 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Tests.Visual.OnlinePlay;
@ -18,13 +19,13 @@ namespace osu.Game.Tests.Visual.Playlists
{
protected new TestRequestHandlingRoomManager RoomManager => (TestRequestHandlingRoomManager)base.RoomManager;
private LoungeSubScreen loungeScreen;
private TestLoungeSubScreen loungeScreen;
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen()));
AddStep("push screen", () => LoadScreen(loungeScreen = new TestLoungeSubScreen()));
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
}
@ -69,21 +70,26 @@ namespace osu.Game.Tests.Visual.Playlists
{
AddStep("add rooms", () => RoomManager.AddRooms(1));
AddAssert("selected room is not disabled", () => !OnlinePlayDependencies.SelectedRoom.Disabled);
AddAssert("selected room is not disabled", () => !loungeScreen.SelectedRoom.Disabled);
AddStep("select room", () => roomsContainer.Rooms[0].TriggerClick());
AddAssert("selected room is non-null", () => OnlinePlayDependencies.SelectedRoom.Value != null);
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
AddStep("enter room", () => roomsContainer.Rooms[0].TriggerClick());
AddUntilStep("wait for match load", () => Stack.CurrentScreen is PlaylistsRoomSubScreen);
AddAssert("selected room is non-null", () => OnlinePlayDependencies.SelectedRoom.Value != null);
AddAssert("selected room is disabled", () => OnlinePlayDependencies.SelectedRoom.Disabled);
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
AddAssert("selected room is disabled", () => loungeScreen.SelectedRoom.Disabled);
}
private bool checkRoomVisible(DrawableRoom room) =>
loungeScreen.ChildrenOfType<OsuScrollContainer>().First().ScreenSpaceDrawQuad
.Contains(room.ScreenSpaceDrawQuad.Centre);
private class TestLoungeSubScreen : PlaylistsLoungeSubScreen
{
public new Bindable<Room> SelectedRoom => base.SelectedRoom;
}
}
}

View File

@ -38,7 +38,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
protected override BackgroundScreen CreateBackground() => new LoungeBackgroundScreen
{
SelectedRoom = { BindTarget = selectedRoom }
SelectedRoom = { BindTarget = SelectedRoom }
};
protected override UserActivity InitialActivity => new UserActivity.SearchingForLobby();
@ -52,6 +52,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
protected ListingPollingComponent ListingPollingComponent { get; private set; }
protected readonly Bindable<Room> SelectedRoom = new Bindable<Room>();
[Resolved]
private MusicController music { get; set; }
@ -68,7 +70,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
private LeasedBindable<Room> selectionLease;
private readonly Bindable<FilterCriteria> filter = new Bindable<FilterCriteria>(new FilterCriteria());
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
private readonly IBindable<bool> operationInProgress = new Bindable<bool>();
private readonly IBindable<bool> isIdle = new BindableBool();
private LoadingLayer loadingLayer;
@ -105,7 +106,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
Child = roomsContainer = new RoomsContainer
{
Filter = { BindTarget = filter },
SelectedRoom = { BindTarget = selectedRoom }
SelectedRoom = { BindTarget = SelectedRoom }
}
},
},
@ -164,7 +165,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
};
// scroll selected room into view on selection.
selectedRoom.BindValueChanged(val =>
SelectedRoom.BindValueChanged(val =>
{
var drawable = roomsContainer.Rooms.FirstOrDefault(r => r.Room == val.NewValue);
if (drawable != null)
@ -247,8 +248,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
selectionLease.Return();
selectionLease = null;
if (selectedRoom.Value?.RoomID.Value == null)
selectedRoom.Value = new Room();
if (SelectedRoom.Value?.RoomID.Value == null)
SelectedRoom.Value = new Room();
music?.EnsurePlayingSomething();
@ -321,7 +322,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
protected virtual void OpenNewRoom(Room room)
{
selectionLease = selectedRoom.BeginLease(false);
selectionLease = SelectedRoom.BeginLease(false);
Debug.Assert(selectionLease != null);
selectionLease.Value = room;