mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Move TestCase descriptions to attributes
Removes the necessity to construct a TestCase to get its description. Removes descriptions where they weren't adding anything to the titles. Also tidies up naming of some TestCases and button layout. Closes #1185.
This commit is contained in:
@@ -15,10 +15,9 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("frame-based animations")]
|
||||
internal class TestCaseAnimation : TestCase
|
||||
{
|
||||
public override string Description => "Various frame-based animations";
|
||||
|
||||
public TestCaseAnimation()
|
||||
{
|
||||
DrawableAnimation drawableAnimation;
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseBufferedContainer : TestCaseMasking
|
||||
{
|
||||
public override string Description => @"Buffered containers containing almost all visual effects.";
|
||||
|
||||
private readonly BufferedContainer buffer;
|
||||
|
||||
public TestCaseBufferedContainer()
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseCheckboxes : TestCase
|
||||
{
|
||||
public override string Description => @"Checkboxes with clickable labels";
|
||||
|
||||
public TestCaseCheckboxes()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseCircularProgress : TestCase
|
||||
{
|
||||
public override string Description => @"Circular progress bar";
|
||||
|
||||
private readonly CircularProgress clock;
|
||||
|
||||
private int rotateMode;
|
||||
|
||||
@@ -81,8 +81,6 @@ namespace osu.Framework.Tests.Visual
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description => @"Various cases of colour gradients.";
|
||||
|
||||
private readonly Box[] boxes = new Box[4];
|
||||
|
||||
protected override void Update()
|
||||
|
||||
@@ -12,10 +12,9 @@ using osu.Framework.Testing;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("ensure valid container state in various scenarios")]
|
||||
public class TestCaseContainerState : TestCase
|
||||
{
|
||||
public override string Description => "Ensuring a container's state is consistent in various scenarios.";
|
||||
|
||||
private readonly Container container;
|
||||
|
||||
public TestCaseContainerState()
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseContextMenu : TestCase
|
||||
{
|
||||
public override string Description => @"Menu visible on right click";
|
||||
|
||||
private const int start_time = 0;
|
||||
private const int duration = 1000;
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ using osu.Framework.Testing;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
internal class TestCaseDspfContainer : TestCase
|
||||
internal class TestCaseDrawSizePreservingFillContainer : TestCase
|
||||
{
|
||||
public TestCaseDspfContainer()
|
||||
public TestCaseDrawSizePreservingFillContainer()
|
||||
{
|
||||
DrawSizePreservingFillContainer fillContainer;
|
||||
Child = new Container
|
||||
@@ -57,7 +57,5 @@ namespace osu.Framework.Tests.Visual
|
||||
AddSliderStep("Width", 50, 650, 500, v => Child.Width = v);
|
||||
AddSliderStep("Height", 50, 650, 500, v => Child.Height = v);
|
||||
}
|
||||
|
||||
public override string Description => @"DrawSize-preserving fill container.";
|
||||
}
|
||||
}
|
||||
@@ -103,8 +103,6 @@ namespace osu.Framework.Tests.Visual
|
||||
Colour = Color4.White,
|
||||
};
|
||||
|
||||
public override string Description => @"Various cases of drawable paths.";
|
||||
|
||||
private class UserDrawnPath : Path
|
||||
{
|
||||
public override bool HandleInput => true;
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseDropdownBox : TestCase
|
||||
{
|
||||
public override string Description => @"Drop-down boxes";
|
||||
|
||||
private const int items_to_add = 10;
|
||||
|
||||
public TestCaseDropdownBox()
|
||||
|
||||
@@ -13,10 +13,9 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("changing depth of child dynamically")]
|
||||
public class TestCaseDynamicDepth : TestCase
|
||||
{
|
||||
public override string Description => @"Dynamically change depth of a child.";
|
||||
|
||||
private void addDepthSteps(DepthBox box, Container container)
|
||||
{
|
||||
AddStep($@"bring forward {box.Name}", () => container.ChangeChildDepth(box, box.Depth - 1));
|
||||
|
||||
@@ -15,10 +15,9 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("implementing the IEffect interface")]
|
||||
internal class TestCaseEffects : TestCase
|
||||
{
|
||||
public override string Description => "Tests classes implement the IEffect interface.";
|
||||
|
||||
public TestCaseEffects()
|
||||
{
|
||||
var effect = new EdgeEffect
|
||||
|
||||
@@ -20,10 +20,8 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
internal class TestCaseFlow : TestCase
|
||||
internal class TestCaseFillFlowContainer : TestCase
|
||||
{
|
||||
public override string Description => "Test lots of different settings for Flow Containers";
|
||||
|
||||
private FillDirectionDropdown selectionDropdown;
|
||||
|
||||
private Anchor childAnchor = Anchor.TopLeft;
|
||||
@@ -36,7 +34,7 @@ namespace osu.Framework.Tests.Visual
|
||||
private ScheduledDelegate scheduledAdder;
|
||||
private bool doNotAddChildren;
|
||||
|
||||
public TestCaseFlow()
|
||||
public TestCaseFillFlowContainer()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@@ -16,6 +16,7 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[System.ComponentModel.Description("sprite stretching")]
|
||||
internal class TestCaseFillModes : GridTestCase
|
||||
{
|
||||
public TestCaseFillModes() : base(3, 3)
|
||||
@@ -76,8 +77,6 @@ namespace osu.Framework.Tests.Visual
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description => @"Test sprite display and fill modes";
|
||||
|
||||
private Texture texture;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
||||
@@ -85,7 +85,5 @@ namespace osu.Framework.Tests.Visual
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description => @"Hollow Container with EdgeEffect";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[System.ComponentModel.Description("live path optimiastion")]
|
||||
internal class TestCaseInputResampler : GridTestCase
|
||||
{
|
||||
public TestCaseInputResampler() : base(3, 3)
|
||||
@@ -121,8 +122,6 @@ namespace osu.Framework.Tests.Visual
|
||||
Colour = Color4.White,
|
||||
};
|
||||
|
||||
public override string Description => @"Live optimizing paths to relevant nodes.";
|
||||
|
||||
private class SmoothedPath : Path
|
||||
{
|
||||
protected SmoothedPath()
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
public class TestCaseKeyBindings : GridTestCase
|
||||
{
|
||||
public override string Description => @"Keybindings";
|
||||
|
||||
public TestCaseKeyBindings()
|
||||
: base(2, 2)
|
||||
{
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseLocalisation : TestCase
|
||||
{
|
||||
public override string Description => "Localisation engine";
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly LocalisationEngine engine; //keep a reference to avoid GC of the engine
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseMasking : TestCase
|
||||
{
|
||||
public override string Description => @"Various scenarios which potentially challenge masking calculations.";
|
||||
|
||||
protected Container TestContainer;
|
||||
|
||||
public TestCaseMasking()
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseNestedHover : TestCase
|
||||
{
|
||||
public override string Description => @"Hovering multiple nested elements";
|
||||
|
||||
public TestCaseNestedHover()
|
||||
{
|
||||
HoverBox box1;
|
||||
|
||||
@@ -175,8 +175,6 @@ namespace osu.Framework.Tests.Visual
|
||||
});
|
||||
}
|
||||
|
||||
public override string Description => @"Add fixed padding via a PaddingContainer";
|
||||
|
||||
private class PaddedBox : Container
|
||||
{
|
||||
private readonly SpriteText t1;
|
||||
|
||||
@@ -11,10 +11,9 @@ using OpenTK;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[System.ComponentModel.Description("ensure validity of drawables when receiving certain values")]
|
||||
internal class TestCasePropertyBoundaries : TestCase
|
||||
{
|
||||
public override string Description => "Testing the validity of drawables after being passed certain values.";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseRigidBody : TestCase
|
||||
{
|
||||
public override string Description => @"Rigid body simulation scenarios.";
|
||||
|
||||
private readonly TestRigidBodySimulation sim;
|
||||
|
||||
private float restitutionBacking;
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseScreen : TestCase
|
||||
{
|
||||
public override string Description => @"Test stackable game screens";
|
||||
|
||||
public TestCaseScreen()
|
||||
{
|
||||
Add(new TestScreen());
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
private readonly ScheduledDelegate boxCreator;
|
||||
|
||||
public override string Description => @"A flow container in a scroll container";
|
||||
|
||||
private ScrollContainer scroll;
|
||||
private FillFlowContainer flow;
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseSearchContainer : TestCase
|
||||
{
|
||||
public override string Description => "Tests the SearchContainer";
|
||||
|
||||
public TestCaseSearchContainer()
|
||||
{
|
||||
SearchContainer<HeaderContainer> search;
|
||||
|
||||
@@ -14,10 +14,9 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("potentially challenging size calculations")]
|
||||
internal class TestCaseSizing : TestCase
|
||||
{
|
||||
public override string Description => @"Various scenarios which potentially challenge size calculations.";
|
||||
|
||||
private readonly Container testContainer;
|
||||
|
||||
public TestCaseSizing()
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
public class TestCaseSliderbar : TestCase
|
||||
{
|
||||
public override string Description => @"Sliderbar tests.";
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly BindableDouble sliderBarValue; //keep a reference to avoid GC of the bindable
|
||||
private readonly SpriteText sliderbarText;
|
||||
|
||||
@@ -46,8 +46,6 @@ namespace osu.Framework.Tests.Visual
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description => @"Boxes with automatically smoothed edges (no anti-aliasing).";
|
||||
|
||||
private readonly Box[] boxes = new Box[4];
|
||||
|
||||
protected override void Update()
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseSpriteText : TestCase
|
||||
{
|
||||
public override string Description => @"Test all sizes of text rendering";
|
||||
|
||||
public TestCaseSpriteText()
|
||||
{
|
||||
FillFlowContainer flow;
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseTabControl : TestCase
|
||||
{
|
||||
public override string Description => @"Tab control";
|
||||
|
||||
public TestCaseTabControl()
|
||||
{
|
||||
List<KeyValuePair<string, TestEnum>> items = new List<KeyValuePair<string, TestEnum>>();
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseTextBox : TestCase
|
||||
{
|
||||
public override string Description => @"Text entry evolved";
|
||||
|
||||
public TestCaseTextBox()
|
||||
{
|
||||
FillFlowContainer textBoxes = new FillFlowContainer
|
||||
|
||||
@@ -14,10 +14,9 @@ using OpenTK.Graphics;
|
||||
namespace osu.Framework.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[Description("word-wrap and paragraphs")]
|
||||
internal class TestCaseTextFlow : TestCase
|
||||
{
|
||||
public override string Description => @"Test word-wrapping and paragraphs";
|
||||
|
||||
public TestCaseTextFlow()
|
||||
{
|
||||
FillFlowContainer flow;
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseTooltip : TestCase
|
||||
{
|
||||
public override string Description => "Tooltip that shows when hovering a drawable";
|
||||
|
||||
private readonly Container testContainer;
|
||||
|
||||
public TestCaseTooltip()
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseTransformSequence : GridTestCase
|
||||
{
|
||||
public override string Description => @"Sequences (potentially looping) of transforms";
|
||||
|
||||
private readonly Container[] boxes;
|
||||
|
||||
public TestCaseTransformSequence()
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace osu.Framework.Tests.Visual
|
||||
[TestFixture]
|
||||
internal class TestCaseTriangles : TestCase
|
||||
{
|
||||
public override string Description => @"Various scenarios which potentially challenge triangles.";
|
||||
|
||||
private readonly Container testContainer;
|
||||
|
||||
public TestCaseTriangles()
|
||||
|
||||
@@ -75,12 +75,12 @@
|
||||
<Compile Include="Visual\TestCaseCountingText.cs" />
|
||||
<Compile Include="Visual\TestCaseDelayedLoad.cs" />
|
||||
<Compile Include="Visual\TestCaseDrawablePath.cs" />
|
||||
<Compile Include="Visual\TestCaseDspfContainer.cs" />
|
||||
<Compile Include="Visual\TestCaseDrawSizePreservingFillContainer.cs" />
|
||||
<Compile Include="Visual\TestCaseDropdownBox.cs" />
|
||||
<Compile Include="Visual\TestCaseDynamicDepth.cs" />
|
||||
<Compile Include="Visual\TestCaseEffects.cs" />
|
||||
<Compile Include="Visual\TestCaseFillModes.cs" />
|
||||
<Compile Include="Visual\TestCaseFlow.cs" />
|
||||
<Compile Include="Visual\TestCaseFillFlowContainer.cs" />
|
||||
<Compile Include="Visual\TestCaseGridContainer.cs" />
|
||||
<Compile Include="Visual\TestCaseHollowEdgeEffect.cs" />
|
||||
<Compile Include="Visual\TestCaseInputResampler.cs" />
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Framework.Testing.Drawables
|
||||
@@ -15,7 +15,7 @@ namespace osu.Framework.Testing.Drawables
|
||||
internal class TestCaseButton : ClickableContainer
|
||||
{
|
||||
private readonly Box box;
|
||||
private readonly Container text;
|
||||
private readonly TextFlowContainer text;
|
||||
|
||||
public readonly Type TestType;
|
||||
|
||||
@@ -46,9 +46,7 @@ namespace osu.Framework.Testing.Drawables
|
||||
|
||||
CornerRadius = 5;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Size = new Vector2(1, 60);
|
||||
|
||||
TestCase tempTestCase = (TestCase)Activator.CreateInstance(test);
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
@@ -58,35 +56,27 @@ namespace osu.Framework.Testing.Drawables
|
||||
Colour = new Color4(140, 140, 140, 255),
|
||||
Alpha = 0.7f
|
||||
},
|
||||
text = new Container
|
||||
text = new TextFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Left = 4,
|
||||
Right = 4,
|
||||
Bottom = 2,
|
||||
},
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = tempTestCase.Name,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Text = tempTestCase.Description,
|
||||
TextSize = 15,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
text.AddText(test.Name.Replace("TestCase", ""));
|
||||
|
||||
var description = test.GetCustomAttribute<DescriptionAttribute>()?.Description;
|
||||
if (description != null)
|
||||
{
|
||||
text.NewLine();
|
||||
text.AddText(description, t => t.TextSize = 15);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
@@ -101,4 +91,4 @@ namespace osu.Framework.Testing.Drawables
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace osu.Framework.Testing
|
||||
[TestFixture]
|
||||
public abstract class TestCase : Container, IDynamicallyCompile
|
||||
{
|
||||
public virtual string Description => @"The base class for a test case";
|
||||
|
||||
public readonly FillFlowContainer<Drawable> StepsContainer;
|
||||
private readonly Container content;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user