Merge remote-tracking branch 'upstream/master' into back-button-part-2

This commit is contained in:
Dean Herbert
2019-09-25 14:38:39 +09:00
353 changed files with 6697 additions and 1744 deletions

View File

@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Add(overlay = new DialogOverlay());
AddStep("dialog #1", () => overlay.Push(new PopupDialog
AddStep("dialog #1", () => overlay.Push(new TestPopupDialog
{
Icon = FontAwesome.Regular.TrashAlt,
HeaderText = @"Confirm deletion of",
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.UserInterface
},
}));
AddStep("dialog #2", () => overlay.Push(new PopupDialog
AddStep("dialog #2", () => overlay.Push(new TestPopupDialog
{
Icon = FontAwesome.Solid.Cog,
HeaderText = @"What do you want to do with",
@ -71,5 +71,9 @@ namespace osu.Game.Tests.Visual.UserInterface
},
}));
}
private class TestPopupDialog : PopupDialog
{
}
}
}

View File

@ -52,19 +52,23 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("start confirming", () => overlay.Begin());
AddStep("abort confirming", () => overlay.Abort());
AddAssert("ensure not fired internally", () => !overlay.Fired);
AddAssert("ensure aborted", () => !fired);
AddStep("start confirming", () => overlay.Begin());
AddUntilStep("wait until confirmed", () => fired);
AddAssert("ensure fired internally", () => overlay.Fired);
AddStep("abort after fire", () => overlay.Abort());
AddAssert("ensure not fired internally", () => !overlay.Fired);
AddStep("start confirming", () => overlay.Begin());
AddUntilStep("wait until fired again", () => overlay.Fired);
}
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
{
protected override bool AllowMultipleFires => true;
public void Begin() => BeginConfirm();
public void Abort() => AbortConfirm();
}
}
}

View File

@ -0,0 +1,89 @@
// 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.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneLabelledComponent : OsuTestScene
{
[TestCase(false)]
[TestCase(true)]
public void TestPadded(bool hasDescription) => createPaddedComponent(hasDescription);
[TestCase(false)]
[TestCase(true)]
public void TestNonPadded(bool hasDescription) => createPaddedComponent(hasDescription, false);
private void createPaddedComponent(bool hasDescription = false, bool padded = true)
{
AddStep("create component", () =>
{
LabelledComponent<Drawable> component;
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = padded ? (LabelledComponent<Drawable>)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
};
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
});
}
private class PaddedLabelledComponent : LabelledComponent<Drawable>
{
public PaddedLabelledComponent()
: base(true)
{
}
protected override Drawable CreateComponent() => new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.Red,
Text = @"(( Component ))"
};
}
private class NonPaddedLabelledComponent : LabelledComponent<Drawable>
{
public NonPaddedLabelledComponent()
: base(false)
{
}
protected override Drawable CreateComponent() => new Container
{
RelativeSizeAxes = Axes.X,
Height = 40,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.SlateGray
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.Red,
Text = @"(( Component ))"
}
}
};
}
}
}

View File

@ -7,7 +7,8 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Tests.Visual.UserInterface
{
@ -19,6 +20,36 @@ namespace osu.Game.Tests.Visual.UserInterface
typeof(LabelledTextBox),
};
[TestCase(false)]
[TestCase(true)]
public void TestTextBox(bool hasDescription) => createTextBox(hasDescription);
private void createTextBox(bool hasDescription = false)
{
AddStep("create component", () =>
{
LabelledComponent<OsuTextBox> component;
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = new LabelledTextBox
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Label = "Testing text",
PlaceholderText = "This is definitely working as intended",
}
};
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
});
}
[BackgroundDependencyLoader]
private void load()
{
@ -32,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
LabelText = "Testing text",
Label = "Testing text",
PlaceholderText = "This is definitely working as intended",
}
};

View File

@ -13,13 +13,22 @@ namespace osu.Game.Tests.Visual.UserInterface
{
public TestScenePopupDialog()
{
var popup = new PopupDialog
Add(new TestPopupDialog
{
RelativeSizeAxes = Axes.Both,
State = { Value = Framework.Graphics.Containers.Visibility.Visible },
Icon = FontAwesome.Solid.AssistiveListeningSystems,
HeaderText = @"This is a test popup",
BodyText = "I can say lots of stuff and even wrap my words!",
});
}
private class TestPopupDialog : PopupDialog
{
public TestPopupDialog()
{
Icon = FontAwesome.Solid.AssistiveListeningSystems;
HeaderText = @"This is a test popup";
BodyText = "I can say lots of stuff and even wrap my words!";
Buttons = new PopupDialogButton[]
{
new PopupDialogCancelButton
@ -30,10 +39,8 @@ namespace osu.Game.Tests.Visual.UserInterface
{
Text = @"You're a fake!",
},
}
};
Add(popup);
};
}
}
}
}

View File

@ -20,6 +20,8 @@ namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
{
protected override bool UseOnlineAPI => true;
private BeatmapSetInfo testBeatmap;
private IAPIProvider api;
private RulesetStore rulesets;