@ -5,6 +5,7 @@ using Avalonia.Controls.Documents;
using Avalonia.Layout ;
using Avalonia.Layout ;
using Avalonia.Media ;
using Avalonia.Media ;
using Xunit ;
using Xunit ;
using static System . Net . Mime . MediaTypeNames ;
#if AVALONIA_SKIA
#if AVALONIA_SKIA
namespace Avalonia.Skia.RenderTests
namespace Avalonia.Skia.RenderTests
@ -176,5 +177,106 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
await RenderToFile ( target ) ;
await RenderToFile ( target ) ;
CompareImages ( ) ;
CompareImages ( ) ;
}
}
[InlineData(150, 200, TextWrapping.NoWrap)]
[InlineData(44, 200, TextWrapping.NoWrap)]
[InlineData(44, 400, TextWrapping.Wrap)]
[Win32Theory("Has text")]
public async Task Should_Measure_Arrange_TextBlock ( double width , double height , TextWrapping textWrapping )
{
var text = "Hello World" ;
var target = new StackPanel { Width = 2 0 0 , Height = height } ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Left ,
TextAlignment = TextAlignment . Left ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Left ,
TextAlignment = TextAlignment . Center ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Left ,
TextAlignment = TextAlignment . Right ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Center ,
TextAlignment = TextAlignment . Left ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Center ,
TextAlignment = TextAlignment . Center ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Center ,
TextAlignment = TextAlignment . Right ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Right ,
TextAlignment = TextAlignment . Left ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Right ,
TextAlignment = TextAlignment . Center ,
Width = width ,
TextWrapping = textWrapping
} ) ;
target . Children . Add ( new TextBlock
{
Text = text ,
Background = Brushes . Red ,
HorizontalAlignment = HorizontalAlignment . Right ,
TextAlignment = TextAlignment . Right ,
Width = width ,
TextWrapping = textWrapping
} ) ;
var testName = $"Should_Measure_Arrange_TextBlock_{width}_{textWrapping}" ;
await RenderToFile ( target , testName ) ;
CompareImages ( testName ) ;
}
}
}
}
}