From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- share/extensions/tests/test_hershey.py | 77 ++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 share/extensions/tests/test_hershey.py (limited to 'share/extensions/tests/test_hershey.py') diff --git a/share/extensions/tests/test_hershey.py b/share/extensions/tests/test_hershey.py new file mode 100644 index 0000000..f698982 --- /dev/null +++ b/share/extensions/tests/test_hershey.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# tests for the hershey-text extension (hershey.py and hershey.inx) +from lxml import etree + +from inkex.tester import ComparisonMixin, InkscapeExtensionTestMixin, TestCase +from inkex.tester.filters import CompareNumericFuzzy, CompareOrderIndependentStyle + +from hershey import Hershey + + +class HersheyComparisonMixin(ComparisonMixin): + comparisons_cmpfile_dict = {} # pairs of args and expected outputs + + def setUp(self): + self.effect_class = Hershey + self.compare_filters = [CompareNumericFuzzy(), CompareOrderIndependentStyle()] + + self.comparisons = self.comparisons_cmpfile_dict.keys() + + def get_compare_cmpfile(self, args, addout=None): + """get the correct cmpfile to compare from comparisons_dict;""" + return self.data_file("refs", self.comparisons_cmpfile_dict[args]) + + +class TestHersheyBasic(InkscapeExtensionTestMixin, HersheyComparisonMixin, TestCase): + compare_file = "svg/hershey_input.svg" # a huge number of inputs + comparisons_cmpfile_dict = { + # default parameters: + (): "hershey.out", + # same as above, but explicit parameters. same output: + ( + '--tab="render"', + '--fontface="HersheySans1"', + '--preserve="False"', + ): "hershey.out", + } + + +class TestHersheyTrivialInput( + InkscapeExtensionTestMixin, HersheyComparisonMixin, TestCase +): + compare_file = "svg/hershey_trivial_input.svg" + comparisons_cmpfile_dict = { + # loading a different font: + ('--fontface="EMSAllure"',): "hershey_loadfont.out", + # using the "other font" option. same output as above: + ('--fontface="other"', '--otherfont="EMSAllure"'): "hershey_loadfont.out", + # tests preserve text option + ('--fontface="EMSOsmotron"', "--preserve=true"): "hershey_preservetext.out", + # tests when just part of the input file is selected + ("--id=A",): "hershey_partialselection.out", + } + + +class TestHersheyTables(InkscapeExtensionTestMixin, HersheyComparisonMixin, TestCase): + compare_file = "svg/default-inkscape-SVG.svg" + comparisons_cmpfile_dict = { + # generates a simple font table: + ( + '--tab="utilities"', + '--action="sample"', + '--text="I am a quick brown fox"', + ): "hershey_fonttable.out", + # generates a simple font table, while testing UTF-8 input + ( + '--tab="utilities"', + '--action="sample"', + '--text="Î âm å qù¡çk brõwñ fø×"', + ): "hershey_encoding.out", + # generates a glyph table in the font "EMSOsmotron" + ( + '--tab="utilities"', + '--action="table"', + '--fontface="other"', + '--otherfont="EMSOsmotron"', + ): "hershey_glyphtable.out", + } -- cgit v1.2.3