1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:42:54 +08:00

Add TextBadgePair test case

This commit is contained in:
HoutarouOreki 2018-07-24 04:04:18 +02:00
parent 9e9d7a855d
commit 24bb44a152
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,50 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Overlays.Changelog.Header;
namespace osu.Game.Tests.Visual
{
public class TestCaseTextBadgePair : OsuTestCase
{
public TestCaseTextBadgePair()
{
Container container;
TextBadgePair textBadgePair;
Add(container = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 250,
Height = 50,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Gray,
Alpha = 0.5f,
RelativeSizeAxes = Axes.Both,
},
textBadgePair = new TextBadgePair(Color4.DeepSkyBlue, "Test")
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
}
});
AddStep(@"Deactivate", textBadgePair.Deactivate);
AddStep(@"Activate", textBadgePair.Activate);
AddStep(@"Hide text", () => textBadgePair.HideText(200));
AddStep(@"Show text", () => textBadgePair.ShowText(200));
AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider"));
AddWaitStep(1);
AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?.."));
}
}
}

View File

@ -37,6 +37,8 @@ namespace osu.Game.Overlays.Changelog.Header
{
TextSize = 21, // web: 16,
Text = displayText,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding
{
Top = 5,
@ -49,6 +51,7 @@ namespace osu.Game.Overlays.Changelog.Header
UncollapsedSize = 10,
Colour = badgeColour,
Anchor = Anchor.BottomCentre,
Origin = Anchor.Centre,
}
};
}
@ -69,7 +72,8 @@ namespace osu.Game.Overlays.Changelog.Header
// sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here
Scheduler.AddDelayed(() =>
{
if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText;
if (!string.IsNullOrEmpty(displayText))
Text.Text = displayText;
LineBadge.Uncollapse();
}, duration);
}