summaryrefslogtreecommitdiffstats
path: root/share/extensions/tests/test_color_replace.py
blob: 082e8c166fec48beb278cab0c24ecfcedca0668c (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
# coding=utf-8
from color_replace import ReplaceColor
from .test_inkex_extensions import ColorBaseCase
from inkex import Color
from inkex.tester import ComparisonMixin, TestCase


class ColorReplaceTest(ColorBaseCase):
    effect_class = ReplaceColor
    color_tests = [
        ("none", "none"),
        ((0, 0, 0), "#ff0000", []),
        ((128, 0, 0), "#800000", []),
        ((0, 0, 0), "#696969", ["-t1768516095"]),
        ((0, 0, 0), "#000000", ["-f1", "-t1768516095", "-i=False"]),
        ((18, 52, 86), "#696969", ["-f305420031", "-t1768516095"]),
        ((18, 52, 86), "#ff0000", ["-f305420031"]),
        (
            Color([10, 20, 30, 0.2], space="rgba"),
            Color([255, 0, 0, 20 / 255], space="rgba"),
            ["-f169090611", "-t4278190100"],
        ),
        (
            Color([10, 20, 30, 0.5], space="rgba"),
            Color([10, 20, 30, 0.5], space="rgba"),
            ["-f169090611", "-t4278190100", "-i=False"],
        ),
        (
            Color([10, 20, 30, 0.5], space="rgba"),
            Color([255, 0, 0, 20 / 255], space="rgba"),
            ["-f169090611", "-t4278190100"],
        ),
    ]


class ColorReplacePatternTest(ComparisonMixin, TestCase):
    effect_class = ReplaceColor
    compare_file = "svg/simple_patterns.svg"
    comparisons = [("--id=rect184",), ("--id=rect184", "--id=rect184-8")]