PIKApp/plug-ins/script-fu/test/tests/PDB/image/image-new.scm

149 lines
3.5 KiB
Scheme

; test Image methods of PDB
; loading this file changes testing state
; Using numeric equality operator '=' on numeric ID's
; setup
; method new from fresh PIKA state returns ID 1
(define testImage (car (pika-image-new 21 22 RGB)))
; FUTURE method is_valid on new image yields #t
; method is_valid on new image yields 1 i.e. true
(assert `(=
(car (pika-image-id-is-valid ,testImage))
1))
; Ensure attributes of new image are correct
; method is_dirty on new image is true
(assert `(=
(car (pika-image-is-dirty ,testImage))
1))
; method get_width on new image yields same width given when created
(assert `(=
(car (pika-image-get-width ,testImage))
21))
; method get_height on new image yields same height given when created
(assert `(=
(car (pika-image-get-height ,testImage))
22))
; method get-base-type yields same image type given when created
(assert `(=
(car (pika-image-get-base-type ,testImage))
RGB))
; new image is known to pika
; Returns (<length> #(1))
(assert `(= (car (pika-get-images))
,testImage))
; new image has no components
; new image has zero layers
(assert `(= (car (pika-image-get-layers ,testImage))
0))
; new image has zero vectors
(assert `(= (car (pika-image-get-vectors ,testImage))
0))
; new image has no parasites
(assert `(= (length
(car (pika-image-get-parasite-list ,testImage)))
0))
; new image has-a selection
(assert `(pika-image-get-selection ,testImage))
; new image has no floating selection
(assert `(=
(car (pika-image-get-floating-sel ,testImage))
-1))
; TODO floating-sel-attached-to
; new image has unit having ID 1
(assert `(=
(car (pika-image-get-unit ,testImage))
1))
; new image has name
(assert `(string=?
(car (pika-image-get-name ,testImage))
"[Untitled]"))
; new image has empty metadata string
(assert `(string=?
(car (pika-image-get-metadata ,testImage))
""))
; has an effective color profile
(assert `(pika-image-get-effective-color-profile ,testImage))
; new image has no associated files
; GFile is string in ScriptFu
; no file, xcf file, imported file, or exported file
(assert `(string=? (car (pika-image-get-file ,testImage)) ""))
(assert `(string=? (car (pika-image-get-xcf-file ,testImage)) ""))
(assert `(string=? (car (pika-image-get-imported-file ,testImage)) ""))
(assert `(string=? (car (pika-image-get-exported-file ,testImage)) ""))
; Test delete method.
; !!! ID 1 is no longer valid
; method delete succeeds on new image
; returns 1 for true. FUTURE returns #t
(assert `(car (pika-image-delete ,testImage)))
; ensure id invalid for deleted image
; returns 0 for false. FUTURE returns #f
(assert `(=
(car (pika-image-id-is-valid ,testImage))
0))
; deleted image is not in pika
; Returns (<length> #())
; FUTURE Returns empty list `()
(assert `(=
(car (pika-get-images))
0))
; !!! This only passes when testing is from fresh Pika restart
; Test abnormal args to image-new
; Dimension zero yields error
; It does NOT yield invalid ID -1
(assert-error `(pika-image-new 0 0 RGB)
(string-append
"Procedure execution of pika-image-new failed on invalid input arguments: "
"Procedure 'pika-image-new' has been called with value '0' for argument 'width' (#1, type gint)."))
; " This value is out of range."