summaryrefslogtreecommitdiffstats
path: root/share/extensions/tests/test_layer2png.py
blob: d1d7b84ff86058428ce8be1374351233cf8aff1c (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
"""
Test export slices of an image.
"""

from inkex.tester import ComparisonMixin, TestCase
from layer2png import ExportSlices


class Layer2PNGTest(ComparisonMixin, TestCase):
    effect_class = ExportSlices
    compare_file = "svg/slicer.svg"
    comparisons = []

    def test_get_layers(self):
        basic_svg = self.data_file("svg", "slicer.svg")
        args = [basic_svg, "--layer=slices"]
        self.effect.options = self.effect.arg_parser.parse_args(args)
        self.effect.options.input_file = basic_svg
        self.effect.load_raw()
        nodes = self.effect.get_layer_nodes("slices")
        self.assertEqual(len(nodes), 1)
        self.assertEqual(nodes[0].tag, "{http://www.w3.org/2000/svg}rect")

    def test_bad_slice_layer(self):
        basic_svg = self.data_file("svg", "slicer.svg")
        args = [basic_svg, "--layer=slices"]
        self.effect.options = self.effect.arg_parser.parse_args(args)
        self.effect.options.input_file = basic_svg
        self.effect.load_raw()
        nodes = self.effect.get_layer_nodes("badslices")
        self.assertEqual(nodes, None)

    def test_color(self):
        basic_svg = self.data_file("svg", "slicer.svg")
        args = [basic_svg, "--layer=slices"]
        self.effect.options = self.effect.arg_parser.parse_args(args)
        self.effect.options.input_file = basic_svg
        self.effect.load_raw()
        nodes = self.effect.get_layer_nodes("slices")
        color, kwargs = self.effect.get_color_and_command_kwargs(nodes[0])
        self.assertEqual(color, self.effect.GREEN)
        self.assertEqual(kwargs["export-id"], "slice1")