diff options
author | Jose Medrano <jose.medrano@microsoft.com> | 2018-11-27 11:40:11 +0300 |
---|---|---|
committer | Jose Medrano <jose.medrano@microsoft.com> | 2018-11-27 12:33:12 +0300 |
commit | 4715b2977456c8ff864a70955874640352cd1f16 (patch) | |
tree | 5ffb9cd2109578e6dddeb8375fb50b765ff324d8 /Testing | |
parent | 4e6e8bb6965ddb34197ba64ea7a7416824c0b51f (diff) |
Adds fontsize to span
Diffstat (limited to 'Testing')
-rw-r--r-- | Testing/Tests/FormattedTextTests.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Testing/Tests/FormattedTextTests.cs b/Testing/Tests/FormattedTextTests.cs index fb984140..36d2b9dd 100644 --- a/Testing/Tests/FormattedTextTests.cs +++ b/Testing/Tests/FormattedTextTests.cs @@ -67,6 +67,46 @@ namespace Xwt } [Test] + public void ParseFontSize () + { + //relative checks + string currentSpan; + FormattedText ft; + FontSizeTextAttribute at; + float currentSizeValue; + + foreach (var item in new string[] { "smaller", "larger" }) { + currentSpan = $"<span size='{item}'>(support-v7)</span>"; + ft = FormattedText.FromMarkup (currentSpan); + Assert.AreEqual (1, ft.Attributes.Count); + Assert.IsAssignableFrom<FontSizeTextAttribute> (ft.Attributes[0]); + at = (FontSizeTextAttribute)ft.Attributes[0]; + Assert.AreEqual ((float) Xwt.Drawing.Font.SystemFont.Size, at.Size); + } + + //absolute size check + foreach (var currentSize in FontSizeTextAttribute.SizeAbsoluteValues.Keys) { + currentSizeValue = FontSizeTextAttribute.SizeAbsoluteValues[currentSize]; + currentSpan = $"<span size='{currentSize}'>(support-v7)</span>"; + ft = FormattedText.FromMarkup (currentSpan); + Assert.AreEqual (1, ft.Attributes.Count); + Assert.IsAssignableFrom<FontSizeTextAttribute> (ft.Attributes[0]); + at = (FontSizeTextAttribute)ft.Attributes[0]; + Assert.AreEqual (currentSizeValue, at.Size); + } + + //numeric value + currentSizeValue = 14.5f; + var pagoSizeValue = currentSizeValue * FontSizeTextAttribute.MaxSize; + currentSpan = $"<span size='{pagoSizeValue}'>(support-v7)</span>"; + ft = FormattedText.FromMarkup (currentSpan); + Assert.AreEqual (1, ft.Attributes.Count); + Assert.IsAssignableFrom<FontSizeTextAttribute> (ft.Attributes[0]); + at = (FontSizeTextAttribute)ft.Attributes[0]; + Assert.AreEqual (currentSizeValue, at.Size); + } + + [Test] public void ParseFontWeight () { var s = "0<b>12</b><span weight='ultrabold'>34</span><span font-weight='Light'>56</span>"; |