csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.5 KiB
80 lines
2.5 KiB
using Avalonia.Media;
|
|
using Avalonia.UnitTests;
|
|
using Avalonia.Media.TextFormatting;
|
|
using Avalonia.Controls.Documents;
|
|
using Xunit;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Avalonia.Controls.UnitTests
|
|
{
|
|
public class InlineTests : ScopedTestBase
|
|
{
|
|
[Fact]
|
|
public void Should_Inherit_FontWeight_In_Nested_Inlines()
|
|
{
|
|
var bold = new Bold();
|
|
var span = new Span();
|
|
var run = new Run("Test");
|
|
span.Inlines.Add(run);
|
|
bold.Inlines.Add(span);
|
|
|
|
var textRuns = new List<TextRun>();
|
|
bold.BuildTextRun(textRuns, default);
|
|
|
|
var runProperties = textRuns[0].Properties;
|
|
Assert.Equal(FontWeight.Bold, runProperties.Typeface.Weight);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_Inherit_FontStyle_In_Nested_Inlines()
|
|
{
|
|
var italic = new Italic();
|
|
var span = new Span();
|
|
var run = new Run("Test");
|
|
span.Inlines.Add(run);
|
|
italic.Inlines.Add(span);
|
|
|
|
var textRuns = new List<TextRun>();
|
|
italic.BuildTextRun(textRuns, default);
|
|
|
|
var runProperties = textRuns[0].Properties;
|
|
Assert.Equal(FontStyle.Italic, runProperties.Typeface.Style);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_Inherit_FontStretch_In_Nested_Inlines()
|
|
{
|
|
var span = new Span();
|
|
var innerSpan = new Span();
|
|
var run = new Run("Test");
|
|
span.FontStretch = FontStretch.Condensed;
|
|
innerSpan.Inlines.Add(run);
|
|
span.Inlines.Add(innerSpan);
|
|
|
|
var textRuns = new List<TextRun>();
|
|
span.BuildTextRun(textRuns, default);
|
|
|
|
var runProperties = textRuns[0].Properties;
|
|
Assert.Equal(FontStretch.Condensed, runProperties.Typeface.Stretch);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_Inherit_Background_In_Nested_Inlines()
|
|
{
|
|
var backgroundBrush = Brushes.Red;
|
|
var span = new Span();
|
|
var innerSpan = new Span();
|
|
var run = new Run("Test");
|
|
|
|
span.Background = backgroundBrush;
|
|
innerSpan.Inlines.Add(run);
|
|
span.Inlines.Add(innerSpan);
|
|
|
|
var textRuns = new List<TextRun>();
|
|
span.BuildTextRun(textRuns, default);
|
|
|
|
var runProperties = textRuns[0].Properties;
|
|
Assert.Equal(backgroundBrush, runProperties.BackgroundBrush);
|
|
}
|
|
}
|
|
}
|
|
|