mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Test steps.
This commit is contained in:
parent
4aff2ba2af
commit
ed97d35ef7
@ -3,26 +3,115 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi.Screens.Match;
|
using osu.Game.Screens.Multi.Screens.Match.Settings;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseRoomSettings : OsuTestCase
|
public class TestCaseRoomSettings : ManualInputManagerTestCase
|
||||||
{
|
{
|
||||||
|
private readonly Room room;
|
||||||
|
private readonly TestRoomSettingsOverlay overlay;
|
||||||
|
|
||||||
public TestCaseRoomSettings()
|
public TestCaseRoomSettings()
|
||||||
{
|
{
|
||||||
Room room = new Room();
|
room = new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "One Testing Room" },
|
||||||
|
Availability = { Value = RoomAvailability.Public },
|
||||||
|
Type = { Value = new GameTypeTeamVersus() },
|
||||||
|
MaxParticipants = { Value = 10 },
|
||||||
|
};
|
||||||
|
|
||||||
RoomSettingsOverlay overlay;
|
Add(overlay = new TestRoomSettingsOverlay(room)
|
||||||
Add(overlay = new RoomSettingsOverlay(room)
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Height = 0.75f,
|
Height = 0.75f,
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep(@"toggle", overlay.ToggleVisibility);
|
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", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(overlay.ApplyButton);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
get => Name.Text;
|
||||||
|
set => Name.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? CurrentMaxParticipants
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int max;
|
||||||
|
if (int.TryParse(MaxParticipants.Text, out max))
|
||||||
|
return max;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set => MaxParticipants.Text = value?.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoomAvailability CurrentAvailability
|
||||||
|
{
|
||||||
|
get => Availability.Current.Value;
|
||||||
|
set => Availability.Current.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameType CurrentType
|
||||||
|
{
|
||||||
|
get => Type.Current.Value;
|
||||||
|
set => Type.Current.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriangleButton ApplyButton => Apply;
|
||||||
|
|
||||||
|
public TestRoomSettingsOverlay(Room room) : base(room)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ using OpenTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
||||||
{
|
{
|
||||||
public class RoomSettingsOverlay : OverlayContainer
|
public class RoomSettingsOverlay : FocusedOverlayContainer
|
||||||
{
|
{
|
||||||
private const float transition_duration = 500;
|
private const float transition_duration = 500;
|
||||||
private const float field_padding = 45;
|
private const float field_padding = 45;
|
||||||
@ -28,13 +28,15 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
|
protected readonly OsuTextBox Name, MaxParticipants;
|
||||||
|
protected readonly RoomAvailabilityPicker Availability;
|
||||||
|
protected readonly GameTypePicker Type;
|
||||||
|
protected readonly TriangleButton Apply;
|
||||||
|
|
||||||
public RoomSettingsOverlay(Room room)
|
public RoomSettingsOverlay(Room room)
|
||||||
{
|
{
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
|
||||||
SettingsTextBox name, maxParticipants;
|
|
||||||
RoomAvailabilityPicker availability;
|
|
||||||
GameTypePicker type;
|
|
||||||
Child = content = new Container
|
Child = content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -59,15 +61,15 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
{
|
{
|
||||||
new Section("ROOM NAME")
|
new Section("ROOM NAME")
|
||||||
{
|
{
|
||||||
Child = name = new SettingsTextBox(),
|
Child = Name = new SettingsTextBox(),
|
||||||
},
|
},
|
||||||
new Section("ROOM VISIBILITY")
|
new Section("ROOM VISIBILITY")
|
||||||
{
|
{
|
||||||
Child = availability = new RoomAvailabilityPicker(),
|
Child = Availability = new RoomAvailabilityPicker(),
|
||||||
},
|
},
|
||||||
new Section("GAME TYPE")
|
new Section("GAME TYPE")
|
||||||
{
|
{
|
||||||
Child = type = new GameTypePicker(),
|
Child = Type = new GameTypePicker(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,7 +82,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
{
|
{
|
||||||
new Section("MAX PARTICIPANTS")
|
new Section("MAX PARTICIPANTS")
|
||||||
{
|
{
|
||||||
Child = maxParticipants = new SettingsTextBox(),
|
Child = MaxParticipants = new SettingsTextBox(),
|
||||||
},
|
},
|
||||||
new Section("PASSWORD (OPTIONAL)")
|
new Section("PASSWORD (OPTIONAL)")
|
||||||
{
|
{
|
||||||
@ -90,7 +92,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new ApplyButton
|
Apply = new ApplyButton
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
@ -100,12 +102,12 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
{
|
{
|
||||||
if (room != null)
|
if (room != null)
|
||||||
{
|
{
|
||||||
room.Name.Value = name.Text;
|
room.Name.Value = Name.Text;
|
||||||
room.Availability.Value = availability.Current.Value;
|
room.Availability.Value = Availability.Current.Value;
|
||||||
room.Type.Value = type.Current.Value;
|
room.Type.Value = Type.Current.Value;
|
||||||
|
|
||||||
int max;
|
int max;
|
||||||
if (int.TryParse(maxParticipants.Text, out max))
|
if (int.TryParse(MaxParticipants.Text, out max))
|
||||||
room.MaxParticipants.Value = max;
|
room.MaxParticipants.Value = max;
|
||||||
else
|
else
|
||||||
room.MaxParticipants.Value = null;
|
room.MaxParticipants.Value = null;
|
||||||
@ -117,10 +119,10 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
nameBind.ValueChanged += n => name.Text = n;
|
nameBind.ValueChanged += n => Name.Text = n;
|
||||||
availabilityBind.ValueChanged += a => availability.Current.Value = a;
|
availabilityBind.ValueChanged += a => Availability.Current.Value = a;
|
||||||
typeBind.ValueChanged += t => type.Current.Value = t;
|
typeBind.ValueChanged += t => Type.Current.Value = t;
|
||||||
maxParticipantsBind.ValueChanged += m => maxParticipants.Text = m?.ToString();
|
maxParticipantsBind.ValueChanged += m => MaxParticipants.Text = m?.ToString();
|
||||||
|
|
||||||
nameBind.BindTo(room.Name);
|
nameBind.BindTo(room.Name);
|
||||||
availabilityBind.BindTo(room.Availability);
|
availabilityBind.BindTo(room.Availability);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user