mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge remote-tracking branch 'upstream/master' into inter-column-movements
This commit is contained in:
@ -16,6 +16,7 @@ using NUnit.Framework;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@ -54,8 +55,9 @@ namespace osu.Game.Tests.Visual
|
||||
linkColour = colours.Blue;
|
||||
|
||||
var chatManager = new ChannelManager();
|
||||
chatManager.AvailableChannels.Add(new Channel { Name = "#english"});
|
||||
chatManager.AvailableChannels.Add(new Channel { Name = "#japanese" });
|
||||
BindableCollection<Channel> availableChannels = (BindableCollection<Channel>)chatManager.AvailableChannels;
|
||||
availableChannels.Add(new Channel { Name = "#english"});
|
||||
availableChannels.Add(new Channel { Name = "#japanese" });
|
||||
Dependencies.Cache(chatManager);
|
||||
|
||||
Dependencies.Cache(new ChatOverlay());
|
||||
|
135
osu.Game.Tests/Visual/TestCaseIdleTracker.cs
Normal file
135
osu.Game.Tests/Visual/TestCaseIdleTracker.cs
Normal file
@ -0,0 +1,135 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Input;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseIdleTracker : ManualInputManagerTestCase
|
||||
{
|
||||
private readonly IdleTrackingBox box1;
|
||||
private readonly IdleTrackingBox box2;
|
||||
private readonly IdleTrackingBox box3;
|
||||
private readonly IdleTrackingBox box4;
|
||||
|
||||
public TestCaseIdleTracker()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
box1 = new IdleTrackingBox(1000)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Red,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
},
|
||||
box2 = new IdleTrackingBox(2000)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Green,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
box3 = new IdleTrackingBox(3000)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Blue,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
box4 = new IdleTrackingBox(4000)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Orange,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNudge()
|
||||
{
|
||||
AddStep("move mouse to top left", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre));
|
||||
|
||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
||||
|
||||
AddStep("nudge mouse", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre + new Vector2(1)));
|
||||
|
||||
AddAssert("check not idle", () => !box1.IsIdle);
|
||||
AddAssert("check idle", () => box2.IsIdle);
|
||||
AddAssert("check idle", () => box3.IsIdle);
|
||||
AddAssert("check idle", () => box4.IsIdle);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMovement()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(box2.ScreenSpaceDrawQuad.Centre));
|
||||
|
||||
AddAssert("check not idle", () => box1.IsIdle);
|
||||
AddAssert("check not idle", () => !box2.IsIdle);
|
||||
AddAssert("check idle", () => box3.IsIdle);
|
||||
AddAssert("check idle", () => box4.IsIdle);
|
||||
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(box3.ScreenSpaceDrawQuad.Centre));
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(box4.ScreenSpaceDrawQuad.Centre));
|
||||
|
||||
AddAssert("check not idle", () => box1.IsIdle);
|
||||
AddAssert("check not idle", () => !box2.IsIdle);
|
||||
AddAssert("check idle", () => !box3.IsIdle);
|
||||
AddAssert("check idle", () => !box4.IsIdle);
|
||||
|
||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTimings()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
|
||||
|
||||
AddAssert("check not idle", () => !box1.IsIdle && !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
||||
AddUntilStep(() => box1.IsIdle, "Wait for idle");
|
||||
AddAssert("check not idle", () => !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
|
||||
AddUntilStep(() => box2.IsIdle, "Wait for idle");
|
||||
AddAssert("check not idle", () => !box3.IsIdle && !box4.IsIdle);
|
||||
AddUntilStep(() => box3.IsIdle, "Wait for idle");
|
||||
|
||||
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
|
||||
}
|
||||
|
||||
private class IdleTrackingBox : CompositeDrawable
|
||||
{
|
||||
private readonly IdleTracker idleTracker;
|
||||
|
||||
public bool IsIdle => idleTracker.IsIdle.Value;
|
||||
|
||||
public IdleTrackingBox(double timeToIdle)
|
||||
{
|
||||
Box box;
|
||||
|
||||
Alpha = 0.6f;
|
||||
Scale = new Vector2(0.6f);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
idleTracker = new IdleTracker(timeToIdle),
|
||||
box = new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
|
||||
idleTracker.IsIdle.BindValueChanged(idle => box.Colour = idle ? Color4.White : Color4.Black, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
119
osu.Game.Tests/Visual/TestCaseRoomSettings.cs
Normal file
119
osu.Game.Tests/Visual/TestCaseRoomSettings.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// 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;
|
||||
using osu.Framework.Testing.Input;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Screens.Match.Settings;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseRoomSettings : ManualInputManagerTestCase
|
||||
{
|
||||
private readonly Room room;
|
||||
private readonly TestRoomSettingsOverlay overlay;
|
||||
|
||||
public TestCaseRoomSettings()
|
||||
{
|
||||
room = new Room
|
||||
{
|
||||
Name = { Value = "One Testing Room" },
|
||||
Availability = { Value = RoomAvailability.Public },
|
||||
Type = { Value = new GameTypeTeamVersus() },
|
||||
MaxParticipants = { Value = 10 },
|
||||
};
|
||||
|
||||
Add(overlay = new TestRoomSettingsOverlay(room)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.75f,
|
||||
});
|
||||
|
||||
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", () =>
|
||||
{
|
||||
overlay.ClickApplyButton(InputManager);
|
||||
});
|
||||
}
|
||||
|
||||
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 => NameField.Text;
|
||||
set => NameField.Text = value;
|
||||
}
|
||||
|
||||
public int? CurrentMaxParticipants
|
||||
{
|
||||
get
|
||||
{
|
||||
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
||||
return max;
|
||||
|
||||
return null;
|
||||
}
|
||||
set => MaxParticipantsField.Text = value?.ToString();
|
||||
}
|
||||
|
||||
public RoomAvailability CurrentAvailability
|
||||
{
|
||||
get => AvailabilityPicker.Current.Value;
|
||||
set => AvailabilityPicker.Current.Value = value;
|
||||
}
|
||||
|
||||
public GameType CurrentType
|
||||
{
|
||||
get => TypePicker.Current.Value;
|
||||
set => TypePicker.Current.Value = value;
|
||||
}
|
||||
|
||||
public TestRoomSettingsOverlay(Room room) : base(room)
|
||||
{
|
||||
}
|
||||
|
||||
public void ClickApplyButton(ManualInputManager inputManager)
|
||||
{
|
||||
inputManager.MoveMouseTo(ApplyButton);
|
||||
inputManager.Click(MouseButton.Left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user