PIKApp/plug-ins/script-fu/test/tests/PDB/layer/layer-ops.scm

89 lines
2.5 KiB
Scheme
Raw Normal View History

2023-09-26 00:35:21 +02:00
; test Layer methods of PDB
; where methods are operations
; setup
(define testImage (car (pika-image-new 21 22 RGB)))
(define
testLayer (car (pika-layer-new
testImage
21
22
RGB-IMAGE
"LayerNew#2"
50.0
LAYER-MODE-NORMAL)))
; assert layer is not inserted in image
; errors when layer not in image
; resize fails
(assert-error `(pika-layer-resize ,testLayer 23 24 0 0)
(string-append
"Procedure execution of pika-layer-resize failed on invalid input arguments: "))
;"Item 'LayerNew#2' (10) cannot be used because it has not been added to an image"))
; scale fails
(assert-error `(pika-layer-scale ,testLayer
23 24 ; width height
0) ; is local origin?
(string-append
"Procedure execution of pika-layer-scale failed on invalid input arguments: "))
;"Item 'LayerNew#2' (10) cannot be used because it has not been added to an image"))
; pika-layer-resize-to-image-size fails
; TODO
; pika-layer-remove-mask fails when layer has no mask
(assert-error `(pika-layer-remove-mask
,testLayer
MASK-APPLY)
(string-append
"Procedure execution of pika-layer-remove-mask failed on invalid input arguments: "))
; "Item 'LayerNew#2' (10) cannot be used because it has not been added to an image"))
; alpha operations
; add-alpha succeeds
(assert `(pika-layer-add-alpha ,testLayer))
; and is effective
; Note method on superclass Drawable
(assert `(= (car (pika-drawable-has-alpha ,testLayer))
1))
; flatten succeeds
(assert `(pika-layer-flatten ,testLayer))
; flatten was effective: no longer has alpha
; flatten a layer means "remove alpha"
(assert `(= (car (pika-drawable-has-alpha ,testLayer))
0))
; delete
; delete succeeds
(assert `(pika-layer-delete ,testLayer))
; delete second time fails
(assert-error `(pika-layer-delete ,testLayer)
"runtime: invalid item ID")
; Error for flatten:
; "Procedure execution of pika-layer-delete failed on invalid input arguments: "
; "Procedure 'pika-layer-delete' has been called with an invalid ID for argument 'layer'. "
; "Most likely a plug-in is trying to work on a layer that doesn't exist any longer."))
; delete layer when image already deleted fails
; TODO