mirror of https://github.com/GNOME/gimp.git
2.99 Test: add more tests
Add tests of context stack ops. Add test of paint methods. Test convert to all precisions. Test paint dynamics. Test PDB as database. Test PDBProcedure methods. Test display methods. Test drawable operations.
This commit is contained in:
parent
cc1f1b5900
commit
888adc5b96
|
@ -18,7 +18,8 @@ if not stable
|
|||
'tests' / 'PDB' / 'image' / 'image-color-profile.scm',
|
||||
|
||||
'tests' / 'PDB' / 'paint' / 'paint.scm',
|
||||
|
||||
'tests' / 'PDB' / 'paint' / 'paint-methods.scm',
|
||||
'tests' / 'PDB' / 'paint' / 'dynamics.scm',
|
||||
|
||||
'tests' / 'PDB' / 'layer' / 'layer-new.scm',
|
||||
'tests' / 'PDB' / 'layer' / 'layer-ops.scm',
|
||||
|
@ -30,6 +31,8 @@ if not stable
|
|||
'tests' / 'PDB' / 'item' / 'item-position.scm',
|
||||
'tests' / 'PDB' / 'item' / 'item-layer-group.scm',
|
||||
|
||||
'tests' / 'PDB' / 'drawable' / 'drawable-ops.scm',
|
||||
|
||||
'tests' / 'PDB' / 'channel' / 'channel-new.scm',
|
||||
'tests' / 'PDB' / 'channel' / 'channel-attributes.scm',
|
||||
'tests' / 'PDB' / 'channel' / 'channel-ops.scm',
|
||||
|
@ -45,21 +48,31 @@ if not stable
|
|||
'tests' / 'PDB' / 'resource' / 'resource-ops.scm',
|
||||
'tests' / 'PDB' / 'resource' / 'brush.scm',
|
||||
'tests' / 'PDB' / 'resource' / 'palette.scm',
|
||||
|
||||
'tests' / 'PDB' / 'context' / 'context-get-set.scm',
|
||||
'tests' / 'PDB' / 'context' / 'context-resource.scm',
|
||||
'tests' / 'PDB' / 'context' / 'context-stack.scm',
|
||||
|
||||
'tests' / 'PDB' / 'display' / 'display.scm',
|
||||
|
||||
'tests' / 'PDB' / 'edit' / 'buffer.scm',
|
||||
'tests' / 'PDB' / 'edit' / 'edit.scm',
|
||||
'tests' / 'PDB' / 'edit' / 'edit-multi-layer.scm',
|
||||
|
||||
'tests' / 'PDB' / 'gimp' / 'gimp.scm',
|
||||
'tests' / 'PDB' / 'gimp' / 'PDB.scm',
|
||||
'tests' / 'PDB' / 'gimp' / 'refresh.scm',
|
||||
'tests' / 'PDB' / 'gimp' / 'procedures.scm',
|
||||
|
||||
'tests' / 'PDB' / 'misc.scm',
|
||||
'tests' / 'PDB' / 'enums.scm',
|
||||
'tests' / 'PDB' / 'refresh.scm',
|
||||
|
||||
'tests' / 'PDB' / 'bind-args.scm',
|
||||
|
||||
# comprehensive, total test
|
||||
'tests' / 'PDB' / 'pdb.scm',
|
||||
|
||||
|
||||
'tests' / 'TS' / 'sharp-expr.scm',
|
||||
'tests' / 'TS' / 'sharp-expr-char.scm',
|
||||
'tests' / 'TS' / 'sharp-expr-unichar.scm',
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
; test stack methods of Context
|
||||
|
||||
; push and pop
|
||||
|
||||
; We arbitrarily use context:antialias to distinguish context instances.
|
||||
; Antialias is a setting for the selection tool.
|
||||
; Antialias is usually true.
|
||||
; !!! This test depends on it being true initially.
|
||||
|
||||
; The two context instances are:
|
||||
; - original, pushed
|
||||
; - new one, after a push
|
||||
|
||||
|
||||
|
||||
|
||||
; test the sequence push, pop i.e. the normal sequence
|
||||
|
||||
; Test initial condition is context:antialias true
|
||||
(assert-PDB-true `(gimp-context-get-antialias))
|
||||
|
||||
; push succeeds
|
||||
(assert `(gimp-context-push))
|
||||
|
||||
; Set antialias false in new context
|
||||
; FUTURE pass #f
|
||||
(assert `(gimp-context-set-antialias 0))
|
||||
(assert-PDB-false `(gimp-context-get-antialias))
|
||||
|
||||
; pop succeeds
|
||||
(assert `(gimp-context-pop))
|
||||
|
||||
; pop effective: original context i.e. antialias true
|
||||
(assert-PDB-true `(gimp-context-get-antialias))
|
||||
|
||||
|
||||
|
||||
; test abnormal sequence: pop without a prior push.
|
||||
; Yields an error
|
||||
(assert-error `(gimp-context-pop)
|
||||
"Procedure execution of gimp-context-pop failed")
|
||||
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
; test methods of display
|
||||
|
||||
; A display is a tabbed window in the GIMP app.
|
||||
; Expect all the API calls are impotent if called in batch
|
||||
; i.e. when there is no GUI GIMP app.
|
||||
; But we don't test that yet.
|
||||
|
||||
; A display is represented by numeric ID in ScriptFu.
|
||||
; The space of ID's for displays overlaps the space of ID's for images.
|
||||
; I.E. 1 can be both an ID for an image and display, at the same time.
|
||||
|
||||
; Testing has visible results: displays appear as tabs in the GIMP app
|
||||
|
||||
; Testing throws GLib CRITICAL; must not export G_DEBUG=fatal_criticals
|
||||
|
||||
|
||||
; setup
|
||||
|
||||
; an image
|
||||
(define testImage (testing:load-test-image "wilber.png"))
|
||||
; a second image
|
||||
(define testImage2 (car (gimp-image-new 21 22 RGB)))
|
||||
|
||||
|
||||
; new
|
||||
|
||||
; new succeeds
|
||||
(assert `(gimp-display-new ,testImage))
|
||||
|
||||
; store the ID of another new display on same image
|
||||
; FUTURE: not wrapped in a list
|
||||
(define testDisplay (car (gimp-display-new testImage)))
|
||||
|
||||
; new display has a valid ID
|
||||
(assert-PDB-true `(gimp-display-id-is-valid ,testDisplay))
|
||||
|
||||
; can get many displays of same image
|
||||
(assert `(gimp-display-new ,testImage))
|
||||
|
||||
|
||||
|
||||
; id-is-valid returns false for an invalid ID
|
||||
(assert-PDB-false `(gimp-display-id-is-valid 666))
|
||||
|
||||
|
||||
; misc
|
||||
|
||||
; has-a window-handle, which is a GBytes, i.e. a vector of numbers
|
||||
; FIXME the docs for the API says the type varies by platform, but it is always GBytes?
|
||||
; What varies is the interpretations of the GBytes:
|
||||
; as sequence of characters, or as sequence of bytes of a multi-bit number
|
||||
(assert `(vector? (car (gimp-display-get-window-handle ,testDisplay))))
|
||||
; get-window-handle is safe from invalid ID
|
||||
(assert-error `(gimp-display-get-window-handle 666)
|
||||
"Invalid value for argument 0")
|
||||
|
||||
; flush succeeds
|
||||
(assert `(gimp-displays-flush))
|
||||
|
||||
; present succeeds
|
||||
; TODO what does "present" mean?
|
||||
; I suppose "bring to front", when there are many tabbed displays
|
||||
(assert `(gimp-display-present ,testDisplay))
|
||||
; present is safe from invalid ID
|
||||
|
||||
(assert-error `(gimp-display-present 666)
|
||||
"Invalid value for argument 0")
|
||||
|
||||
|
||||
|
||||
; reconnect
|
||||
; reconnect (to-image from-image)
|
||||
|
||||
; illegal to reconnect from an image that already has a display
|
||||
; testImage is Wilber.png and is in two displays i.e. tabs
|
||||
(assert-error `(gimp-displays-reconnect ,testImage ,testImage )
|
||||
"Procedure execution of gimp-displays-reconnect failed")
|
||||
|
||||
; illegal to reconnect to an image that is not displayed
|
||||
; testImage2 is not displayed
|
||||
(assert-error `(gimp-displays-reconnect ,testImage2 ,testImage )
|
||||
"Procedure execution of gimp-displays-reconnect failed")
|
||||
|
||||
|
||||
; reconnect succeeds
|
||||
; Make displays of wilber.png now show the testImage2 that is not now displayed
|
||||
(assert `(gimp-displays-reconnect ,testImage ,testImage2 ))
|
||||
; display ID is still valid
|
||||
(assert-PDB-true `(gimp-display-id-is-valid ,testDisplay))
|
||||
; effective. TODO no API to know what image is in a display.
|
||||
|
||||
; reconnect is safe from invalid image ID
|
||||
(assert-error `(gimp-displays-reconnect 666 666)
|
||||
"Invalid value for argument 0")
|
||||
|
||||
|
||||
|
||||
; delete
|
||||
|
||||
; succeeds
|
||||
(assert `(gimp-display-delete ,testDisplay))
|
||||
; effective: display ID is no longer valid
|
||||
(assert-PDB-false `(gimp-display-id-is-valid ,testDisplay))
|
||||
; safe from invalid ID
|
||||
(assert-error `(gimp-display-delete ,testDisplay)
|
||||
"Invalid value for argument 0")
|
||||
|
||||
|
||||
; Testing leaves two displays visible in GIMP app
|
|
@ -0,0 +1,63 @@
|
|||
; test op methods of drawable
|
||||
|
||||
; operations change pixels of the drawable without reference to other objects,
|
||||
; or with passed non-drawable args such as curves
|
||||
|
||||
|
||||
|
||||
; setup
|
||||
|
||||
(define testImage (testing:load-test-image "wilber.png"))
|
||||
; Wilber has one layer
|
||||
; cadr is vector, first element is a drawable
|
||||
(define testDrawable (vector-ref (cadr (gimp-image-get-layers testImage)) 0))
|
||||
|
||||
|
||||
|
||||
; tests in alphabetic order
|
||||
|
||||
(assert `(gimp-drawable-brightness-contrast ,testDrawable 0.1 -0.1))
|
||||
|
||||
(assert `(gimp-drawable-color-balance ,testDrawable TRANSFER-MIDTONES 1 0.1 0.1 0.1))
|
||||
|
||||
(assert `(gimp-drawable-colorize-hsl ,testDrawable 360 50 -50))
|
||||
|
||||
; TODO requires vector of size 256
|
||||
; (assert `(gimp-drawable-curves-explicit ,testDrawable HISTOGRAM-RED 2 #(1 2)))
|
||||
|
||||
;(assert `(gimp-drawable-curves-spline ,testDrawable DESATURATE-LUMA))
|
||||
|
||||
(assert `(gimp-drawable-desaturate ,testDrawable DESATURATE-LUMA))
|
||||
|
||||
(assert `(gimp-drawable-equalize ,testDrawable 1)) ; boolean mask-only
|
||||
|
||||
;(assert `(gimp-drawable-extract-component ,testDrawable DESATURATE-LUMA))
|
||||
|
||||
(assert `(gimp-drawable-fill ,testDrawable FILL-CIELAB-MIDDLE-GRAY))
|
||||
|
||||
(assert `(gimp-drawable-foreground-extract ,testDrawable FOREGROUND-EXTRACT-MATTING ,testDrawable))
|
||||
|
||||
(assert `(gimp-drawable-hue-saturation ,testDrawable HUE-RANGE-MAGENTA 0 1 2 3))
|
||||
|
||||
|
||||
; misc
|
||||
; free-shadow
|
||||
|
||||
; attributes
|
||||
; get-bpp
|
||||
|
||||
(assert `(gimp-drawable-invert ,testDrawable 1)) ; boolean invert in linear space
|
||||
|
||||
(assert `(gimp-drawable-levels
|
||||
,testDrawable
|
||||
HISTOGRAM-LUMINANCE
|
||||
0.5 0.5 1 ; boolean clamp input
|
||||
8 0.5 0.5 1 ; boolean clamp output
|
||||
))
|
||||
|
||||
(assert `(gimp-drawable-posterize ,testDrawable 2))
|
||||
|
||||
(assert `(gimp-drawable-desaturate ,testDrawable DESATURATE-LUMA))
|
||||
|
||||
(gimp-display-new testImage)
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
; test methods of PDB as a database
|
||||
|
||||
|
||||
|
||||
(assert `(gimp-pdb-dump "/tmp/pdb.dump"))
|
||||
|
||||
|
||||
|
||||
; store named array of bytes into db
|
||||
(assert `(gimp-pdb-set-data "myData" #(1 2 3)))
|
||||
|
||||
; effective: the named data can be retrieved
|
||||
(assert `(equal? (car (gimp-pdb-get-data "myData"))
|
||||
#(1 2 3)))
|
||||
|
||||
|
||||
|
||||
; test existence of procedure
|
||||
(assert `(gimp-pdb-proc-exists "gimp-pdb-proc-exists"))
|
||||
|
||||
|
||||
|
||||
; query the pdb by a set of regex strings
|
||||
; returns list of names
|
||||
|
||||
; empty regex matches anything, returns all procedure names in pdb
|
||||
; Test exists more than 1000 procedures
|
||||
(assert `(> (length (car (gimp-pdb-query "" ; name
|
||||
"" "" ; blurb help
|
||||
"" "" ; authors copyright
|
||||
"" "" ; date type
|
||||
)))
|
||||
1000))
|
||||
|
||||
; a query on a specific name returns the same name
|
||||
(assert `(string=? ( caar (gimp-pdb-query "gimp-pdb-proc-exists" ; name
|
||||
"" "" ; blurb help
|
||||
"" "" ; authors copyright
|
||||
"" ""))
|
||||
"gimp-pdb-proc-exists"))
|
||||
|
||||
|
||||
|
||||
; generate a unique name.
|
||||
; name guaranteed to be unique for life of GIMP session.
|
||||
; I.E. the PDB has a generator.
|
||||
(assert `(string? (car (gimp-pdb-temp-name))))
|
|
@ -1,6 +1,8 @@
|
|||
; Tests of gimp module of the PDB
|
||||
; These are not associated with an object class
|
||||
|
||||
; Generally speaking, prefix is "gimp-get"
|
||||
|
||||
|
||||
; The serialized color configuration is a string
|
||||
(assert '(string? (car (gimp-get-color-configuration))))
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
; test methods of PDB about PDBProcedure
|
||||
|
||||
; Prefix of methods is "gimp-pdb-proc"
|
||||
|
||||
; Tests in alphabetic order of attribute name
|
||||
|
||||
; Assymmetry:
|
||||
; - some attributes can be get, but not set
|
||||
; - some attributes can be set but not get
|
||||
; Such attributes are set only in libgimp, not by a PDB procedure
|
||||
|
||||
; Dependent on ProcedureType
|
||||
; ProcedureType:Internal procedures lack some attributes e.g. menu_label
|
||||
; ProcedureType:Plugin procedures have those attributes
|
||||
|
||||
; There is no PDB API to create a procedure
|
||||
; and no setters of the arguments and return values.
|
||||
; There are setters of other attributes.
|
||||
|
||||
; Setters like gimp-pdb-set-file-proc- are not tested.
|
||||
|
||||
|
||||
|
||||
; Getters
|
||||
;
|
||||
; Getters of argument and return value types, useful for introspection.
|
||||
; Returns GParamSpec
|
||||
; FIXME crashes, ScriptFu does not marshall return type GParamSpec
|
||||
; (assert `(gimp-pdb-get-proc-argument "gimp-pdb-get-proc-argument" 0)
|
||||
; (assert `(gimp-pdb-get-proc-return-value "gimp-pdb-get-proc-argument" 0)
|
||||
|
||||
; Other getters
|
||||
|
||||
; Getters that return lists of strings of no real significance
|
||||
; Every procedure of any type has the attribute and it is generally not empty string.
|
||||
(assert `(gimp-pdb-get-proc-attribution "gimp-pdb-get-proc-argument"))
|
||||
(assert `(gimp-pdb-get-proc-documentation "gimp-pdb-get-proc-argument"))
|
||||
|
||||
|
||||
; image types is a string with known encoding
|
||||
; typically RGB, GRAY, RGBA, * (any), "" (none), or combinations
|
||||
|
||||
; Error to ask for image-types of ProcedureType:Internal
|
||||
(assert-error `(gimp-pdb-get-proc-image-types "gimp-pdb-get-proc-argument")
|
||||
"Procedure execution of gimp-pdb-get-proc-image-types failed")
|
||||
; Works for ProcedureType:Plugin
|
||||
(assert `(gimp-pdb-get-proc-image-types "plug-in-script-fu-console"))
|
||||
; Empty string means ScriptFu Console can be invoked when no images open
|
||||
(assert `(string=? (car (gimp-pdb-get-proc-image-types "plug-in-script-fu-console"))
|
||||
""))
|
||||
|
||||
|
||||
; first return value is integer from enumeration GimpPDBProcType
|
||||
(assert `(number? (car (gimp-pdb-get-proc-info "gimp-pdb-get-proc-argument"))))
|
||||
; gimp-pdb-get-proc-argument is ProcedureType:Internal
|
||||
(assert `(= (car (gimp-pdb-get-proc-info "gimp-pdb-get-proc-argument"))
|
||||
PDB-PROC-TYPE-INTERNAL))
|
||||
; plug-in-script-fu-console is ProcedureType:Plugin
|
||||
(assert `(= (car (gimp-pdb-get-proc-info "plug-in-script-fu-console"))
|
||||
PDB-PROC-TYPE-PLUGIN))
|
||||
|
||||
|
||||
; Error to ask for the menu_label of ProcedureType:Internal
|
||||
(assert-error `(gimp-pdb-get-proc-menu-label "gimp-pdb-get-proc-argument")
|
||||
"Procedure execution of gimp-pdb-get-proc-menu-label failed")
|
||||
; Error to ask for the menu-paths of ProcedureType:Internal
|
||||
(assert-error `(gimp-pdb-get-proc-menu-paths "gimp-pdb-get-proc-argument")
|
||||
"Procedure execution of gimp-pdb-get-proc-menu-paths failed")
|
||||
|
||||
|
||||
; Not an error for ProcedureType:Plugin.
|
||||
; Returns single string.
|
||||
; The string may be encoded with tag "_" for keyboard shortcuts
|
||||
(assert `(string=? (car (gimp-pdb-get-proc-menu-label "plug-in-script-fu-console"))
|
||||
"Script-Fu _Console"))
|
||||
(assert `(gimp-pdb-get-proc-menu-paths "plug-in-script-fu-console"))
|
||||
; Returns possibly long list of strings.
|
||||
; a procedure can be installed at many menu paths.
|
||||
; !!! FUTURE: returns a doubly wrapped list
|
||||
(assert `(string=? (caar (gimp-pdb-get-proc-menu-paths "plug-in-script-fu-console"))
|
||||
"<Image>/Filters/Development/Script-Fu"))
|
||||
|
||||
|
||||
; Setters cannot be called on a procedure that is not owned by current plugin.
|
||||
; Current plugin during test is e.g. ScriptFu Console
|
||||
; and it owns/installed the procedure: plug-in-script-fu-console
|
||||
(assert-error `(gimp-pdb-set-proc-attribution "gimp-pdb-get-proc-argument" "author" "foo" "bar")
|
||||
"Procedure execution of gimp-pdb-set-proc-attribution failed on invalid input arguments: ")
|
||||
; ... It has however not installed that procedure. This is not allowed.
|
||||
|
||||
; Setters work if the procedure is owned/installed by the current procedure
|
||||
; i.e. ProcedureType:Temporary installed by extension-script-fu.
|
||||
; Unable to test, since the current procedure during test varies
|
||||
; and doesn't own any temporary procedures.
|
||||
; This doesn't work:
|
||||
; (assert `(gimp-pdb-set-proc-attribution "plug-in-script-fu-console" "author" "copyright" "date"))
|
||||
|
||||
|
||||
|
||||
; Signatures of other setters, all return void
|
||||
;gimp-pdb-set-proc-attribution ( gchararray gchararray gchararray gchararray ) =>
|
||||
;gimp-pdb-set-proc-documentation ( gchararray gchararray gchararray gchararray ) =>
|
||||
;gimp-pdb-set-proc-icon ( gchararray GimpIconType gint GimpUint8Array ) =>
|
||||
;gimp-pdb-set-proc-image-types ( gchararray gchararray ) =>
|
||||
;gimp-pdb-set-proc-menu-label ( gchararray gchararray ) =>
|
||||
; Set but not get
|
||||
;gimp-pdb-set-proc-sensitivity-mask ( gchararray gint ) =>
|
|
@ -13,7 +13,7 @@
|
|||
; method get_precision on new image yields PRECISION-U8-NON-LINEAR 150
|
||||
(assert `(=
|
||||
(car (gimp-image-get-precision ,testImage))
|
||||
PRECISION-U8-NON-LINEAR ))
|
||||
PRECISION-U8-NON-LINEAR ))
|
||||
|
||||
|
||||
|
||||
|
@ -52,4 +52,48 @@
|
|||
; image has given precision
|
||||
(assert `(=
|
||||
(car (gimp-image-get-precision ,testImageWithPrecision))
|
||||
PRECISION-DOUBLE-GAMMA ))
|
||||
PRECISION-DOUBLE-GAMMA ))
|
||||
|
||||
|
||||
|
||||
; test conversions to all the precisions
|
||||
|
||||
(define (testConvertPrecision precision)
|
||||
(assert `(car (gimp-image-convert-precision
|
||||
,testImage
|
||||
,precision))))
|
||||
|
||||
; First convert away from 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
|
||||
PRECISION-U8-NON-LINEAR
|
||||
PRECISION-U8-PERCEPTUAL
|
||||
PRECISION-U16-LINEAR
|
||||
PRECISION-U16-NON-LINEAR
|
||||
PRECISION-U16-PERCEPTUAL
|
||||
PRECISION-U32-LINEAR
|
||||
PRECISION-U32-NON-LINEAR
|
||||
PRECISION-U32-PERCEPTUAL
|
||||
PRECISION-HALF-LINEAR
|
||||
PRECISION-HALF-NON-LINEAR
|
||||
PRECISION-HALF-PERCEPTUAL
|
||||
PRECISION-FLOAT-LINEAR
|
||||
PRECISION-FLOAT-NON-LINEAR
|
||||
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))
|
||||
|
||||
; sequence through all precisions, converting testImage to them
|
||||
(for-each
|
||||
testConvertPrecision
|
||||
allPrecisions)
|
|
@ -0,0 +1,107 @@
|
|||
; Test methods related to paint dynamics
|
||||
|
||||
|
||||
|
||||
; setup
|
||||
|
||||
; an image, drawable, and path
|
||||
(define testImage (testing:load-test-image "wilber.png"))
|
||||
(define testLayer (vector-ref (cadr (gimp-image-get-layers testImage ))
|
||||
0))
|
||||
(define testPath (car (gimp-vectors-new testImage "Test Path")))
|
||||
; must add to image
|
||||
(gimp-image-insert-vectors
|
||||
testImage
|
||||
testPath
|
||||
0 0) ; parent=0 position=0
|
||||
; Add stroke to path
|
||||
(gimp-vectors-stroke-new-from-points
|
||||
testPath
|
||||
VECTORS-STROKE-TYPE-BEZIER
|
||||
12 ; count control points, 2*2
|
||||
(vector 1 2 83 84 5 6 7 8 9 10 11 12)
|
||||
FALSE) ; not closed
|
||||
|
||||
; make test harder by using float precision
|
||||
(gimp-image-convert-precision testImage PRECISION-DOUBLE-GAMMA)
|
||||
; 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.)
|
||||
(gimp-context-set-paint-method "gimp-paintbrush")
|
||||
; make test harder by using a big, color brush
|
||||
(gimp-context-set-brush (car (gimp-brush-get-by-name "Wilber")))
|
||||
|
||||
|
||||
|
||||
|
||||
; methods of the gimp module
|
||||
|
||||
; introspection: gimp module returns list of names of dynamics
|
||||
; second arg is a regex
|
||||
(assert `(list? (car (gimp-dynamics-get-list ""))))
|
||||
|
||||
; refresh: gimp module will load newly installed dynamics
|
||||
; method is void and should never fail.
|
||||
(assert `(gimp-dynamics-refresh))
|
||||
|
||||
; TODO install a new dynamic and test that refresh is effective
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; context setting
|
||||
|
||||
; the dynamics setting defaults to true
|
||||
; !!! test requires freshly installed GIMP OR no prior testing
|
||||
(assert-PDB-true `(gimp-context-are-dynamics-enabled))
|
||||
|
||||
; the dynamics-enabled setting can be set to false
|
||||
; TODO #f instead of 0
|
||||
(assert `(gimp-context-enable-dynamics 0))
|
||||
; setting to false was effective
|
||||
(assert-PDB-false `(gimp-context-are-dynamics-enabled))
|
||||
; restore to enabled for further testing
|
||||
(assert `(gimp-context-enable-dynamics 1))
|
||||
|
||||
|
||||
; 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))
|
||||
"Tilt Angle"))
|
||||
|
||||
|
||||
|
||||
; TODO test all the dynamics seems to work
|
||||
|
||||
; Test that all dynamics seem to work:
|
||||
; set context to dynamics
|
||||
; stroke a drawable along a path with current brush and dynamics
|
||||
|
||||
|
||||
(define dynamicsList (car (gimp-dynamics-get-list "")))
|
||||
|
||||
(define (testDynamics dynamics)
|
||||
; Test that every dynamics can be set on the context
|
||||
(gimp-context-set-dynamics dynamics)
|
||||
|
||||
(display dynamics)
|
||||
; paint with paintbrush and dynamics, under the test harness
|
||||
(assert `(gimp-drawable-edit-stroke-item ,testLayer ,testPath))
|
||||
)
|
||||
|
||||
; apply testDynamics to each dynamics kind.
|
||||
; This is not a difficult test since the stroke is uniform w/r to dynamics.
|
||||
; The stroke does not vary by e.g. pressure.
|
||||
(for-each
|
||||
testDynamics
|
||||
dynamicsList)
|
||||
|
||||
;(gimp-display-new testImage)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
; test paint-method methods of API
|
||||
|
||||
; tests setting a paint-method in context,
|
||||
; then painting (stroking) with it.
|
||||
|
||||
|
||||
|
||||
; setup
|
||||
|
||||
; an image, drawable, and path
|
||||
(define testImage (testing:load-test-image "wilber.png"))
|
||||
(define testLayer (vector-ref (cadr (gimp-image-get-layers testImage ))
|
||||
0))
|
||||
(define testPath (car (gimp-vectors-new testImage "Test Path")))
|
||||
; must add to image
|
||||
(gimp-image-insert-vectors
|
||||
testImage
|
||||
testPath
|
||||
0 0) ; parent=0 position=0
|
||||
; Add stroke to path
|
||||
(gimp-vectors-stroke-new-from-points
|
||||
testPath
|
||||
VECTORS-STROKE-TYPE-BEZIER
|
||||
12 ; count control points, 2*2
|
||||
(vector 1 2 3 4 5 6 7 8 9 10 11 12)
|
||||
FALSE) ; not closed
|
||||
|
||||
|
||||
|
||||
; paint-methods are introspectable to a list
|
||||
(assert `(list? (gimp-context-list-paint-methods)))
|
||||
|
||||
; TODO
|
||||
; test their names all have "gimp-" prefix and lower case.
|
||||
|
||||
; Test that every returned name is valid to set on the context
|
||||
(define paintMethods (car (gimp-context-list-paint-methods)))
|
||||
; TODO this doesn't seem to work: illegal function
|
||||
; Probably the assert wrapper screws something up
|
||||
; (assert `(map gimp-context-set-paint-method ,paintMethods))
|
||||
|
||||
|
||||
|
||||
|
||||
; paint-method get/set on context
|
||||
|
||||
(assert `(gimp-context-set-paint-method "gimp-ink"))
|
||||
|
||||
; getter succeeds and setter was effective
|
||||
(assert `(string=? (car (gimp-context-get-paint-method))
|
||||
"gimp-ink"))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; Test that all paint-methods seem to work:
|
||||
; set context stroke method to paint-method
|
||||
; stroke a drawable along a path with the paint method
|
||||
; (except some paintMethods not painted with)
|
||||
|
||||
; set context to stroke with paint (versus line)
|
||||
(assert `(gimp-context-set-stroke-method STROKE-PAINT-METHOD))
|
||||
|
||||
; iterate over paintMethods, testing that they seem to work
|
||||
|
||||
; test function that paints a path using a paint method.
|
||||
; paintMethod is string
|
||||
(define (testPaintMethod paintMethod)
|
||||
; Test that every paintMethod can be set on the context
|
||||
(gimp-context-set-paint-method paintMethod)
|
||||
|
||||
; Don't paint with paint methods that need a source image set
|
||||
; The API does not have a way to set source image
|
||||
; TODO this is still failing with "Set a source first"
|
||||
(if (not (or
|
||||
(string=? paintMethod "gimp-clone")
|
||||
(string=? paintMethod "gimp-heal")
|
||||
(string=? paintMethod "gimp-perspective-clone")))
|
||||
(display paintMethod)
|
||||
; paint with the method, under the test harness
|
||||
(assert `(gimp-drawable-edit-stroke-item ,testLayer ,testPath))
|
||||
))
|
||||
|
||||
; apply testPaintMethod to each paintMethod
|
||||
(for-each
|
||||
testPaintMethod
|
||||
paintMethods)
|
|
@ -1,5 +1,11 @@
|
|||
; Test painting operations on drawable
|
||||
|
||||
; AKA PaintMethod
|
||||
; This tests the PaintMethods that have an API.
|
||||
; These PaintMethods do not have API:
|
||||
; ink, paintbrush, mybrush, perspective-clone.
|
||||
; See paintmethods.scm for tests of those.
|
||||
|
||||
; The operand is a subset of the drawable
|
||||
; For operations on the total image, see image-ops.scm
|
||||
; For operations on a total layer, see layer-ops.scm
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
(testing:load-test "image-color-profile.scm")
|
||||
|
||||
(testing:load-test "paint.scm")
|
||||
(testing:load-test "paint-methods.scm")
|
||||
(testing:load-test "dynamics.scm")
|
||||
|
||||
(testing:load-test "layer-new.scm")
|
||||
(testing:load-test "layer-ops.scm")
|
||||
|
@ -42,17 +44,20 @@
|
|||
|
||||
; Test superclass methods.
|
||||
; Drawable and Item are superclasses
|
||||
|
||||
; Testing Drawable and Item uses extant instances;
|
||||
; must be after instances of subclasses are created.
|
||||
(testing:load-test "item.scm")
|
||||
(testing:load-test "item-position.scm")
|
||||
(testing:load-test "item-layer-group.scm")
|
||||
|
||||
; TODO drawable
|
||||
(testing:load-test "drawable-ops.scm")
|
||||
|
||||
|
||||
; context
|
||||
(testing:load-test "context-get-set.scm")
|
||||
(testing:load-test "context-resource.scm")
|
||||
(testing:load-test "context-stack.scm")
|
||||
|
||||
(testing:load-test "resource.scm")
|
||||
(testing:load-test "brush.scm")
|
||||
|
@ -69,6 +74,14 @@
|
|||
|
||||
; gimp module, gimp-get methods
|
||||
(testing:load-test "gimp.scm")
|
||||
; gimp PDB as a queriable store i.e. database
|
||||
(testing:load-test "PDB.scm")
|
||||
; test gimp as a refreshable set of installed resources
|
||||
(testing:load-test "refresh.scm")
|
||||
; test methods on PDBProcedure
|
||||
(testing:load-test "procedures.scm")
|
||||
|
||||
(testing:load-test "display.scm")
|
||||
|
||||
; TODO undo
|
||||
; TODO progress
|
||||
|
@ -77,13 +90,11 @@
|
|||
; unit
|
||||
; parasite
|
||||
|
||||
; pdb the object
|
||||
; gimp-parasite
|
||||
|
||||
|
||||
(testing:load-test "misc.scm")
|
||||
(testing:load-test "enums.scm")
|
||||
(testing:load-test "refresh.scm")
|
||||
(testing:load-test "bind-args.scm")
|
||||
|
||||
; report the result
|
||||
|
|
Loading…
Reference in New Issue