diff options
| author | Stefan Kangas | 2021-10-24 12:05:37 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2021-10-24 12:14:32 +0200 |
| commit | b2bfdd9658be87d34438f1a9ecd38242be6f6064 (patch) | |
| tree | c58d96f7403a3681e02766c9e04f37229170ef8f /test | |
| parent | b931e11a03fdb44e378133b10f312e38b1b3d712 (diff) | |
| download | emacs-b2bfdd9658be87d34438f1a9ecd38242be6f6064.tar.gz emacs-b2bfdd9658be87d34438f1a9ecd38242be6f6064.zip | |
Add tests for gif to src/image-tests.el
* test/src/image-tests.el (image-tests--images): Rename from
image-tests-files. Add gif.
(image-tests-image-size/gif)
(image-tests-image-mask-p/gif)
(image-tests-image-metadata/gif): New tests.
* test/data/image/black.gif: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/data/image/black.gif | bin | 0 -> 143 bytes | |||
| -rw-r--r-- | test/src/image-tests.el | 79 |
2 files changed, 48 insertions, 31 deletions
diff --git a/test/data/image/black.gif b/test/data/image/black.gif new file mode 100644 index 00000000000..6ab623e367e --- /dev/null +++ b/test/data/image/black.gif | |||
| Binary files differ | |||
diff --git a/test/src/image-tests.el b/test/src/image-tests.el index b921739a056..2b236086b6f 100644 --- a/test/src/image-tests.el +++ b/test/src/image-tests.el | |||
| @@ -35,8 +35,10 @@ | |||
| 35 | 35 | ||
| 36 | ;;;; Images | 36 | ;;;; Images |
| 37 | 37 | ||
| 38 | (defconst image-tests--files | 38 | (defconst image-tests--images |
| 39 | `((jpeg . ,(expand-file-name "test/data/image/black.jpg" | 39 | `((gif . ,(expand-file-name "test/data/image/black.gif" |
| 40 | source-directory)) | ||
| 41 | (jpeg . ,(expand-file-name "test/data/image/black.jpg" | ||
| 40 | source-directory)) | 42 | source-directory)) |
| 41 | (pbm . ,(find-image '((:file "splash.svg" :type svg)))) | 43 | (pbm . ,(find-image '((:file "splash.svg" :type svg)))) |
| 42 | (png . ,(find-image '((:file "splash.png" :type png)))) | 44 | (png . ,(find-image '((:file "splash.png" :type png)))) |
| @@ -47,64 +49,69 @@ | |||
| 47 | (webp . ,(expand-file-name "test/data/image/black.webp" | 49 | (webp . ,(expand-file-name "test/data/image/black.webp" |
| 48 | source-directory)) | 50 | source-directory)) |
| 49 | (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) | 51 | (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) |
| 50 | (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))) | 52 | (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))))) |
| 51 | ;; TODO: gif | ||
| 52 | )) | ||
| 53 | 53 | ||
| 54 | ;;;; image-test-size | 54 | ;;;; image-test-size |
| 55 | 55 | ||
| 56 | (ert-deftest image-tests-image-size/gif () | ||
| 57 | (image-skip-unless 'gif) | ||
| 58 | (pcase (image-size (create-image (cdr (assq 'gif image-tests--images)))) | ||
| 59 | (`(,a . ,b) | ||
| 60 | (should (floatp a)) | ||
| 61 | (should (floatp b))))) | ||
| 62 | |||
| 56 | (ert-deftest image-tests-image-size/jpeg () | 63 | (ert-deftest image-tests-image-size/jpeg () |
| 57 | (image-skip-unless 'jpeg) | 64 | (image-skip-unless 'jpeg) |
| 58 | (pcase (image-size (create-image (cdr (assq 'jpeg image-tests--files)))) | 65 | (pcase (image-size (create-image (cdr (assq 'jpeg image-tests--images)))) |
| 59 | (`(,a . ,b) | 66 | (`(,a . ,b) |
| 60 | (should (floatp a)) | 67 | (should (floatp a)) |
| 61 | (should (floatp b))))) | 68 | (should (floatp b))))) |
| 62 | 69 | ||
| 63 | (ert-deftest image-tests-image-size/pbm () | 70 | (ert-deftest image-tests-image-size/pbm () |
| 64 | (image-skip-unless 'pbm) | 71 | (image-skip-unless 'pbm) |
| 65 | (pcase (image-size (cdr (assq 'pbm image-tests--files))) | 72 | (pcase (image-size (cdr (assq 'pbm image-tests--images))) |
| 66 | (`(,a . ,b) | 73 | (`(,a . ,b) |
| 67 | (should (floatp a)) | 74 | (should (floatp a)) |
| 68 | (should (floatp b))))) | 75 | (should (floatp b))))) |
| 69 | 76 | ||
| 70 | (ert-deftest image-tests-image-size/png () | 77 | (ert-deftest image-tests-image-size/png () |
| 71 | (image-skip-unless 'png) | 78 | (image-skip-unless 'png) |
| 72 | (pcase (image-size (cdr (assq 'png image-tests--files))) | 79 | (pcase (image-size (cdr (assq 'png image-tests--images))) |
| 73 | (`(,a . ,b) | 80 | (`(,a . ,b) |
| 74 | (should (floatp a)) | 81 | (should (floatp a)) |
| 75 | (should (floatp b))))) | 82 | (should (floatp b))))) |
| 76 | 83 | ||
| 77 | (ert-deftest image-tests-image-size/svg () | 84 | (ert-deftest image-tests-image-size/svg () |
| 78 | (image-skip-unless 'svg) | 85 | (image-skip-unless 'svg) |
| 79 | (pcase (image-size (cdr (assq 'svg image-tests--files))) | 86 | (pcase (image-size (cdr (assq 'svg image-tests--images))) |
| 80 | (`(,a . ,b) | 87 | (`(,a . ,b) |
| 81 | (should (floatp a)) | 88 | (should (floatp a)) |
| 82 | (should (floatp b))))) | 89 | (should (floatp b))))) |
| 83 | 90 | ||
| 84 | (ert-deftest image-tests-image-size/tiff () | 91 | (ert-deftest image-tests-image-size/tiff () |
| 85 | (image-skip-unless 'tiff) | 92 | (image-skip-unless 'tiff) |
| 86 | (pcase (image-size (create-image (cdr (assq 'tiff image-tests--files)))) | 93 | (pcase (image-size (create-image (cdr (assq 'tiff image-tests--images)))) |
| 87 | (`(,a . ,b) | 94 | (`(,a . ,b) |
| 88 | (should (floatp a)) | 95 | (should (floatp a)) |
| 89 | (should (floatp b))))) | 96 | (should (floatp b))))) |
| 90 | 97 | ||
| 91 | (ert-deftest image-tests-image-size/webp () | 98 | (ert-deftest image-tests-image-size/webp () |
| 92 | (image-skip-unless 'webp) | 99 | (image-skip-unless 'webp) |
| 93 | (pcase (image-size (create-image (cdr (assq 'webp image-tests--files)))) | 100 | (pcase (image-size (create-image (cdr (assq 'webp image-tests--images)))) |
| 94 | (`(,a . ,b) | 101 | (`(,a . ,b) |
| 95 | (should (floatp a)) | 102 | (should (floatp a)) |
| 96 | (should (floatp b))))) | 103 | (should (floatp b))))) |
| 97 | 104 | ||
| 98 | (ert-deftest image-tests-image-size/xbm () | 105 | (ert-deftest image-tests-image-size/xbm () |
| 99 | (image-skip-unless 'xbm) | 106 | (image-skip-unless 'xbm) |
| 100 | (pcase (image-size (cdr (assq 'xbm image-tests--files))) | 107 | (pcase (image-size (cdr (assq 'xbm image-tests--images))) |
| 101 | (`(,a . ,b) | 108 | (`(,a . ,b) |
| 102 | (should (floatp a)) | 109 | (should (floatp a)) |
| 103 | (should (floatp b))))) | 110 | (should (floatp b))))) |
| 104 | 111 | ||
| 105 | (ert-deftest image-tests-image-size/xpm () | 112 | (ert-deftest image-tests-image-size/xpm () |
| 106 | (image-skip-unless 'xpm) | 113 | (image-skip-unless 'xpm) |
| 107 | (pcase (image-size (cdr (assq 'xpm image-tests--files))) | 114 | (pcase (image-size (cdr (assq 'xpm image-tests--images))) |
| 108 | (`(,a . ,b) | 115 | (`(,a . ,b) |
| 109 | (should (floatp a)) | 116 | (should (floatp a)) |
| 110 | (should (floatp b))))) | 117 | (should (floatp b))))) |
| @@ -119,40 +126,45 @@ | |||
| 119 | 126 | ||
| 120 | ;;;; image-mask-p | 127 | ;;;; image-mask-p |
| 121 | 128 | ||
| 129 | (ert-deftest image-tests-image-mask-p/gif () | ||
| 130 | (image-skip-unless 'gif) | ||
| 131 | (should-not (image-mask-p (create-image | ||
| 132 | (cdr (assq 'gif image-tests--images)))))) | ||
| 133 | |||
| 122 | (ert-deftest image-tests-image-mask-p/jpeg () | 134 | (ert-deftest image-tests-image-mask-p/jpeg () |
| 123 | (image-skip-unless 'jpeg) | 135 | (image-skip-unless 'jpeg) |
| 124 | (should-not (image-mask-p (create-image | 136 | (should-not (image-mask-p (create-image |
| 125 | (cdr (assq 'jpeg image-tests--files)))))) | 137 | (cdr (assq 'jpeg image-tests--images)))))) |
| 126 | 138 | ||
| 127 | (ert-deftest image-tests-image-mask-p/pbm () | 139 | (ert-deftest image-tests-image-mask-p/pbm () |
| 128 | (image-skip-unless 'pbm) | 140 | (image-skip-unless 'pbm) |
| 129 | (should-not (image-mask-p (cdr (assq 'pbm image-tests--files))))) | 141 | (should-not (image-mask-p (cdr (assq 'pbm image-tests--images))))) |
| 130 | 142 | ||
| 131 | (ert-deftest image-tests-image-mask-p/png () | 143 | (ert-deftest image-tests-image-mask-p/png () |
| 132 | (image-skip-unless 'png) | 144 | (image-skip-unless 'png) |
| 133 | (should-not (image-mask-p (cdr (assq 'png image-tests--files))))) | 145 | (should-not (image-mask-p (cdr (assq 'png image-tests--images))))) |
| 134 | 146 | ||
| 135 | (ert-deftest image-tests-image-mask-p/svg () | 147 | (ert-deftest image-tests-image-mask-p/svg () |
| 136 | (image-skip-unless 'svg) | 148 | (image-skip-unless 'svg) |
| 137 | (should-not (image-mask-p (cdr (assq 'svg image-tests--files))))) | 149 | (should-not (image-mask-p (cdr (assq 'svg image-tests--images))))) |
| 138 | 150 | ||
| 139 | (ert-deftest image-tests-image-mask-p/tiff () | 151 | (ert-deftest image-tests-image-mask-p/tiff () |
| 140 | (image-skip-unless 'tiff) | 152 | (image-skip-unless 'tiff) |
| 141 | (should-not (image-mask-p (create-image | 153 | (should-not (image-mask-p (create-image |
| 142 | (cdr (assq 'tiff image-tests--files)))))) | 154 | (cdr (assq 'tiff image-tests--images)))))) |
| 143 | 155 | ||
| 144 | (ert-deftest image-tests-image-mask-p/webp () | 156 | (ert-deftest image-tests-image-mask-p/webp () |
| 145 | (image-skip-unless 'webp) | 157 | (image-skip-unless 'webp) |
| 146 | (should-not (image-mask-p (create-image | 158 | (should-not (image-mask-p (create-image |
| 147 | (cdr (assq 'webp image-tests--files)))))) | 159 | (cdr (assq 'webp image-tests--images)))))) |
| 148 | 160 | ||
| 149 | (ert-deftest image-tests-image-mask-p/xbm () | 161 | (ert-deftest image-tests-image-mask-p/xbm () |
| 150 | (image-skip-unless 'xbm) | 162 | (image-skip-unless 'xbm) |
| 151 | (should-not (image-mask-p (cdr (assq 'xbm image-tests--files))))) | 163 | (should-not (image-mask-p (cdr (assq 'xbm image-tests--images))))) |
| 152 | 164 | ||
| 153 | (ert-deftest image-tests-image-mask-p/xpm () | 165 | (ert-deftest image-tests-image-mask-p/xpm () |
| 154 | (image-skip-unless 'xpm) | 166 | (image-skip-unless 'xpm) |
| 155 | (should-not (image-mask-p (cdr (assq 'xpm image-tests--files))))) | 167 | (should-not (image-mask-p (cdr (assq 'xpm image-tests--images))))) |
| 156 | 168 | ||
| 157 | (ert-deftest image-tests-image-mask-p/error-on-invalid-spec () | 169 | (ert-deftest image-tests-image-mask-p/error-on-invalid-spec () |
| 158 | (skip-unless (display-images-p)) | 170 | (skip-unless (display-images-p)) |
| @@ -160,47 +172,52 @@ | |||
| 160 | 172 | ||
| 161 | (ert-deftest image-tests-image-mask-p/error-on-nongraphical-display () | 173 | (ert-deftest image-tests-image-mask-p/error-on-nongraphical-display () |
| 162 | (skip-unless (not (display-images-p))) | 174 | (skip-unless (not (display-images-p))) |
| 163 | (should-error (image-mask-p (cdr (assq 'xpm image-tests--files))))) | 175 | (should-error (image-mask-p (cdr (assq 'xpm image-tests--images))))) |
| 164 | 176 | ||
| 165 | ;;;; image-metadata | 177 | ;;;; image-metadata |
| 166 | 178 | ||
| 167 | ;; TODO: These tests could be expanded with files that actually | 179 | ;; TODO: These tests could be expanded with files that actually |
| 168 | ;; contain metadata. | 180 | ;; contain metadata. |
| 169 | 181 | ||
| 182 | (ert-deftest image-tests-image-metadata/gif () | ||
| 183 | (image-skip-unless 'gif) | ||
| 184 | (should-not (image-metadata | ||
| 185 | (create-image (cdr (assq 'gif image-tests--images)))))) | ||
| 186 | |||
| 170 | (ert-deftest image-tests-image-metadata/jpeg () | 187 | (ert-deftest image-tests-image-metadata/jpeg () |
| 171 | (image-skip-unless 'jpeg) | 188 | (image-skip-unless 'jpeg) |
| 172 | (should-not (image-metadata | 189 | (should-not (image-metadata |
| 173 | (create-image (cdr (assq 'jpeg image-tests--files)))))) | 190 | (create-image (cdr (assq 'jpeg image-tests--images)))))) |
| 174 | 191 | ||
| 175 | (ert-deftest image-tests-image-metadata/pbm () | 192 | (ert-deftest image-tests-image-metadata/pbm () |
| 176 | (image-skip-unless 'pbm) | 193 | (image-skip-unless 'pbm) |
| 177 | (should-not (image-metadata (cdr (assq 'pbm image-tests--files))))) | 194 | (should-not (image-metadata (cdr (assq 'pbm image-tests--images))))) |
| 178 | 195 | ||
| 179 | (ert-deftest image-tests-image-metadata/png () | 196 | (ert-deftest image-tests-image-metadata/png () |
| 180 | (image-skip-unless 'png) | 197 | (image-skip-unless 'png) |
| 181 | (should-not (image-metadata (cdr (assq 'png image-tests--files))))) | 198 | (should-not (image-metadata (cdr (assq 'png image-tests--images))))) |
| 182 | 199 | ||
| 183 | (ert-deftest image-tests-image-metadata/svg () | 200 | (ert-deftest image-tests-image-metadata/svg () |
| 184 | (image-skip-unless 'svg) | 201 | (image-skip-unless 'svg) |
| 185 | (should-not (image-metadata (cdr (assq 'svg image-tests--files))))) | 202 | (should-not (image-metadata (cdr (assq 'svg image-tests--images))))) |
| 186 | 203 | ||
| 187 | (ert-deftest image-tests-image-metadata/tiff () | 204 | (ert-deftest image-tests-image-metadata/tiff () |
| 188 | (image-skip-unless 'tiff) | 205 | (image-skip-unless 'tiff) |
| 189 | (should-not (image-metadata | 206 | (should-not (image-metadata |
| 190 | (create-image (cdr (assq 'tiff image-tests--files)))))) | 207 | (create-image (cdr (assq 'tiff image-tests--images)))))) |
| 191 | 208 | ||
| 192 | (ert-deftest image-tests-image-metadata/webp () | 209 | (ert-deftest image-tests-image-metadata/webp () |
| 193 | (image-skip-unless 'webp) | 210 | (image-skip-unless 'webp) |
| 194 | (should-not (image-metadata | 211 | (should-not (image-metadata |
| 195 | (create-image (cdr (assq 'webp image-tests--files)))))) | 212 | (create-image (cdr (assq 'webp image-tests--images)))))) |
| 196 | 213 | ||
| 197 | (ert-deftest image-tests-image-metadata/xbm () | 214 | (ert-deftest image-tests-image-metadata/xbm () |
| 198 | (image-skip-unless 'xbm) | 215 | (image-skip-unless 'xbm) |
| 199 | (should-not (image-metadata (cdr (assq 'xbm image-tests--files))))) | 216 | (should-not (image-metadata (cdr (assq 'xbm image-tests--images))))) |
| 200 | 217 | ||
| 201 | (ert-deftest image-tests-image-metadata/xpm () | 218 | (ert-deftest image-tests-image-metadata/xpm () |
| 202 | (image-skip-unless 'xpm) | 219 | (image-skip-unless 'xpm) |
| 203 | (should-not (image-metadata (cdr (assq 'xpm image-tests--files))))) | 220 | (should-not (image-metadata (cdr (assq 'xpm image-tests--images))))) |
| 204 | 221 | ||
| 205 | (ert-deftest image-tests-image-metadata/nil-on-invalid-spec () | 222 | (ert-deftest image-tests-image-metadata/nil-on-invalid-spec () |
| 206 | (skip-unless (display-images-p)) | 223 | (skip-unless (display-images-p)) |
| @@ -208,7 +225,7 @@ | |||
| 208 | 225 | ||
| 209 | (ert-deftest image-tests-image-metadata/error-on-nongraphical-display () | 226 | (ert-deftest image-tests-image-metadata/error-on-nongraphical-display () |
| 210 | (skip-unless (not (display-images-p))) | 227 | (skip-unless (not (display-images-p))) |
| 211 | (should-error (image-metadata (cdr (assq 'xpm image-tests--files))))) | 228 | (should-error (image-metadata (cdr (assq 'xpm image-tests--images))))) |
| 212 | 229 | ||
| 213 | ;;;; ImageMagick | 230 | ;;;; ImageMagick |
| 214 | 231 | ||