summaryrefslogtreecommitdiffstats
path: root/share/extensions/tests/test_guides_creator.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /share/extensions/tests/test_guides_creator.py
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/extensions/tests/test_guides_creator.py')
-rw-r--r--share/extensions/tests/test_guides_creator.py109
1 files changed, 109 insertions, 0 deletions
diff --git a/share/extensions/tests/test_guides_creator.py b/share/extensions/tests/test_guides_creator.py
new file mode 100644
index 0000000..4bb66b1
--- /dev/null
+++ b/share/extensions/tests/test_guides_creator.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+# coding=utf-8
+from guides_creator import GuidesCreator
+from inkex.tester import ComparisonMixin, InkscapeExtensionTestMixin, TestCase
+from inkex.tester.filters import CompareNumericFuzzy
+
+
+class GuidesCreatorBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase):
+ """Basic tests for GuidesCreator"""
+
+ effect_class = GuidesCreator
+ compare_file = "svg/guides.svg"
+ compare_filters = [
+ CompareNumericFuzzy(),
+ ]
+ old_defaults = (
+ "--vertical_guides=3",
+ "--ul=True",
+ "--ur=True",
+ "--ll=True",
+ "--lr=True",
+ "--header_margin=6",
+ "--footer_margin=6",
+ "--left_margin=6",
+ "--right_margin=6",
+ )
+ comparisons = [
+ old_defaults + ("--tab=regular_guides", "--guides_preset=custom"),
+ old_defaults
+ + ("--tab=regular_guides", "--guides_preset=golden", "--delete=True"),
+ old_defaults
+ + ("--tab=regular_guides", "--guides_preset=5;5", "--start_from_edges=True"),
+ old_defaults + ("--tab=diagonal_guides", "--nodup=False"),
+ old_defaults
+ + ("--tab=margins", "--start_from_edges=True", "--margins_preset=custom"),
+ old_defaults
+ + ("--tab=margins", "--start_from_edges=True", "--margins_preset=book_left"),
+ old_defaults
+ + ("--tab=margins", "--start_from_edges=True", "--margins_preset=book_right"),
+ ]
+
+
+class GuidesCreatorMillimeterTest(ComparisonMixin, TestCase):
+ """Test that guides are correctly created in a mm based document"""
+
+ effect_class = GuidesCreator
+ compare_file = "svg/complextransform.test.svg"
+ compare_filters = [CompareNumericFuzzy()]
+ comparisons = [
+ ("--vertical_guides=6", "--horizontal_guides=8"),
+ ("--tab=regular_guides", "--start_from_edges=True", "--guides_preset=golden"),
+ (
+ "--tab=regular_guides",
+ "--start_from_edges=True",
+ "--guides_preset=custom",
+ "--vertical_guides=4",
+ "--horizontal_guides=5",
+ ),
+ (
+ "--tab=margins",
+ "--start_from_edges=False",
+ "--margins_preset=book_right",
+ "--vert=3",
+ "--horz=2",
+ ),
+ ]
+
+
+class GuidesTestMulitpage(ComparisonMixin, TestCase):
+ """Test multipage functionality"""
+
+ effect_class = GuidesCreator
+ compare_file = "svg/empty_multipage.svg"
+ compare_filters = [CompareNumericFuzzy()]
+ comparisons = [
+ (), # by default, all pages
+ # selection of pages
+ ("--vertical_guides=4", "--horizontal_guides=3", "--pages=1,,3-7,12"),
+ # diagonal guides
+ (
+ "--tab=diagonal_guides",
+ "--nodup=False",
+ "--pages=1-3",
+ "--ul=True",
+ "--ur=True",
+ "--ll=True",
+ "--lr=True",
+ ),
+ # There is one diagonal guide already in the file, it should be unchanged
+ (
+ "--tab=diagonal_guides",
+ "--nodup=True",
+ "--pages=1-3",
+ "--ul=True",
+ "--ur=True",
+ "--ll=True",
+ "--lr=True",
+ ),
+ (
+ "--tab=margins",
+ "--start_from_edges=True",
+ "--margins_preset=book_alternating_left",
+ ),
+ (
+ "--tab=margins",
+ "--start_from_edges=False",
+ "--margins_preset=book_alternating_right",
+ ),
+ ]