2018-06-06 11:29:52 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-08-14 23:25:35 +08:00
|
|
|
|
using osu.Framework.Testing.Input;
|
2018-06-06 16:38:43 +08:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2018-06-07 10:30:17 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Screens.Match.Settings;
|
2018-11-26 15:29:56 +08:00
|
|
|
|
using osuTK.Input;
|
2018-06-06 11:29:52 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2018-06-07 10:30:17 +08:00
|
|
|
|
public class TestCaseRoomSettings : ManualInputManagerTestCase
|
2018-06-06 11:29:52 +08:00
|
|
|
|
{
|
2018-06-07 10:30:17 +08:00
|
|
|
|
private readonly Room room;
|
|
|
|
|
private readonly TestRoomSettingsOverlay overlay;
|
|
|
|
|
|
2018-06-06 11:29:52 +08:00
|
|
|
|
public TestCaseRoomSettings()
|
|
|
|
|
{
|
2018-06-07 10:30:17 +08:00
|
|
|
|
room = new Room
|
|
|
|
|
{
|
|
|
|
|
Name = { Value = "One Testing Room" },
|
|
|
|
|
Availability = { Value = RoomAvailability.Public },
|
|
|
|
|
Type = { Value = new GameTypeTeamVersus() },
|
|
|
|
|
MaxParticipants = { Value = 10 },
|
|
|
|
|
};
|
2018-06-06 11:29:52 +08:00
|
|
|
|
|
2018-06-07 10:30:17 +08:00
|
|
|
|
Add(overlay = new TestRoomSettingsOverlay(room)
|
2018-06-06 11:29:52 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Height = 0.75f,
|
|
|
|
|
});
|
|
|
|
|
|
2018-06-07 10:30:17 +08:00
|
|
|
|
AddStep(@"show", overlay.Show);
|
|
|
|
|
assertAll();
|
|
|
|
|
AddStep(@"set name", () => overlay.CurrentName = @"Two Testing Room");
|
|
|
|
|
AddStep(@"set max", () => overlay.CurrentMaxParticipants = null);
|
|
|
|
|
AddStep(@"set availability", () => overlay.CurrentAvailability = RoomAvailability.InviteOnly);
|
|
|
|
|
AddStep(@"set type", () => overlay.CurrentType = new GameTypeTagTeam());
|
|
|
|
|
apply();
|
|
|
|
|
assertAll();
|
|
|
|
|
AddStep(@"show", overlay.Show);
|
|
|
|
|
AddStep(@"set room name", () => room.Name.Value = @"Room Changed Name!");
|
|
|
|
|
AddStep(@"set room availability", () => room.Availability.Value = RoomAvailability.Public);
|
|
|
|
|
AddStep(@"set room type", () => room.Type.Value = new GameTypeTag());
|
|
|
|
|
AddStep(@"set room max", () => room.MaxParticipants.Value = 100);
|
|
|
|
|
assertAll();
|
|
|
|
|
AddStep(@"set name", () => overlay.CurrentName = @"Unsaved Testing Room");
|
|
|
|
|
AddStep(@"set max", () => overlay.CurrentMaxParticipants = 20);
|
|
|
|
|
AddStep(@"set availability", () => overlay.CurrentAvailability = RoomAvailability.FriendsOnly);
|
|
|
|
|
AddStep(@"set type", () => overlay.CurrentType = new GameTypeVersus());
|
|
|
|
|
AddStep(@"hide", overlay.Hide);
|
|
|
|
|
AddWaitStep(5);
|
|
|
|
|
AddStep(@"show", overlay.Show);
|
|
|
|
|
assertAll();
|
|
|
|
|
AddStep(@"hide", overlay.Hide);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void apply()
|
|
|
|
|
{
|
|
|
|
|
AddStep(@"apply", () =>
|
|
|
|
|
{
|
2018-08-14 22:31:20 +08:00
|
|
|
|
overlay.ClickApplyButton(InputManager);
|
2018-06-07 10:30:17 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertAll()
|
|
|
|
|
{
|
|
|
|
|
AddAssert(@"name == room name", () => overlay.CurrentName == room.Name.Value);
|
|
|
|
|
AddAssert(@"max == room max", () => overlay.CurrentMaxParticipants == room.MaxParticipants.Value);
|
|
|
|
|
AddAssert(@"availability == room availability", () => overlay.CurrentAvailability == room.Availability.Value);
|
|
|
|
|
AddAssert(@"type == room type", () => Equals(overlay.CurrentType, room.Type.Value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestRoomSettingsOverlay : RoomSettingsOverlay
|
|
|
|
|
{
|
|
|
|
|
public string CurrentName
|
|
|
|
|
{
|
2018-08-14 22:31:20 +08:00
|
|
|
|
get => NameField.Text;
|
|
|
|
|
set => NameField.Text = value;
|
2018-06-07 10:30:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int? CurrentMaxParticipants
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-08-14 23:25:35 +08:00
|
|
|
|
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
2018-06-07 10:30:17 +08:00
|
|
|
|
return max;
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-08-14 22:31:20 +08:00
|
|
|
|
set => MaxParticipantsField.Text = value?.ToString();
|
2018-06-07 10:30:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RoomAvailability CurrentAvailability
|
|
|
|
|
{
|
2018-08-14 22:31:20 +08:00
|
|
|
|
get => AvailabilityPicker.Current.Value;
|
|
|
|
|
set => AvailabilityPicker.Current.Value = value;
|
2018-06-07 10:30:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GameType CurrentType
|
|
|
|
|
{
|
2018-08-14 22:31:20 +08:00
|
|
|
|
get => TypePicker.Current.Value;
|
|
|
|
|
set => TypePicker.Current.Value = value;
|
2018-06-07 10:30:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TestRoomSettingsOverlay(Room room) : base(room)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-08-14 22:31:20 +08:00
|
|
|
|
|
|
|
|
|
public void ClickApplyButton(ManualInputManager inputManager)
|
|
|
|
|
{
|
|
|
|
|
inputManager.MoveMouseTo(ApplyButton);
|
|
|
|
|
inputManager.Click(MouseButton.Left);
|
|
|
|
|
}
|
2018-06-06 11:29:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|