summaryrefslogtreecommitdiffstats
path: root/share/extensions/tests/test_guides_creator.py
blob: 4bb66b1b84c13a5a5e326674565e35b3a9664568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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",
        ),
    ]