Merge branch 'master' into fix-initial-spectator-state-callback

This commit is contained in:
smoogipoo
2021-04-20 21:16:05 +09:00
37 changed files with 938 additions and 167 deletions

View File

@ -149,7 +149,7 @@ namespace osu.Game.Tests.Visual.Components
private void waitForAllIdle()
{
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
AddUntilStep("wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
}
private class IdleTrackingBox : CompositeDrawable
@ -158,7 +158,7 @@ namespace osu.Game.Tests.Visual.Components
public bool IsIdle => idleTracker.IsIdle.Value;
public IdleTrackingBox(double timeToIdle)
public IdleTrackingBox(int timeToIdle)
{
Box box;
@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.Components
InternalChildren = new Drawable[]
{
idleTracker = new IdleTracker(timeToIdle),
idleTracker = new GameIdleTracker(timeToIdle),
box = new Box
{
Colour = Color4.White,

View File

@ -118,8 +118,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestBasic()
{
AddStep("move to center", () => InputManager.MoveMouseTo(recordingManager.ScreenSpaceDrawQuad.Centre));
AddUntilStep("one frame recorded", () => replay.Frames.Count == 1);
AddAssert("position matches", () => playbackManager.ChildrenOfType<Box>().First().Position == recordingManager.ChildrenOfType<Box>().First().Position);
AddUntilStep("at least one frame recorded", () => replay.Frames.Count > 0);
AddUntilStep("position matches", () => playbackManager.ChildrenOfType<Box>().First().Position == recordingManager.ChildrenOfType<Box>().First().Position);
}
[Test]
@ -139,14 +139,16 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestLimitedFrameRate()
{
ScheduledDelegate moveFunction = null;
int initialFrameCount = 0;
AddStep("lower rate", () => recorder.RecordFrameRate = 2);
AddStep("count frames", () => initialFrameCount = replay.Frames.Count);
AddStep("move to center", () => InputManager.MoveMouseTo(recordingManager.ScreenSpaceDrawQuad.Centre));
AddStep("much move", () => moveFunction = Scheduler.AddDelayed(() =>
InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0)), 10, true));
AddWaitStep("move", 10);
AddStep("stop move", () => moveFunction.Cancel());
AddAssert("less than 10 frames recorded", () => replay.Frames.Count < 10);
AddAssert("less than 10 frames recorded", () => replay.Frames.Count - initialFrameCount < 10);
}
[Test]

View File

@ -0,0 +1,70 @@
// 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.
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneLabelledColourPalette : OsuTestScene
{
private LabelledColourPalette component;
[Test]
public void TestPalette([Values] bool hasDescription)
{
createColourPalette(hasDescription);
AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4);
AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo");
AddRepeatStep("remove random colour", () =>
{
if (component.Colours.Count > 0)
component.Colours.RemoveAt(RNG.Next(component.Colours.Count));
}, 8);
}
private void createColourPalette(bool hasDescription = false)
{
AddStep("create component", () =>
{
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = new LabelledColourPalette
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ColourNamePrefix = "My colour #"
}
};
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
component.Colours.AddRange(new[]
{
Color4.DarkRed,
Color4.Aquamarine,
Color4.Goldenrod,
Color4.Gainsboro
});
});
}
private Color4 randomColour() => new Color4(
RNG.NextSingle(),
RNG.NextSingle(),
RNG.NextSingle(),
1);
}
}