Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Medrano <jose.medrano@microsoft.com>2018-11-27 21:37:21 +0300
committerJose Medrano <jose.medrano@microsoft.com>2018-11-27 21:37:21 +0300
commit0f33ce7d7c7e2fc35b79e4561ee9663ee20dfbbc (patch)
treed1c8dd5e89bebb5fc2e492fd79cfc4474d438303 /Testing
parentf7ce8ff0c31290d8306f4aab882224a61556322d (diff)
Adds compatibility for sizes in PT in markup
Diffstat (limited to 'Testing')
-rw-r--r--Testing/Tests/FormattedTextTests.cs42
1 files changed, 19 insertions, 23 deletions
diff --git a/Testing/Tests/FormattedTextTests.cs b/Testing/Tests/FormattedTextTests.cs
index 36d2b9dd..252c7597 100644
--- a/Testing/Tests/FormattedTextTests.cs
+++ b/Testing/Tests/FormattedTextTests.cs
@@ -70,42 +70,38 @@ namespace Xwt
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);
+ AssertFirstAttribute (item, (float)Xwt.Drawing.Font.SystemFont.Size);
}
+ float currentSizeValue;
//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);
+ AssertFirstAttribute (currentSize, currentSizeValue);
}
- //numeric value
+ //pango size values
currentSizeValue = 14.5f;
- var pagoSizeValue = currentSizeValue * FontSizeTextAttribute.MaxSize;
- currentSpan = $"<span size='{pagoSizeValue}'>(support-v7)</span>";
- ft = FormattedText.FromMarkup (currentSpan);
+ var pagoSizeValue = currentSizeValue * PangoScale;
+ AssertFirstAttribute (pagoSizeValue.ToString (), currentSizeValue);
+
+ //pt values
+ AssertFirstAttribute (currentSizeValue.ToString (), currentSizeValue);
+ }
+
+ void AssertFirstAttribute (string size, float resultSize)
+ {
+ var currentSpan = $"<span size='{size}'>(support-v7)</span>";
+ var 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);
+ var at = (FontSizeTextAttribute)ft.Attributes[0];
+ Assert.AreEqual (resultSize, at.Size);
}
+ const int PangoScale = 1024;
+
[Test]
public void ParseFontWeight ()
{