From 9246adc349f8e0e204029390548581d80ff2a87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 4 Nov 2021 21:32:57 +0100 Subject: [PATCH 1/2] Add failing test coverage for labelled drawable description visible --- .../Visual/UserInterface/TestSceneLabelledDrawable.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs index fe312ccc8f..d5dda6f6cd 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDrawable.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; @@ -65,10 +66,10 @@ namespace osu.Game.Tests.Visual.UserInterface private void createPaddedComponent(bool hasDescription = false, bool padded = true) { + LabelledDrawable component = null; + AddStep("create component", () => { - LabelledDrawable component; - Child = new Container { Anchor = Anchor.Centre, @@ -81,6 +82,8 @@ namespace osu.Game.Tests.Visual.UserInterface component.Label = "a sample component"; component.Description = hasDescription ? "this text describes the component" : string.Empty; }); + + AddAssert($"description {(hasDescription ? "visible" : "hidden")}", () => component.ChildrenOfType().ElementAt(1).IsPresent == hasDescription); } private class PaddedLabelledDrawable : LabelledDrawable From 4c8d6a77be6baaac0bd0ee739bb93728e6bfb883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 4 Nov 2021 21:38:01 +0100 Subject: [PATCH 2/2] Fix labelled drawable descriptions not showing --- osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs index 95884f1515..1e6032c1d0 100644 --- a/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs +++ b/osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs @@ -168,7 +168,7 @@ namespace osu.Game.Graphics.UserInterfaceV2 { descriptionText.Text = value; - if (value == default) + if (!string.IsNullOrEmpty(value.ToString())) descriptionText.Show(); else descriptionText.Hide();