Browse Source

add failing test for formatter for #4806

Andrey Kunchev 5 years ago
parent
commit
0f81b0fc93

+ 28 - 0
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs

@@ -293,6 +293,34 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
             }
         }
 
+        [Fact]
+        public void Wrap_Should_Not_Produce_Empty_Lines()
+        {
+            using (Start())
+            {
+                const string text = "012345";
+
+                var defaultProperties = new GenericTextRunProperties(Typeface.Default);
+                var paragraphProperties = new GenericTextParagraphProperties(defaultProperties, textWrapping: TextWrapping.Wrap);
+                var textSource = new SingleBufferTextSource(text, defaultProperties);
+                var formatter = new TextFormatterImpl();
+
+                var textSourceIndex = 0;
+
+                while (textSourceIndex < text.Length)
+                {
+                    var textLine =
+                        formatter.FormatLine(textSource, textSourceIndex, 3, paragraphProperties);
+
+                    Assert.NotEqual(0, textLine.TextRange.Length);
+
+                    textSourceIndex += textLine.TextRange.Length;
+                }
+
+                Assert.Equal(text.Length, textSourceIndex);
+            }
+        }
+
         public static IDisposable Start()
         {
             var disposable = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface