summaryrefslogtreecommitdiffstats
path: root/share/extensions/tests/test_render_barcode_qrcode.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/extensions/tests/test_render_barcode_qrcode.py')
-rw-r--r--share/extensions/tests/test_render_barcode_qrcode.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/share/extensions/tests/test_render_barcode_qrcode.py b/share/extensions/tests/test_render_barcode_qrcode.py
new file mode 100644
index 0000000..2375891
--- /dev/null
+++ b/share/extensions/tests/test_render_barcode_qrcode.py
@@ -0,0 +1,101 @@
+# coding=utf-8
+from render_barcode_qrcode import QrCode, QRCode
+from inkex.tester import ComparisonMixin, TestCase
+
+
+class TestQRCodeInkscapeBasic(ComparisonMixin, TestCase):
+ """Test basic use of QR codes"""
+
+ effect_class = QrCode
+ compare_file = "svg/empty.svg"
+ comparisons = [
+ (
+ "--text=0123456789",
+ "--typenumber=0",
+ "--modulesize=10",
+ "--drawtype=smooth",
+ "--smoothness=greedy",
+ ),
+ (
+ "--text=BreadRolls",
+ "--typenumber=2",
+ "--encoding=utf8",
+ "--modulesize=10",
+ "--drawtype=smooth",
+ "--smoothness=greedy",
+ ),
+ (
+ "--text=Blue Front Yard",
+ "--typenumber=3",
+ "--correctionlevel=1",
+ "--modulesize=10",
+ "--drawtype=smooth",
+ "--smoothness=greedy",
+ ),
+ (
+ "--text=Waterfall",
+ "--typenumber=1",
+ "--drawtype=pathpreset",
+ "--pathtype=circle",
+ "--modulesize=10",
+ ),
+ (
+ "--text=groupid",
+ "--groupid=testid",
+ "--modulesize=10",
+ "--drawtype=smooth",
+ "--smoothness=greedy",
+ ),
+ ]
+
+
+class TestQRCodeInkscapeSelection(ComparisonMixin, TestCase):
+ """Test QR code with a selection as input"""
+
+ effect_class = QrCode
+ compare_file = "svg/shapes.svg"
+ comparisons = [
+ ("--text=test", "--drawtype=selection", "--id=r3", "--modulesize=10")
+ ]
+
+
+class TestQRCodeInkscapeSymbol(ComparisonMixin, TestCase):
+ """Test symbols in qr codes"""
+
+ effect_class = QrCode
+ compare_file = "svg/symbol.svg"
+ comparisons = [
+ (
+ "--text=ThingOne",
+ "--drawtype=symbol",
+ "--correctionlevel=2",
+ "--symbolid=AirTransportation_Inv",
+ "--modulesize=10",
+ ),
+ ]
+
+
+class TestLargeQRCodes(ComparisonMixin, TestCase):
+ """Test large qr codes with up to 2953 bytes of payload. Also tests numeric mode"""
+
+ effect_class = QrCode
+ compare_file = "svg/empty.svg"
+ comparisons = [
+ # the largest numeric QR code has 7089 characters
+ ("--text=" + (("12345" * 2000)[0:7089]), "--qrmode=1", "--correctionlevel=1"),
+ ]
+
+
+class TestQRCodeClasses(ComparisonMixin, TestCase):
+ """Test alphanumeric barcode"""
+
+ effect_class = QrCode
+ compare_file = "svg/empty.svg"
+ comparisons = [
+ (
+ "--text=THIS IS A TEST OF AN ALPHANUMERIC QRCODE. IT CAN STORE A LARGER NUMBER OF "
+ "UPPERSPACE CHARACTERS THAN A BYTE-ENCODED QRCODE: 123",
+ "--qrmode=2",
+ "--correctionlevel=1",
+ ),
+ ]