mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add test flow for joining passworded rooms via UI
This commit is contained in:
@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
@ -18,6 +22,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
private LoungeSubScreen loungeScreen;
|
private LoungeSubScreen loungeScreen;
|
||||||
|
|
||||||
|
private Room lastJoinedRoom;
|
||||||
|
private string lastJoinedPassword;
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
@ -25,20 +32,46 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("push screen", () => LoadScreen(loungeScreen = new MultiplayerLoungeSubScreen()));
|
AddStep("push screen", () => LoadScreen(loungeScreen = new MultiplayerLoungeSubScreen()));
|
||||||
|
|
||||||
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
||||||
|
|
||||||
|
AddStep("bind to event", () =>
|
||||||
|
{
|
||||||
|
lastJoinedRoom = null;
|
||||||
|
lastJoinedPassword = null;
|
||||||
|
RoomManager.JoinRoomRequested = onRoomJoined;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestJoinRoomWithoutPassword()
|
public void TestJoinRoomWithoutPassword()
|
||||||
{
|
{
|
||||||
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: false));
|
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: false));
|
||||||
|
AddStep("select room", () => InputManager.Key(Key.Down));
|
||||||
|
AddStep("join room", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddAssert("room join requested", () => lastJoinedRoom == RoomManager.Rooms.First());
|
||||||
|
AddAssert("room join password correct", () => lastJoinedPassword == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestJoinRoomWithPassword()
|
public void TestJoinRoomWithPassword()
|
||||||
{
|
{
|
||||||
|
DrawableRoom.PasswordEntryPopover passwordEntryPopover = null;
|
||||||
|
|
||||||
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
|
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
|
||||||
|
AddStep("select room", () => InputManager.Key(Key.Down));
|
||||||
|
AddStep("attempt join room", () => InputManager.Key(Key.Enter));
|
||||||
|
AddUntilStep("password prompt appeared", () => (passwordEntryPopover = loungeScreen.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().FirstOrDefault()) != null);
|
||||||
|
AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType<TextBox>().First().Text = "password");
|
||||||
|
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().Click());
|
||||||
|
|
||||||
|
AddAssert("room join requested", () => lastJoinedRoom == RoomManager.Rooms.First());
|
||||||
|
AddAssert("room join password correct", () => lastJoinedPassword == "password");
|
||||||
}
|
}
|
||||||
|
|
||||||
private RoomsContainer roomsContainer => loungeScreen.ChildrenOfType<RoomsContainer>().First();
|
private void onRoomJoined(Room room, string password)
|
||||||
|
{
|
||||||
|
lastJoinedRoom = room;
|
||||||
|
lastJoinedPassword = password;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
|
|
||||||
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
||||||
|
|
||||||
|
public Action<Room, string> JoinRoomRequested;
|
||||||
|
|
||||||
public IBindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
public IBindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||||
|
|
||||||
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
||||||
@ -37,7 +39,11 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
onSuccess?.Invoke(room);
|
onSuccess?.Invoke(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null) => onSuccess?.Invoke(room);
|
public void JoinRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
|
{
|
||||||
|
JoinRoomRequested?.Invoke(room, password);
|
||||||
|
onSuccess?.Invoke(room);
|
||||||
|
}
|
||||||
|
|
||||||
public void PartRoom()
|
public void PartRoom()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user