PIKApp/plug-ins/script-fu/test/tests/PDB/bind-args.scm

88 lines
2.3 KiB
Scheme
Raw Normal View History

2023-09-26 00:35:21 +02:00
; Test ScriptFu's binding to all Pika C arg types of the PDB
; The PDB procedures called are arbitrary, chosen for the type of their args.
; The test is only that no error is thrown, not necessarily that the call is effective.
; Test binding in both directions: args passed and args returned.
; Testing is not complete, but illustrative of special cases.
; Testing is not blindly exhaustive of every type declarable for PDB procedures.
; Testing is with knowledge of the code.
; Only testing representatives for cases in switch statement of scheme-wrapper.c.
; For example, the code has a case for GObject that covers most subclasses
; of PikaItem, so we only test once, say for PikaLayer.
; Also, we don't test all primitive types.
; We know they are tested drive-by in other tests,
; so we don't necessarily test them here.
; Int, String, Double, UInt
; Note that no PDB procedure takes or returns:
; gchar (the type for a single character.)
; GParam or PikaParam
; There is no case in scheme-wrapper.c.
; int
; float
; PikaRGB is tested e.g. with Palette
; PikaRGBArray is tested e.g.
; from palette-get-colormap
; to is not tested: not an arg to any PDB proc
; GStrv string array
; from brushes-get-list
; to file-gih-save or extension-pika-help
; TODO test GStrv to file-gih-save
; GBytes
; from image-get-colormap
; to image-set-colormap
; FloatArray
; from pika-context-get-line-dash-pattern
; to pika-context-set-line-dash-pattern
; PikaResource
; see resource.scm and context.scm
; GFile
; PikaParasite
; ScriptFu takes and returns a list of attributes of a PikaParasite
; A PikaParasite is a named string having a flags attribute ?
; Also tested elsewhere, many objects can have parasites.
; This tests the global parasites, on the pika instance.
; to
(assert '(pika-attach-parasite (list "foo" 1 "zed")))
; from
(assert `(equal? (car (pika-get-parasite "foo"))
'("foo" 1 "zed")))
; PikaUnit
; A PikaUnit is both an enum and an object???
; ScriptFu converts to int. More or less an ID.
; to
; unit index 0 is px
(assert '(string=? (car (pika-unit-get-abbreviation 0))
"px"))
; from
; default line width unit is px
(assert '(= (car (pika-context-get-line-width-unit))
0))