From 54a53ae8b7891ab90e2fd9187a7a6b80eb5ad66b Mon Sep 17 00:00:00 2001 From: lloyd konneker Date: Wed, 8 Jan 2025 11:53:58 -0500 Subject: [PATCH 1/3] ScriptFu: tests: fix tests broken between 2.99 and 3.0rc2 No changes other than to test framework and tests. --- .../script-fu/test/frameworks/testing.scm | 4 +++- .../test/tests/PDB/image/image-new.scm | 3 ++- .../test/tests/PDB/image/image-precision.scm | 24 ++++++++++--------- .../test/tests/PDB/paint/dynamics.scm | 16 +++++++------ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/plug-ins/script-fu/test/frameworks/testing.scm b/plug-ins/script-fu/test/frameworks/testing.scm index 91432c56276..1050e1f63d8 100644 --- a/plug-ins/script-fu/test/frameworks/testing.scm +++ b/plug-ins/script-fu/test/frameworks/testing.scm @@ -112,7 +112,9 @@ ; except by proximity in the output. (define (test! string) (displayln "") - (displayln string)) + (displayln string) + ; also to GIMP Error Console + (gimp-message string)) ; reset testing state when test framework is loaded diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-new.scm b/plug-ins/script-fu/test/tests/PDB/image/image-new.scm index bf2fe48aea3..195ee4ee459 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-new.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-new.scm @@ -159,7 +159,8 @@ ; Dimension zero yields error ; It does NOT yield invalid ID -1 (assert-error `(gimp-image-new 0 0 RGB) - "argument 1 in call to gimp-image-new has value 0 out of range: 1 to 524288") + "Invalid value for argument 0") +; FORMERLY "argument 1 in call to gimp-image-new has value 0 out of range: 1 to 524288") ; Since 3.0, parameter validation catches this earlier. ; Formerly, "Procedure execution of gimp-image-new failed on invalid input arguments: " diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm b/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm index 5e355a96f93..2ed841993cd 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm @@ -45,14 +45,23 @@ ; New with precision + +; GAMMA obsolete since 3.0 +; PRECISION-U8-GAMMA +; PRECISION-U16-GAMMA +; PRECISION-U32-GAMMA +; PRECISION-HALF-GAMMA +; PRECISION-FLOAT-GAMMA +; PRECISION-DOUBLE-GAMMA + ; setup -(define testImageWithPrecision (car (gimp-image-new-with-precision 21 22 RGB PRECISION-DOUBLE-GAMMA))) +(define testImageWithPrecision (car (gimp-image-new-with-precision 21 22 RGB PRECISION-U8-PERCEPTUAL))) ; image has given precision (assert `(= (car (gimp-image-get-precision ,testImageWithPrecision)) - PRECISION-DOUBLE-GAMMA )) + PRECISION-U8-PERCEPTUAL )) @@ -63,9 +72,8 @@ ,testImage ,precision)))) -; First convert away from first precision in list: +; Assert precision is not first precision in list: ; it will fail if image already that precision -(gimp-image-convert-precision testImage PRECISION-U8-NON-LINEAR) (define allPrecisions `(PRECISION-U8-LINEAR @@ -85,13 +93,7 @@ PRECISION-FLOAT-PERCEPTUAL PRECISION-DOUBLE-LINEAR PRECISION-DOUBLE-NON-LINEAR - PRECISION-DOUBLE-PERCEPTUAL - PRECISION-U8-GAMMA - PRECISION-U16-GAMMA - PRECISION-U32-GAMMA - PRECISION-HALF-GAMMA - PRECISION-FLOAT-GAMMA - PRECISION-DOUBLE-GAMMA)) + PRECISION-DOUBLE-PERCEPTUAL)) ; sequence through all precisions, converting testImage to them (for-each diff --git a/plug-ins/script-fu/test/tests/PDB/paint/dynamics.scm b/plug-ins/script-fu/test/tests/PDB/paint/dynamics.scm index 1ced87f5585..e403005e96b 100644 --- a/plug-ins/script-fu/test/tests/PDB/paint/dynamics.scm +++ b/plug-ins/script-fu/test/tests/PDB/paint/dynamics.scm @@ -23,7 +23,7 @@ FALSE) ; not closed ; make test harder by using float precision -(gimp-image-convert-precision testImage PRECISION-DOUBLE-GAMMA) +(gimp-image-convert-precision testImage PRECISION-DOUBLE-NON-LINEAR) ; ensure testing is stroking with paint (versus line) (gimp-context-set-stroke-method STROKE-PAINT-METHOD) ; ensure testing is painting with paintbrush (versus pencil, airbrush, etc.) @@ -38,7 +38,8 @@ ; introspection: gimp module returns list of names of dynamics ; second arg is a regex -(assert `(list? (gimp-dynamics-get-list ""))) +; FORMERLY get-list +(assert `(list? (gimp-dynamics-get-name-list ""))) ; refresh: gimp module will load newly installed dynamics ; method is void and should never fail. @@ -67,9 +68,10 @@ ; the dynamics setting can be set to the name of a dynamics -(assert `(gimp-context-set-dynamics "Tilt Angle")) -; setting to false was effective -(assert `(string=? (car (gimp-context-get-dynamics)) +(assert `(gimp-context-set-dynamics-name "Tilt Angle")) +; setting was effective +; formerly context-[set,get]-dynamics +(assert `(string=? (car (gimp-context-get-dynamics-name)) "Tilt Angle")) @@ -81,11 +83,11 @@ ; stroke a drawable along a path with current brush and dynamics -(define dynamicsList (car (gimp-dynamics-get-list ""))) +(define dynamicsList (car (gimp-dynamics-get-name-list ""))) (define (testDynamics dynamics) ; Test that every dynamics can be set on the context - (gimp-context-set-dynamics dynamics) + (gimp-context-set-dynamics-name dynamics) (display dynamics) ; paint with paintbrush and dynamics, under the test harness -- GitLab From b14b17fa53361e5c6b9e1a3702598da83754ad51 Mon Sep 17 00:00:00 2001 From: lloyd konneker Date: Wed, 8 Jan 2025 12:03:08 -0500 Subject: [PATCH 2/3] ScriptFu: fix relay error when marshalling args Broken in previous commit to this file. An error return from script_fu_marshal_arg_to_value must be relayed. --- plug-ins/script-fu/libscriptfu/scheme-wrapper.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plug-ins/script-fu/libscriptfu/scheme-wrapper.c b/plug-ins/script-fu/libscriptfu/scheme-wrapper.c index 3211d1d2c77..99dc7ae6a32 100644 --- a/plug-ins/script-fu/libscriptfu/scheme-wrapper.c +++ b/plug-ins/script-fu/libscriptfu/scheme-wrapper.c @@ -728,6 +728,7 @@ ts_load_file (const gchar *dirname, return FALSE; } +/* Returns pointer to sc->NIL (normal) or pointer to error. */ static pointer script_fu_marshal_arg_to_value (scheme *sc, pointer a, @@ -1504,7 +1505,13 @@ script_fu_marshal_procedure_call (scheme *sc, debug_in_arg (sc, a, i, g_type_name (G_VALUE_TYPE (&value))); - script_fu_marshal_arg_to_value (sc, a, proc_name, i, arg_spec, &value); + return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, i, arg_spec, &value); + + if (return_val != sc->NIL) + { + g_value_unset (&value); + return return_val; + } debug_gvalue (&value); if (g_param_value_validate (arg_spec, &value)) -- GitLab From 8f1be83840cc300a7b28334eae0942e1c421bcad Mon Sep 17 00:00:00 2001 From: lloyd konneker Date: Thu, 9 Jan 2025 16:40:05 -0500 Subject: [PATCH 3/3] ScriptFu: tests: revise for recent changes to API circa 3.0rc2 No changes except to tests. Mostly minor, except major changes to testing calls to gegl filters. --- .../script-fu/test/frameworks/testing.scm | 2 +- .../test/tests/PDB/channel/channel-new.scm | 3 +- .../script-fu/test/tests/PDB/color/color.scm | 6 +- .../test/tests/PDB/drawable/drawable.scm | 2 + .../script-fu/test/tests/PDB/edit/buffer.scm | 18 +- .../script-fu/test/tests/PDB/edit/edit.scm | 6 +- .../script-fu/test/tests/PDB/gimp/PDB.scm | 4 +- .../script-fu/test/tests/PDB/gimp/refresh.scm | 50 +-- .../tests/PDB/image/image-color-profile.scm | 2 +- .../test/tests/PDB/image/image-grayscale.scm | 2 +- .../test/tests/PDB/image/image-indexed.scm | 2 +- .../test/tests/PDB/image/image-new.scm | 4 +- .../test/tests/PDB/image/image-precision.scm | 71 ++-- .../test/tests/PDB/layer/layer-ops.scm | 3 +- plug-ins/script-fu/test/tests/PDB/pdb.scm | 2 + .../script-fu/test/tests/Plugins/gegl.scm | 326 +++++++++++++----- 16 files changed, 332 insertions(+), 171 deletions(-) diff --git a/plug-ins/script-fu/test/frameworks/testing.scm b/plug-ins/script-fu/test/frameworks/testing.scm index 1050e1f63d8..02811150b9a 100644 --- a/plug-ins/script-fu/test/frameworks/testing.scm +++ b/plug-ins/script-fu/test/frameworks/testing.scm @@ -441,7 +441,7 @@ ; FUTURE: platform independent path ; FUTURE: color profile test files in the repo (define (testing:path-to-color-profile name) - (string-append "/work/" name)) + (string-append "/work/colorProfilesICC/" name)) ; float comparison utility diff --git a/plug-ins/script-fu/test/tests/PDB/channel/channel-new.scm b/plug-ins/script-fu/test/tests/PDB/channel/channel-new.scm index c516c584fc8..789472d82e8 100644 --- a/plug-ins/script-fu/test/tests/PDB/channel/channel-new.scm +++ b/plug-ins/script-fu/test/tests/PDB/channel/channel-new.scm @@ -89,7 +89,8 @@ ; Delete throws error when channel already removed ; gimp-channel-delete is deprecated (assert-error `(gimp-item-delete ,testChannel) - "runtime: invalid item ID" ) + "Invalid value for argument 0") +; FORMERLY "runtime: invalid item ID" ) (test! "item-delete on channel") diff --git a/plug-ins/script-fu/test/tests/PDB/color/color.scm b/plug-ins/script-fu/test/tests/PDB/color/color.scm index d5809f20dfe..90382fe97eb 100644 --- a/plug-ins/script-fu/test/tests/PDB/color/color.scm +++ b/plug-ins/script-fu/test/tests/PDB/color/color.scm @@ -107,8 +107,10 @@ ; Note the rgb is black 0,0,0 , same as before conversion to indexed. ; Note the image still has an alpha and pixel 1,1 is transparent (assert `(equal? (gimp-drawable-get-pixel ,testDrawableIndexed 1 1) - '(139 127 114 0))) -; FIXME: strange behavior, should be, and sometimes is, '(0 0 0 0))) + '(0 0 0 0))) +; FIXME: strange behavior: +; sometimes '(139 127 114 0))) +; sometimes '(0 0 0 0))) (display (gimp-drawable-get-pixel testDrawableIndexed 1 1)) diff --git a/plug-ins/script-fu/test/tests/PDB/drawable/drawable.scm b/plug-ins/script-fu/test/tests/PDB/drawable/drawable.scm index 8acb4b6e15a..adcb88d61e1 100644 --- a/plug-ins/script-fu/test/tests/PDB/drawable/drawable.scm +++ b/plug-ins/script-fu/test/tests/PDB/drawable/drawable.scm @@ -36,10 +36,12 @@ ; 1 ; push merge to undo stack ; )) +; TODO document that signature changed in v3 (assert `(gimp-drawable-offset ,testDrawable 1 ; wrap around or fill OFFSET-WRAP-AROUND ; OffsetType + "white" ; color to fill background -2147483648 -2147483648 ; x, y )) diff --git a/plug-ins/script-fu/test/tests/PDB/edit/buffer.scm b/plug-ins/script-fu/test/tests/PDB/edit/buffer.scm index 5c8698675fd..5cc76df4579 100644 --- a/plug-ins/script-fu/test/tests/PDB/edit/buffer.scm +++ b/plug-ins/script-fu/test/tests/PDB/edit/buffer.scm @@ -8,10 +8,12 @@ ; E.G. gimp-edit-named-copy might be better named: "edit-copy-to-named-buffer" ; The API has no method to determine if the clipboard is empty -; buffers-get-list only gets the named buffers +; buffers-get-name-list only gets the named buffers ; Many calls take a regex string +; FORMERLY buffers-get-list => buffers-get-name-list + ; Prereq: no buffer exists yet. @@ -40,10 +42,10 @@ ; Since no selection, the buffer is same size as image ; Creation was effective: gimp knows the buffer -; get-list takes a regex, here empty "" -; get-list returns (("bufferName")) : a list of strings +; get-name-list takes a regex, here empty "" +; get-name-list returns (("bufferName")) : a list of strings ; and the first string is "bufferName" -(assert `(string=? (car (gimp-buffers-get-list "")) +(assert `(string=? (car (gimp-buffers-get-name-list "")) "bufferName")) ; buffer has same size as image when created with no selection @@ -74,13 +76,13 @@ "renamedName")) ; Effect renaming: gimp knows the renamed name -(assert `(string=? (car (gimp-buffers-get-list "")) +(assert `(string=? (car (gimp-buffers-get-name-list "")) "renamedName")) ; Renaming does not add another buffer -(assert `(= (length (gimp-buffers-get-list "")) +(assert `(= (length (gimp-buffers-get-name-list "")) 1)) -(display (gimp-buffers-get-list "")) +(display (gimp-buffers-get-name-list "")) (test! "buffer-delete") @@ -90,7 +92,7 @@ ; Delete was effective: gimp no longer knows ; and returns nil i.e. empty list (()) -(assert `(null? (gimp-buffers-get-list ""))) +(assert `(null? (gimp-buffers-get-name-list ""))) ; TODO test two buffers diff --git a/plug-ins/script-fu/test/tests/PDB/edit/edit.scm b/plug-ins/script-fu/test/tests/PDB/edit/edit.scm index dece1cc5796..8e4f0687887 100644 --- a/plug-ins/script-fu/test/tests/PDB/edit/edit.scm +++ b/plug-ins/script-fu/test/tests/PDB/edit/edit.scm @@ -38,7 +38,7 @@ (make-vector 1 testLayer) "testBufferName")) ; There is one named buffer -(assert `(= (length (gimp-buffers-get-list "")) 1)) +(assert `(= (length (gimp-buffers-get-name-list "")) 1)) @@ -97,7 +97,7 @@ (test! "named-paste") ; There is one named buffer -(assert `(= (length (gimp-buffers-get-list "")) 1)) +(assert `(= (length (gimp-buffers-get-name-list "")) 1)) ; named-paste returns just the floating sel (assert `(gimp-edit-named-paste @@ -159,7 +159,7 @@ ; There are still two layers (assert `(= (vector-length (gimp-image-get-layers ,testImage)) 2)) ; There is two named buffer -(assert `(= (length (gimp-buffers-get-list "")) +(assert `(= (length (gimp-buffers-get-name-list "")) 2)) diff --git a/plug-ins/script-fu/test/tests/PDB/gimp/PDB.scm b/plug-ins/script-fu/test/tests/PDB/gimp/PDB.scm index a3b30a30636..1786ad785fd 100644 --- a/plug-ins/script-fu/test/tests/PDB/gimp/PDB.scm +++ b/plug-ins/script-fu/test/tests/PDB/gimp/PDB.scm @@ -24,13 +24,13 @@ ; returns list of names ; empty regex matches anything, returns all procedure names in pdb -; Test exists more than 1000 procedures +; Test exists more than 900 procedures (assert `(> (length (car (gimp-pdb-query "" ; name "" "" ; blurb help "" "" ; authors copyright "" "" ; date type ))) - 1000)) + 900)) ; a query on a specific name returns the same name (assert `(string=? ( caar (gimp-pdb-query "gimp-pdb-proc-exists" ; name diff --git a/plug-ins/script-fu/test/tests/PDB/gimp/refresh.scm b/plug-ins/script-fu/test/tests/PDB/gimp/refresh.scm index 708e2d421dc..584c89a88d6 100644 --- a/plug-ins/script-fu/test/tests/PDB/gimp/refresh.scm +++ b/plug-ins/script-fu/test/tests/PDB/gimp/refresh.scm @@ -18,34 +18,40 @@ ; gimp-parasite-list => gimp-get-parasite-list -; refresh + +(script-fu-use-v3) + +(test! "refresh resources") ; always succeeds -; FIXME but wraps result in list (#t) -(assert `(car (gimp-brushes-refresh))) -(assert `(car (gimp-dynamics-refresh))) -(assert `(car (gimp-fonts-refresh))) -(assert `(car (gimp-gradients-refresh))) -(assert `(car (gimp-palettes-refresh))) -(assert `(car (gimp-patterns-refresh))) +; Returns #t +(assert `(gimp-brushes-refresh)) +(assert `(gimp-dynamics-refresh)) +(assert `(gimp-fonts-refresh)) +(assert `(gimp-gradients-refresh)) +(assert `(gimp-palettes-refresh)) +(assert `(gimp-patterns-refresh)) -; list +(test! "list resources") ; always succeeds -; take an optional regex string -(assert `(list? (car (gimp-brushes-get-list "")))) -(assert `(list? (car (gimp-dynamics-get-list "")))) -(assert `(list? (car (gimp-fonts-get-list "")))) -(assert `(list? (car (gimp-gradients-get-list "")))) -(assert `(list? (car (gimp-palettes-get-list "")))) -(assert `(list? (car (gimp-patterns-get-list "")))) +; Takes an optional regex string. +; Returns a vector of object ID's. +; !!! The name says its a list, but its an array +(assert `(vector? (gimp-brushes-get-list ""))) +(assert `(vector? (gimp-fonts-get-list ""))) +(assert `(vector? (gimp-gradients-get-list ""))) +(assert `(vector? (gimp-palettes-get-list ""))) +(assert `(vector? (gimp-patterns-get-list ""))) ; listing app's collection of things not resources ; But taking a regex -(assert `(list? (car (gimp-buffers-get-list "")))) +; Returns list of names, not a vector of object ID's +(assert `(list? (gimp-dynamics-get-name-list ""))) +(assert `(list? (gimp-buffers-get-name-list ""))) ; listing app's other collections not resources @@ -53,14 +59,18 @@ ; FIXME the naming does not follow the pattern, should be plural parasites ; Not: (gimp-parasites-get-list "") -(assert `(list? (car (gimp-get-parasite-list)))) +(assert `(list? (gimp-get-parasite-list))) ; the app, images, vectors, drawables, items ; can all have parasites. ; Tested elsewhere. +(test! "get images") ; gimp-get-images does not follow the pattern: ; it doesn't take a regex -; and it returns a vector of image objects (0 #()) -(assert `(vector? (car (gimp-get-images)))) +; and it returns a vector of image objects #() +(assert `(vector? (gimp-get-images))) + + +(script-fu-use-v2) \ No newline at end of file diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-color-profile.scm b/plug-ins/script-fu/test/tests/PDB/image/image-color-profile.scm index b6a777efc93..512d7863f9b 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-color-profile.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-color-profile.scm @@ -110,7 +110,7 @@ ; This is a stress test: a large profile (assert `(gimp-image-set-simulation-profile-from-file ,testImage - "/work/Coated_Fogra39L_VIGC_300.icc")) + (testing:path-to-color-profile "Coated_Fogra39L_VIGC_300.icc"))) ; effective: the vector of the profile is a different length than prior ; Not tested, crashes, because TS runs out of memory??? Tried setting CELL_SEGSIZE to 100k, did not help ;(assert `(= (vector-length (car (gimp-image-get-simulation-profile ,testImage))) diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-grayscale.scm b/plug-ins/script-fu/test/tests/PDB/image/image-grayscale.scm index 7428190b392..adad9b95b60 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-grayscale.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-grayscale.scm @@ -36,7 +36,7 @@ ; convert precision of grayscale image succeeds (assert `(gimp-image-convert-precision ,testImage - PRECISION-DOUBLE-GAMMA)) + PRECISION-U8-PERCEPTUAL)) (script-fu-use-v2) diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-indexed.scm b/plug-ins/script-fu/test/tests/PDB/image/image-indexed.scm index 3f69c914aba..9d08a03cdae 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-indexed.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-indexed.scm @@ -118,7 +118,7 @@ ; convert precision of indexed images yields error (assert-error `(gimp-image-convert-precision ,newTestImage - PRECISION-DOUBLE-GAMMA) + PRECISION-U8-PERCEPTUAL) "Procedure execution of gimp-image-convert-precision failed on invalid input arguments: ") ; "Image '[Untitled]' (4) must not be of type 'indexed'" diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-new.scm b/plug-ins/script-fu/test/tests/PDB/image/image-new.scm index 195ee4ee459..1035de16d02 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-new.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-new.scm @@ -159,8 +159,8 @@ ; Dimension zero yields error ; It does NOT yield invalid ID -1 (assert-error `(gimp-image-new 0 0 RGB) - "Invalid value for argument 0") -; FORMERLY "argument 1 in call to gimp-image-new has value 0 out of range: 1 to 524288") + "argument 1 in call to gimp-image-new has value 0 out of range: 1 to 524288") +; Not this: "Invalid value for argument 0") ; Since 3.0, parameter validation catches this earlier. ; Formerly, "Procedure execution of gimp-image-new failed on invalid input arguments: " diff --git a/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm b/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm index 2ed841993cd..822f77ec189 100644 --- a/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm +++ b/plug-ins/script-fu/test/tests/PDB/image/image-precision.scm @@ -2,33 +2,34 @@ ; Using numeric equality operator '=' on numeric ID's +(script-fu-use-v3) + ; setup -(define testImage (car (gimp-image-new 21 22 RGB))) +(define testImage (gimp-image-new 21 22 RGB)) + + -; Basic precision tests +(test! "new image has PRECISION-U8-NON-LINEAR") -; method get_precision on new image yields PRECISION-U8-NON-LINEAR 150 -(assert `(= - (car (gimp-image-get-precision ,testImage)) +(assert `(= (gimp-image-get-precision ,testImage) PRECISION-U8-NON-LINEAR )) -; Convert precision +(test! "Convert precision") ; method convert-precision yields true, with side effect on image -(assert `(car (gimp-image-convert-precision +(assert `(gimp-image-convert-precision ,testImage - PRECISION-U8-LINEAR))) + PRECISION-U8-LINEAR)) -; converted image is the precision -(assert `(= - (car (gimp-image-get-precision ,testImage)) - PRECISION-U8-LINEAR )) +; Effective: converted image is the precision +(assert `(= (gimp-image-get-precision ,testImage) + PRECISION-U8-LINEAR)) ; converting to the same precision yields error message (assert-error `(gimp-image-convert-precision @@ -43,40 +44,30 @@ -; New with precision +(test! "New with precision") +(define testImageWithPrecision (gimp-image-new-with-precision 21 22 RGB PRECISION-U8-PERCEPTUAL)) -; GAMMA obsolete since 3.0 -; PRECISION-U8-GAMMA -; PRECISION-U16-GAMMA -; PRECISION-U32-GAMMA -; PRECISION-HALF-GAMMA -; PRECISION-FLOAT-GAMMA -; PRECISION-DOUBLE-GAMMA - -; setup -(define testImageWithPrecision (car (gimp-image-new-with-precision 21 22 RGB PRECISION-U8-PERCEPTUAL))) +; Effective: image has given precision +(assert `(= (gimp-image-get-precision ,testImageWithPrecision) + PRECISION-U8-PERCEPTUAL)) -; image has given precision -(assert `(= - (car (gimp-image-get-precision ,testImageWithPrecision)) - PRECISION-U8-PERCEPTUAL )) - -; test conversions to all the precisions +(test! "conversions to all the precisions") (define (testConvertPrecision precision) - (assert `(car (gimp-image-convert-precision + (assert `(gimp-image-convert-precision ,testImage - ,precision)))) + ,precision))) -; Assert precision is not first precision in list: -; it will fail if image already that precision +; Require testImage precision is not first precision in list: +; it will fail if image already that precision. (define allPrecisions - `(PRECISION-U8-LINEAR + `( + ; skip because testImage already is PRECISION-U8-LINEAR PRECISION-U8-NON-LINEAR PRECISION-U8-PERCEPTUAL PRECISION-U16-LINEAR @@ -95,7 +86,17 @@ PRECISION-DOUBLE-NON-LINEAR PRECISION-DOUBLE-PERCEPTUAL)) +; GAMMA obsolete since 3.0 +; PRECISION-U8-GAMMA +; PRECISION-U16-GAMMA +; PRECISION-U32-GAMMA +; PRECISION-HALF-GAMMA +; PRECISION-FLOAT-GAMMA +; PRECISION-DOUBLE-GAMMA + ; sequence through all precisions, converting testImage to them (for-each testConvertPrecision - allPrecisions) \ No newline at end of file + allPrecisions) + +(script-fu-use-v2) \ No newline at end of file diff --git a/plug-ins/script-fu/test/tests/PDB/layer/layer-ops.scm b/plug-ins/script-fu/test/tests/PDB/layer/layer-ops.scm index b0c051562b4..b961e758dd2 100644 --- a/plug-ins/script-fu/test/tests/PDB/layer/layer-ops.scm +++ b/plug-ins/script-fu/test/tests/PDB/layer/layer-ops.scm @@ -79,7 +79,8 @@ ; delete second time fails (assert-error `(gimp-item-delete ,testLayer) - "runtime: invalid item ID") + "Invalid value for argument 0") +; FORMERLY "runtime: invalid item ID") ; Error for flatten: ; "Procedure execution of gimp-layer-delete failed on invalid input arguments: " diff --git a/plug-ins/script-fu/test/tests/PDB/pdb.scm b/plug-ins/script-fu/test/tests/PDB/pdb.scm index 30cf1fe55cd..9aa63a3759b 100644 --- a/plug-ins/script-fu/test/tests/PDB/pdb.scm +++ b/plug-ins/script-fu/test/tests/PDB/pdb.scm @@ -105,6 +105,8 @@ (testing:load-test "bind-args.scm") (testing:load-test "pixel.scm") +; Don't routinely test the PDB API for NDE filters, it is long: +; (testing:load-test "gegl.scm") ; report the result (testing:report) diff --git a/plug-ins/script-fu/test/tests/Plugins/gegl.scm b/plug-ins/script-fu/test/tests/Plugins/gegl.scm index 2725c6fab6f..8a1e78fd077 100644 --- a/plug-ins/script-fu/test/tests/Plugins/gegl.scm +++ b/plug-ins/script-fu/test/tests/Plugins/gegl.scm @@ -1,14 +1,47 @@ -; Test the PDB procedures that wrap GEGL plugins +; Test GEGL plugins ; This can also be stress test for GIMP itself: opens hundreds of images -; The procedures defined in /pdb/groups/plug_in_compat.pdb -; Not all GEGL filters are wrapped. +; WORK IN PROGRESS +; This is brute force, it doesn't test effects, mainly tests for crashes. +; The API is very new and subject to change. + +; HISTORY +; For plugin authors porting older plugins. +; +; In GIMP 2 (say about 2.8) many filters were moved to GEGL +; and in GIMP, wrapper plugins were defined in the PDB. +; The wrappers were defined in /pdb/groups/plug_in_compat.pdb +; A wrapper procedure was named like plug-in-antialias, +; where "anti-alias" is a name of a wrapped filter in GEGL +; Not all GEGL filters were wrapped. +; ; Some GEGL filters appear in the GUI (apart from Gegl Ops menu.) ; via app/actions/filters-actions.c and image-menu.ui (xml) -; Here we are calling the wrapped GEGL filters non-interactively. - +; +; Since GIMP 3, new procedures were added to the PDB for a plugin +; to "use" a GEGL filter. +; Filters are "added" to a layer. They are initially NDE (non-destructive) +; After adding a filter, they can be "merged" meaning convert to destructive +; (the effect becomes more permanent, the parameters of the filter +; can no longer be tweaked, i.e. the filter is no longer parameterized.) +; +; The new API in the PDB is: +; gimp-drawable-filter-new etc. +; ScriptFu also has new functions (not in the PDB): +; gimp-drawable-filter-configure, gimp-drawable-filter-set-aux-input, +; gimp-drawable-merge-filter, gimp-drawable-append-filter, etc. +; +; The wrappers also declared ranges for formal args, matching GEGL declared ranges. +; Since wrappers no longer exist, GEGL declared ranges are the only ones effective. +; +; The new API lets an author call ANY Gegl plugin. +; Formerly, some Gegl filters had no wrapper, so you could not call them. + + +; ABOUT THE TESTS +; ; Each test is a simple call. ; No test for effectiveness, only that a call succeeds. @@ -127,179 +160,278 @@ ) +; Functions to create filters +; Filters are now objects with methods. + +; Returns a filter on the global testLayer +; The filter is configured minimally. +(define (createGeglFilter name-suffix) + (let* ((filter-name (string-append "gegl:" name-suffix)) + (filter (gimp-drawable-filter-new + testLayer + filter-name + "" ; user given "effect name" + ))) + ; configure the filter. + ; ??? Do these default? + (gimp-drawable-filter-configure filter + LAYER-MODE-REPLACE ; blend mode + 1.0) ; opacity + + ; Return the filter + filter)) + +; CRUFT to call wrappers, now obsolete. +;(assert `( +; ; form the full name of the plugin, as a symbol +; ,(string->symbol (string-append "plug-in-" name-suffix)) +; RUN-NONINTERACTIVE ,testImage ,testLayer)) ; Define test harness functions -; Function to call gegl wrapper plugin with "usual" arguments +; Function to "add" and "merge" GEGL filter with "usual" arguments ; Omitting most arguments, which are defaulted. -(define (testGeglWrapper name-suffix) +(define (testGeglFilter name-suffix) (test! name-suffix) ; new image for each test (testImageCreator) - (assert `( - ; form the full name of the plugin, as a symbol - ,(string->symbol (string-append "plug-in-" name-suffix)) - RUN-NONINTERACTIVE ,testImage ,testLayer)) + (let* ((filter (createGeglFilter name-suffix)) + + ; key/value pairs for other args + ;"amount-x" 0.0 "amount-x" 0.0 "abyss-policy" "loop" + ;"sampler-type" "cubic" "displace-mode" "cartesian") + + ; The filter is floating, i.e. not on the layer until we append it + ; FIXME: why isn't it named attach like other PDB functions? + (gimp-drawable-append-filter testLayer filter) + + ; Make the filter destructive i.e. effects permanent + ;(gimp-drawable-merge-filter testLayer filter) + ) ; end let* ; not essential, but nice, to display result images (gimp-display-new testImage) (gimp-displays-flush) - ) + )) + ; Function to call gegl plugin with "usual" arguments plus another arg ; Omitting trailing arguments. -(define (testGeglWrapper2 name-suffix other-arg) +(define (testGeglFilterAuxInput name-suffix aux-input) (test! name-suffix) (testImageCreator) - (assert `( - ,(string->symbol (string-append "plug-in-" name-suffix)) - RUN-NONINTERACTIVE ,testImage ,testLayer - ,other-arg)) + + (let* ((filter (createGeglFilter name-suffix)) + ; + (gimp-drawable-filter-set-aux-input filter "aux" aux-input) + (gimp-drawable-merge-filter testLayer filter))) + (gimp-display-new testImage) (gimp-displays-flush) ) -; !!! autocrop layer is not a GEGL wrapper +; NOTES +; These notes are about historical renaming and can be wrong.... +; Certain filters named like plug-in- are compatibility plugins but not GEGL wrappers: +; autocrop +; autocrop-layer +; Certain GEGL wrappers were on the same GEGL plugin: +; plug-in-bump-map-tiled a second wrapper of gegl:bump-map +; Certain GEGL wrappers had names not the same as the wrapped GEGL plugin: +; apply-canvas texturize-canvas +; applylens apply-lens +; autostretch-hsv stretch-contrast-hsv +; c-astretch stretch-contrast +; colortoalpha color-to-alpha +; colors-channel-mixer channel-mixer +; diffraction diffraction-patterns +; dog difference-of-gaussians +; exchange color-exchange +; flarefx lens-flare +; gauss gaussian-blur +; glasstile tile-glass +; hsv-noise noise-hsv +; laplace edge-laplace +; make-seamless seamless-clone or seamless-clone-compose +; neon edge-neon +; noisify ??? +; polar-coords polar-coordinates +; randomize-hurl noise-hurl +; randomize-pick noise-pick +; randomize-slur noise-slur +; rgb-noise noise-rgb +; sel-gauss gaussian-blur-selective +; sobel edge-sobel +; softglow soft-light ??? +; solid-noise simplex-noise ??? +; spread noise-spread +; video video-degradation +; vinvert value-invert +; vpropagate value-propagate +; +; Certain filters are GIMP operations, no longer wrapped and callable from SF? +; semi-flatten +; threshold-alpha ; requires alpha +; +; Certain compatibility procedures might have been specialized calls of gegl filters +; (with special, non-default parameters) +; dilate value-propagate, specialized? +; erode value-propagate, specialized? +; mblur-inward mblur specialized? +; normalize stretch-contrast specialized? +; oilify-enhanced oilify specialized? + + + +; list of names of all gegl filters +; That take no args, or args that properly default. +; In alphabetical order. +; This list is hand-built from former wrapper names, and may be incomplete. +; FIXME it should be extracted from GEGL but there is no API? + +; a short list for use while developing tests +(define gegl-filter-names2 + (list + "antialias" )) -; list of names of all gegl wrappers that take no args, or args that properly default -; in alphabetical order. -(define gegl-wrapper-names +(define gegl-filter-names (list "antialias" - "apply-canvas" - "applylens" - "autocrop" - "autostretch-hsv" - "c-astretch" + "alpha-clip" ; see threshold-alpha, similar ? + "apply-lens" + ; "bump-map" tested separately, requires aux input "cartoon" - "colors-channel-mixer" + "channel-mixer" + "color-to-alpha" ; color defaultable? + "color-exchange" "cubism" "deinterlace" - "diffraction" - "dog" + "diffraction-patterns" + ; "displace" tested separately, requires two aux inputs + "difference-of-gaussians" ; an edge detect "edge" + "edge-laplace" + "edge-neon" + "edge-sobel" "emboss" "engrave" - "exchange" - "flarefx" "fractal-trace" - "gauss" - "glasstile" - "hsv-noise" + "gaussian-blur" + "gaussian-blur-selective" "illusion" - "laplace" + "image-gradient" ; an edge detect + "invert-linear" "lens-distortion" - "make-seamless" + "lens-flare" "maze" "mblur" - "mblur-inward" "median-blur" "mosaic" - "neon" "newsprint" - "normalize" + "noise-hsv" + "noise-hurl" + "noise-pick" + "noise-spread" + "noise-slur" + "noise-rgb" + ; TODO more noise- not wrapped e.g. iCH "oilify" - "oilify-enhanced" "photocopy" "pixelize" "plasma" - "polar-coords" - "randomize-hurl" - "randomize-pick" - "randomize-slur" + "polar-coordinates" "red-eye-removal" - "rgb-noise" "ripple" - "rotate" - "noisify" - "sel-gauss" - "semiflatten" ; requires alpha and returns error otherwise + ; FIXME crashes SF "rotate" + "seamless-clone" + "seamless-clone-compose" "shift" - "sobel" - "softglow" - "solid-noise" - "spread" - "threshold-alpha" ; requires alpha + "soft-light" + "spherize" + "simplex-noise" + "stretch-contrast" + "stretch-contrast-hsv" + "texturize-canvas" + "tile-glass" "unsharp-mask" - "video" - "vinvert" - "vpropagate" - "dilate" - "erode" + "value-invert" + "value-propagate" + "video-degradation" + ; distorts, see also engrave, ripple, shift, spherize "waves" "whirl-pinch" "wind")) -(define (testGeglWrappersTakingNoArg) - (map testGeglWrapper gegl-wrapper-names)) +(define (testGeglFiltersTakingNoArg) + (map testGeglFilter gegl-filter-names)) -; tests Gegl wrappers with one other arg -(define (testGeglWrappersTakingOneArg) - ; These require a non-defaultable arg: bump map +; tests Gegl wrappers taking an aux input +; Most filters have input a single layer +; An aux input is an argument that is a second input, another layer +(define (testGeglFiltersTakingAuxInput) + ; These require a non-defaultable aux input arg: bump map ; TODO using the testLayer as bump map produces little visible effect? - (testGeglWrapper2 "bump-map" testLayer) - (testGeglWrapper2 "bump-map-tiled" testLayer) + (testGeglFilterAuxInput "bump-map" testLayer) + ; "bump-map-tiled" was a wrapper but calls "bump-map" ; Requires an explicit color arg, until we fix defaulting colors in the PDB machinery - (testGeglWrapper2 "colortoalpha" "red") + ; TODO (testGeglFilter2 "colortoalpha" "red") ) -(define (testGeglWrappers) - (testGeglWrappersTakingNoArg) - (testGeglWrappersTakingOneArg) - (testSpecialGeglWrappers)) +(define (testGeglFilters) + (testGeglFiltersTakingNoArg) + (testGeglFiltersTakingAuxInput) + (testSpecialGeglFilters)) ; Tests of gegl wrappers by image modes ; Note you can't just redefine testImageCreator, ; it is not in scope, you must set a global. -(define (testGeglWrappersRGBA) +(define (testGeglFiltersRGBA) (test! "Test GEGL wrappers on RGBA") (set! testImageCreator createRGBATestImage) - (testGeglWrappers)) + (testGeglFilters)) -(define (testGeglWrappersSmallRGBA) +(define (testGeglFiltersSmallRGBA) (test! "Test GEGL wrappers on small image") (set! testImageCreator createSmallTestImage) - (testGeglWrappers)) + (testGeglFilters)) -(define (testGeglWrappersSmallGRAY) +(define (testGeglFiltersSmallGRAY) (test! "Test GEGL wrappers on small gray image") (set! testImageCreator createSmallGrayTestImage) - (testGeglWrappers)) + (testGeglFilters)) -(define (testGeglWrappersINDEXED) +(define (testGeglFiltersINDEXED) (test! "Test GEGL wrappers on INDEXED image") (set! testImageCreator createIndexedImage) - (testGeglWrappers)) + (testGeglFilters)) ; test GEGL wrappers having args that don't default -(define (testSpecialGeglWrappers) +(define (testSpecialGeglFilters) (test! "Special test GEGL wrappers") - ; Requires non-defaultable maps. + ; "displace" requires two non-defaultable aux inputs i.e. maps. ; We can never add test auto-defaulting the args. ; These are NOT the declared defaults. (test! "displace") (testImageCreator) - (let* ((filter (car (gimp-drawable-filter-new ,testLayer "gegl:displace" "")))) - (gimp-drawable-filter-configure filter LAYER-MODE-REPLACE 1.0 - "amount-x" 0.0 "amount-x" 0.0 "abyss-policy" "loop" - "sampler-type" "cubic" "displace-mode" "cartesian") - (gimp-drawable-filter-set-aux-input filter "aux" ,testLayer) - (gimp-drawable-filter-set-aux-input filter "aux2" ,testLayer) - (gimp-drawable-merge-filter ,testLayer filter) - ) + (let* ((filter (createGeglFilter "displace")) + ; using testLayer as both aux inputs + (gimp-drawable-filter-set-aux-input filter "aux" testLayer) + (gimp-drawable-filter-set-aux-input filter "aux2" testLayer) + (gimp-drawable-merge-filter testLayer filter))) + (gimp-display-new testImage) (gimp-displays-flush) ) @@ -311,20 +443,28 @@ ; Testing them all creates about 300 images ; tests on RGBA -(testGeglWrappersRGBA) +(testGeglFiltersRGBA) ; tests of small images is an edge test ; and don't seem to reveal any bugs, even for a 1x1 image -(testGeglWrappersSmallRGBA) +(testGeglFiltersSmallRGBA) ; tests of other image modes tests conversions i.e babl -(testGeglWrappersSmallGRAY) +(testGeglFiltersSmallGRAY) ; FIXME some throw CRITICAL -(testGeglWrappersINDEXED) +(testGeglFiltersINDEXED) ; Not testing image without alpha. ; It only shows that semiflatten and thresholdalpha return errors, ; because they require alpha. ; Not testing other image precisions and color profiles. + + +(test! "Non-existing filter") +; test creating filter for an invalid name +; TODO +; Procedure execution of gimp-drawable-filter-new failed on invalid input arguments: +; drawable_filter_new_invoker: the filter "gegl:bump-map-tiled" is not installed. + -- GitLab