Initial checkin of Pika from heckimp
This commit is contained in:
107
plug-ins/script-fu/test/tests/PDB/selection/selection-from.scm
Normal file
107
plug-ins/script-fu/test/tests/PDB/selection/selection-from.scm
Normal file
@ -0,0 +1,107 @@
|
||||
; test PDB methods that change selection from existing selection
|
||||
|
||||
|
||||
; setup
|
||||
; Reusing image 10
|
||||
(define testImage 10)
|
||||
|
||||
|
||||
; Test a selection-changing function
|
||||
; starting from selection None.
|
||||
;
|
||||
; The testFunction takes a "step" arg
|
||||
; and does not change the selection bounds.
|
||||
|
||||
; {none <func> is-empty} yields true
|
||||
; {none <func>} is not an error
|
||||
|
||||
(define (test-selection-change-from-none testFunction testImage)
|
||||
; Starting state: selection none
|
||||
(assert `(pika-selection-none ,testImage))
|
||||
; test the testFunction
|
||||
(assert `(,testFunction
|
||||
,testImage
|
||||
4 )) ; radius or step
|
||||
; expect selection is still empty
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
1))
|
||||
; expect since there is no selection, the bounds are the entire image
|
||||
(assert `(equal? (cdr (pika-selection-bounds ,testImage))
|
||||
'(0 0 21 22)))
|
||||
)
|
||||
|
||||
(define (test-selection-change-from-all testFunction testImage isIdempotent)
|
||||
; Starting state: selection all
|
||||
(assert `(pika-selection-all ,testImage))
|
||||
; test the testFunction
|
||||
(assert `(,testFunction
|
||||
,testImage
|
||||
4 )) ; radius or step
|
||||
|
||||
(if isIdempotent
|
||||
(begin
|
||||
; expect selection is still not empty
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
0))
|
||||
; expect selection bounds are still entire image
|
||||
(assert `(equal? (cdr (pika-selection-bounds ,testImage))
|
||||
'(0 0 21 22)))))
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; test selection methods that change by a pixel amount
|
||||
(test-selection-change-from-none pika-selection-feather testImage)
|
||||
(test-selection-change-from-none pika-selection-grow testImage)
|
||||
(test-selection-change-from-none pika-selection-shrink testImage)
|
||||
(test-selection-change-from-none pika-selection-border testImage)
|
||||
|
||||
; feather and grow from all are idempotent
|
||||
(test-selection-change-from-all pika-selection-feather testImage #t)
|
||||
(test-selection-change-from-all pika-selection-grow testImage #t)
|
||||
|
||||
(test-selection-change-from-all pika-selection-shrink testImage #f)
|
||||
; shrink from all changes bounds
|
||||
(assert `(equal? (cdr (pika-selection-bounds ,testImage))
|
||||
'(4 4 17 18)))
|
||||
(test-selection-change-from-all pika-selection-border testImage #f)
|
||||
; border from all empties the selection
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
1))
|
||||
|
||||
|
||||
|
||||
|
||||
; Effectiveness
|
||||
; When starting from a typical selection (not empty, not all)
|
||||
|
||||
; TODO feather effective?
|
||||
; Might feather change bounds?
|
||||
|
||||
; grow is effective
|
||||
; bounds are larger
|
||||
; TODO
|
||||
(assert `(equal? (cdr (pika-selection-bounds ,testImage))
|
||||
'(0 0 21 22)))
|
||||
|
||||
; TODO test flood effective: holes were filled
|
||||
; Can't do it without knowing how many pixels are selected?
|
||||
; Knowing bounds is not adequate.
|
||||
|
||||
; Simple tests of success
|
||||
(assert `(pika-selection-flood ,testImage))
|
||||
(assert `(pika-selection-invert ,testImage))
|
||||
(assert `(pika-selection-sharpen ,testImage))
|
||||
(assert `(pika-selection-translate
|
||||
,testImage
|
||||
4 4))
|
||||
|
||||
; TODO invert none is all and vice versa
|
||||
|
||||
; TODO translate effective
|
||||
; TODO translate by large offset is empty selection
|
||||
; TODO sharpen is effective at removing antialiasing
|
||||
|
||||
; save creates a new channel
|
111
plug-ins/script-fu/test/tests/PDB/selection/selection.scm
Normal file
111
plug-ins/script-fu/test/tests/PDB/selection/selection.scm
Normal file
@ -0,0 +1,111 @@
|
||||
; Test methods of selection class of the PDB
|
||||
|
||||
|
||||
|
||||
; setup
|
||||
|
||||
(define testImage (car (pika-image-new 21 22 RGB)))
|
||||
|
||||
|
||||
; get-selection yields an ID.
|
||||
; Image always yields a selection object.
|
||||
; It is a singleton.
|
||||
(define testSelection (car (pika-image-get-selection testImage)))
|
||||
|
||||
|
||||
|
||||
|
||||
; The returned ID is-a Selection
|
||||
(assert `(= (car (pika-item-id-is-selection ,testSelection))
|
||||
1))
|
||||
|
||||
; !!! Note there is little use for a Selection instance.
|
||||
; There are no methods on the class per se i.e. taking the instance ID.
|
||||
; Except for methods on the superclass Item of subclass Selection.
|
||||
;
|
||||
; Instead the methods seem to be on an image.
|
||||
; Its not clear whether changing the selection in an image
|
||||
; also changes the singleton Selection instance,
|
||||
; and there is no way of knowing, since the Selection instance
|
||||
; has no methods.
|
||||
|
||||
; selection on new image is empty
|
||||
; !!! Requre no prior test on this image selected
|
||||
; !!! Arg is the image, not the selection object instance.
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
1))
|
||||
|
||||
; selection bounds yields (1 0 0 21 22)
|
||||
; First element of tuple is 0 (false)
|
||||
; indicates user or program has not made selection
|
||||
(assert `(= (car (pika-selection-bounds ,testImage))
|
||||
0))
|
||||
; selection bounds equal bounds of image
|
||||
(assert `(equal? (cdr (pika-selection-bounds ,testImage))
|
||||
'(0 0 21 22)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; select all and none
|
||||
|
||||
; select all succeeds
|
||||
(assert `(pika-selection-all ,testImage))
|
||||
; !!! A selection operation does not create a new selection object
|
||||
; i.e. ID is the same.
|
||||
; get-selection yields same singleton on image
|
||||
(assert `(= (car (pika-image-get-selection ,testImage))
|
||||
,testSelection))
|
||||
; after select all, selection bound indicates selection created
|
||||
(assert `(= (car (pika-selection-bounds ,testImage))
|
||||
1))
|
||||
; and now is-empty is false
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
0))
|
||||
|
||||
|
||||
; clear and none are the synonyms
|
||||
|
||||
; clear does not invalidate a prior selection object
|
||||
; i.e. get-selection returns same ID
|
||||
|
||||
; clear makes selection bounds equal entire image
|
||||
; TODO
|
||||
|
||||
; select none succeeds
|
||||
(assert `(pika-selection-none ,testImage))
|
||||
; effective: is-empty is true
|
||||
(assert `(= (car (pika-selection-is-empty ,testImage))
|
||||
1))
|
||||
; same singleton on image exists
|
||||
(assert `(= (car (pika-image-get-selection ,testImage))
|
||||
,testSelection))
|
||||
|
||||
|
||||
; misc selection operations
|
||||
|
||||
; pika-selection-value
|
||||
|
||||
|
||||
; change selection to totally new selection
|
||||
; Not a function of existing selection, by color or shape.
|
||||
|
||||
;pika-image-select-color
|
||||
; ,testImage
|
||||
; CHANNEL-OP-ADD
|
||||
; drawable
|
||||
; "red")
|
||||
|
||||
; pika-image-select-contiguous-color
|
||||
; ellipse
|
||||
; polygon
|
||||
; rectangle
|
||||
; round-rectangle
|
||||
|
||||
|
||||
|
||||
|
||||
; pika-selection-float is tested elsewhere
|
||||
; It is not an op on the selection, but an op on the image that uses the selection.
|
||||
; See pika-image-floating-selection
|
Reference in New Issue
Block a user