]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests for opening different image formats
authorStefan Kangas <stefankangas@gmail.com>
Tue, 6 Sep 2022 11:03:40 +0000 (13:03 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Tue, 6 Sep 2022 11:13:15 +0000 (13:13 +0200)
* test/src/image-tests.el
(image-tests-make-load-image-test): New macro.
(image-tests-load-image/gif)
(image-tests-load-image/jpeg)
(image-tests-load-image/pbm)
(image-tests-load-image/png)
(image-tests-load-image/svg)
(image-tests-load-image/tiff)
(image-tests-load-image/webp)
(image-tests-load-image/xbm)
(image-tests-load-image/xpm): New tests.

test/src/image-tests.el

index c05582ada756f2de7ee519b7f43d8141925add1d..0a13db67d45b161ac02889d7bdb386b12a37d51f 100644 (file)
   `(skip-unless (and (display-images-p)
                      (image-type-available-p ,format))))
 
-;;;; Images
+\f
+;;;; Image data
 
 (defconst image-tests--images
   `((gif . ,(expand-file-name "test/data/image/black.gif"
-                               source-directory))
+                              source-directory))
     (jpeg . ,(expand-file-name "test/data/image/black.jpg"
                                source-directory))
     (pbm . ,(find-image '((:file "splash.svg" :type svg))))
     (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm))))
     (xpm . ,(find-image '((:file "splash.xpm" :type xpm))))))
 
+\f
+;;;; Load image
+
+(defmacro image-tests-make-load-image-test (type)
+  `(ert-deftest ,(intern (format "image-tests-load-image/%s"
+                                 (eval type t)))
+       ()
+     (image-skip-unless ,type)
+     (let* ((img (cdr (assq ,type image-tests--images)))
+            (file (if (listp img)
+                      (plist-get (cdr img) :file)
+                    img)))
+       (find-file file))
+     (should (equal major-mode 'image-mode))
+     ;; Cleanup
+     (kill-buffer (current-buffer))))
+
+(image-tests-make-load-image-test 'gif)
+(image-tests-make-load-image-test 'jpeg)
+(image-tests-make-load-image-test 'pbm)
+(image-tests-make-load-image-test 'png)
+(image-tests-make-load-image-test 'svg)
+(image-tests-make-load-image-test 'tiff)
+(image-tests-make-load-image-test 'webp)
+(image-tests-make-load-image-test 'xbm)
+(image-tests-make-load-image-test 'xpm)
+
+\f
 ;;;; image-test-size
 
 (declare-function image-size "image.c" (spec &optional pixels frame))
   (skip-unless (not (display-images-p)))
   (should-error (image-size 'invalid-spec)))
 
+\f
 ;;;; image-mask-p
 
 (declare-function image-mask-p "image.c" (spec &optional frame))
   (skip-unless (not (display-images-p)))
   (should-error (image-mask-p (cdr (assq 'xpm image-tests--images)))))
 
+\f
 ;;;; image-metadata
 
 (declare-function image-metadata "image.c" (spec &optional frame))
   (skip-unless (not (display-images-p)))
   (should-error (image-metadata (cdr (assq 'xpm image-tests--images)))))
 
+\f
 ;;;; ImageMagick
 
 (ert-deftest image-tests-imagemagick-types ()
   (when (fboundp 'imagemagick-types)
     (should (listp (imagemagick-types)))))
 
+\f
 ;;;; Initialization
 
 (ert-deftest image-tests-init-image-library ()