1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00
osu-lazer/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
4.0 KiB
C#
Raw Normal View History

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.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-07-09 17:07:34 +08:00
using System.Linq;
using NUnit.Framework;
2021-08-23 13:29:15 +08:00
using osu.Framework.Bindables;
2020-07-09 17:07:34 +08:00
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
2021-08-23 13:29:15 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Tests.Visual.OnlinePlay;
2021-07-26 09:28:25 +08:00
using osuTK.Input;
2020-07-09 17:07:34 +08:00
namespace osu.Game.Tests.Visual.Playlists
2020-07-09 17:07:34 +08:00
{
public partial class TestScenePlaylistsLoungeSubScreen : OnlinePlayTestScene
2020-07-09 17:07:34 +08:00
{
2021-10-27 15:10:22 +08:00
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
2021-06-24 18:13:50 +08:00
2021-08-23 13:29:15 +08:00
private TestLoungeSubScreen loungeScreen;
2020-07-09 17:07:34 +08:00
public override void SetUpSteps()
{
base.SetUpSteps();
2021-08-23 13:29:15 +08:00
AddStep("push screen", () => LoadScreen(loungeScreen = new TestLoungeSubScreen()));
2020-07-09 17:25:07 +08:00
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
2020-07-09 17:07:34 +08:00
}
private RoomsContainer roomsContainer => loungeScreen.ChildrenOfType<RoomsContainer>().First();
2021-09-08 18:38:47 +08:00
[Test]
public void TestManyRooms()
{
AddStep("add rooms", () => RoomManager.AddRooms(500));
}
2021-07-26 09:28:25 +08:00
[Test]
public void TestScrollByDraggingRooms()
{
AddStep("reset mouse", () => InputManager.ReleaseButton(MouseButton.Left));
AddStep("add rooms", () => RoomManager.AddRooms(30));
AddUntilStep("wait for rooms", () => roomsContainer.Rooms.Count == 30);
2021-07-26 09:28:25 +08:00
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms[0]));
AddStep("move mouse to third room", () => InputManager.MoveMouseTo(roomsContainer.Rooms[2]));
AddStep("hold down", () => InputManager.PressButton(MouseButton.Left));
AddStep("drag to top", () => InputManager.MoveMouseTo(roomsContainer.Rooms[0]));
AddAssert("first and second room masked", ()
=> !checkRoomVisible(roomsContainer.Rooms[0]) &&
!checkRoomVisible(roomsContainer.Rooms[1]));
}
2020-07-09 17:07:34 +08:00
[Test]
public void TestScrollSelectedIntoView()
{
AddStep("add rooms", () => RoomManager.AddRooms(30));
AddUntilStep("wait for rooms", () => roomsContainer.Rooms.Count == 30);
2020-07-09 17:07:34 +08:00
2021-07-26 09:28:25 +08:00
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms[0]));
2020-07-09 17:07:34 +08:00
2021-08-04 16:27:44 +08:00
AddStep("select last room", () => roomsContainer.Rooms[^1].TriggerClick());
2020-07-09 17:07:34 +08:00
2021-07-26 09:28:25 +08:00
AddUntilStep("first room is masked", () => !checkRoomVisible(roomsContainer.Rooms[0]));
AddUntilStep("last room is not masked", () => checkRoomVisible(roomsContainer.Rooms[^1]));
2020-07-09 17:07:34 +08:00
}
2021-08-12 14:11:32 +08:00
[Test]
public void TestEnteringRoomTakesLeaseOnSelection()
{
AddStep("add rooms", () => RoomManager.AddRooms(1));
2021-08-23 13:29:15 +08:00
AddAssert("selected room is not disabled", () => !loungeScreen.SelectedRoom.Disabled);
2021-08-12 14:11:32 +08:00
AddStep("select room", () => roomsContainer.Rooms[0].TriggerClick());
2021-08-23 13:29:15 +08:00
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
2021-08-12 14:11:32 +08:00
AddStep("enter room", () => roomsContainer.Rooms[0].TriggerClick());
AddUntilStep("wait for match load", () => Stack.CurrentScreen is PlaylistsRoomSubScreen);
2021-08-23 13:29:15 +08:00
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
AddAssert("selected room is disabled", () => loungeScreen.SelectedRoom.Disabled);
2021-08-12 14:11:32 +08:00
}
2020-07-09 17:07:34 +08:00
private bool checkRoomVisible(DrawableRoom room) =>
loungeScreen.ChildrenOfType<OsuScrollContainer>().First().ScreenSpaceDrawQuad
.Contains(room.ScreenSpaceDrawQuad.Centre);
2021-08-23 13:29:15 +08:00
private partial class TestLoungeSubScreen : PlaylistsLoungeSubScreen
{
public new Bindable<Room> SelectedRoom => base.SelectedRoom;
}
2020-07-09 17:07:34 +08:00
}
}