diff options
| author | Stefan Kangas | 2022-09-08 02:35:37 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2022-09-08 02:35:37 +0200 |
| commit | 5b87429d99bf99c0adde371a5ecfd2c745fc3489 (patch) | |
| tree | c56a71531c040404b41e205fe13f38f398600002 | |
| parent | ffe50d41d98cf05622288b33cd014be18319dce0 (diff) | |
| download | emacs-5b87429d99bf99c0adde371a5ecfd2c745fc3489.tar.gz emacs-5b87429d99bf99c0adde371a5ecfd2c745fc3489.zip | |
Move some tests to test/manual/image-tests.el
* test/src/image-tests.el: Move several tests from here...
* test/manual/image-tests.el: ...to here.
Suggested by Eli Zaretskii <eliz@gnu.org>.
| -rw-r--r-- | test/manual/image-tests.el | 256 | ||||
| -rw-r--r-- | test/src/image-tests.el | 224 |
2 files changed, 256 insertions, 224 deletions
diff --git a/test/manual/image-tests.el b/test/manual/image-tests.el new file mode 100644 index 00000000000..2565ff29c9b --- /dev/null +++ b/test/manual/image-tests.el | |||
| @@ -0,0 +1,256 @@ | |||
| 1 | ;;; image-tests.el --- tests for image.c -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2021-2022 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Kangas <stefankangas@gmail.com> | ||
| 6 | ;; Keywords: internal | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; These tests will only run in a GUI session. You must run them | ||
| 26 | ;; manually in an interactive session with, for example, `M-x | ||
| 27 | ;; eval-buffer' followed by `M-x ert'. | ||
| 28 | ;; | ||
| 29 | ;; To run them from the command line instead, try: | ||
| 30 | ;; ./src/emacs -Q -l test/manual/image-tests.el -eval "(ert t)" | ||
| 31 | |||
| 32 | ;;; Code: | ||
| 33 | |||
| 34 | (defmacro image-skip-unless (format) | ||
| 35 | `(skip-unless (and (display-images-p) | ||
| 36 | (image-type-available-p ,format)))) | ||
| 37 | |||
| 38 | (defconst image-tests--images | ||
| 39 | `((gif . ,(expand-file-name "test/data/image/black.gif" | ||
| 40 | source-directory)) | ||
| 41 | (jpeg . ,(expand-file-name "test/data/image/black.jpg" | ||
| 42 | source-directory)) | ||
| 43 | (pbm . ,(find-image '((:file "splash.svg" :type svg)))) | ||
| 44 | (png . ,(find-image '((:file "splash.png" :type png)))) | ||
| 45 | (svg . ,(find-image '((:file "splash.pbm" :type pbm)))) | ||
| 46 | (tiff . ,(expand-file-name | ||
| 47 | "nextstep/GNUstep/Emacs.base/Resources/emacs.tiff" | ||
| 48 | source-directory)) | ||
| 49 | (webp . ,(expand-file-name "test/data/image/black.webp" | ||
| 50 | source-directory)) | ||
| 51 | (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) | ||
| 52 | (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))))) | ||
| 53 | |||
| 54 | |||
| 55 | ;;;; Load image | ||
| 56 | |||
| 57 | (defmacro image-tests-make-load-image-test (type) | ||
| 58 | `(ert-deftest ,(intern (format "image-tests-load-image/%s" | ||
| 59 | (eval type t))) | ||
| 60 | () | ||
| 61 | (image-skip-unless ,type) | ||
| 62 | (let* ((img (cdr (assq ,type image-tests--images))) | ||
| 63 | (file (if (listp img) | ||
| 64 | (plist-get (cdr img) :file) | ||
| 65 | img))) | ||
| 66 | (find-file file)) | ||
| 67 | (should (equal major-mode 'image-mode)) | ||
| 68 | ;; Cleanup | ||
| 69 | (kill-buffer (current-buffer)))) | ||
| 70 | |||
| 71 | (image-tests-make-load-image-test 'gif) | ||
| 72 | (image-tests-make-load-image-test 'jpeg) | ||
| 73 | (image-tests-make-load-image-test 'pbm) | ||
| 74 | (image-tests-make-load-image-test 'png) | ||
| 75 | (image-tests-make-load-image-test 'svg) | ||
| 76 | (image-tests-make-load-image-test 'tiff) | ||
| 77 | (image-tests-make-load-image-test 'webp) | ||
| 78 | (image-tests-make-load-image-test 'xbm) | ||
| 79 | (image-tests-make-load-image-test 'xpm) | ||
| 80 | |||
| 81 | |||
| 82 | ;;;; image-test-size | ||
| 83 | |||
| 84 | (declare-function image-size "image.c" (spec &optional pixels frame)) | ||
| 85 | |||
| 86 | (ert-deftest image-tests-image-size/gif () | ||
| 87 | (image-skip-unless 'gif) | ||
| 88 | (pcase (image-size (create-image (cdr (assq 'gif image-tests--images)))) | ||
| 89 | (`(,a . ,b) | ||
| 90 | (should (floatp a)) | ||
| 91 | (should (floatp b))))) | ||
| 92 | |||
| 93 | (ert-deftest image-tests-image-size/jpeg () | ||
| 94 | (image-skip-unless 'jpeg) | ||
| 95 | (pcase (image-size (create-image (cdr (assq 'jpeg image-tests--images)))) | ||
| 96 | (`(,a . ,b) | ||
| 97 | (should (floatp a)) | ||
| 98 | (should (floatp b))))) | ||
| 99 | |||
| 100 | (ert-deftest image-tests-image-size/pbm () | ||
| 101 | (image-skip-unless 'pbm) | ||
| 102 | (pcase (image-size (cdr (assq 'pbm image-tests--images))) | ||
| 103 | (`(,a . ,b) | ||
| 104 | (should (floatp a)) | ||
| 105 | (should (floatp b))))) | ||
| 106 | |||
| 107 | (ert-deftest image-tests-image-size/png () | ||
| 108 | (image-skip-unless 'png) | ||
| 109 | (pcase (image-size (cdr (assq 'png image-tests--images))) | ||
| 110 | (`(,a . ,b) | ||
| 111 | (should (floatp a)) | ||
| 112 | (should (floatp b))))) | ||
| 113 | |||
| 114 | (ert-deftest image-tests-image-size/svg () | ||
| 115 | (image-skip-unless 'svg) | ||
| 116 | (pcase (image-size (cdr (assq 'svg image-tests--images))) | ||
| 117 | (`(,a . ,b) | ||
| 118 | (should (floatp a)) | ||
| 119 | (should (floatp b))))) | ||
| 120 | |||
| 121 | (ert-deftest image-tests-image-size/tiff () | ||
| 122 | (image-skip-unless 'tiff) | ||
| 123 | (pcase (image-size (create-image (cdr (assq 'tiff image-tests--images)))) | ||
| 124 | (`(,a . ,b) | ||
| 125 | (should (floatp a)) | ||
| 126 | (should (floatp b))))) | ||
| 127 | |||
| 128 | (ert-deftest image-tests-image-size/webp () | ||
| 129 | (image-skip-unless 'webp) | ||
| 130 | (pcase (image-size (create-image (cdr (assq 'webp image-tests--images)))) | ||
| 131 | (`(,a . ,b) | ||
| 132 | (should (floatp a)) | ||
| 133 | (should (floatp b))))) | ||
| 134 | |||
| 135 | (ert-deftest image-tests-image-size/xbm () | ||
| 136 | (image-skip-unless 'xbm) | ||
| 137 | (pcase (image-size (cdr (assq 'xbm image-tests--images))) | ||
| 138 | (`(,a . ,b) | ||
| 139 | (should (floatp a)) | ||
| 140 | (should (floatp b))))) | ||
| 141 | |||
| 142 | (ert-deftest image-tests-image-size/xpm () | ||
| 143 | (image-skip-unless 'xpm) | ||
| 144 | (pcase (image-size (cdr (assq 'xpm image-tests--images))) | ||
| 145 | (`(,a . ,b) | ||
| 146 | (should (floatp a)) | ||
| 147 | (should (floatp b))))) | ||
| 148 | |||
| 149 | (ert-deftest image-tests-image-size/error-on-invalid-spec () | ||
| 150 | (skip-unless (display-images-p)) | ||
| 151 | (should-error (image-size 'invalid-spec))) | ||
| 152 | |||
| 153 | |||
| 154 | ;;;; image-mask-p | ||
| 155 | |||
| 156 | (declare-function image-mask-p "image.c" (spec &optional frame)) | ||
| 157 | |||
| 158 | (ert-deftest image-tests-image-mask-p/gif () | ||
| 159 | (image-skip-unless 'gif) | ||
| 160 | (should-not (image-mask-p (create-image | ||
| 161 | (cdr (assq 'gif image-tests--images)))))) | ||
| 162 | |||
| 163 | (ert-deftest image-tests-image-mask-p/jpeg () | ||
| 164 | (image-skip-unless 'jpeg) | ||
| 165 | (should-not (image-mask-p (create-image | ||
| 166 | (cdr (assq 'jpeg image-tests--images)))))) | ||
| 167 | |||
| 168 | (ert-deftest image-tests-image-mask-p/pbm () | ||
| 169 | (image-skip-unless 'pbm) | ||
| 170 | (should-not (image-mask-p (cdr (assq 'pbm image-tests--images))))) | ||
| 171 | |||
| 172 | (ert-deftest image-tests-image-mask-p/png () | ||
| 173 | (image-skip-unless 'png) | ||
| 174 | (should-not (image-mask-p (cdr (assq 'png image-tests--images))))) | ||
| 175 | |||
| 176 | (ert-deftest image-tests-image-mask-p/svg () | ||
| 177 | (image-skip-unless 'svg) | ||
| 178 | (should-not (image-mask-p (cdr (assq 'svg image-tests--images))))) | ||
| 179 | |||
| 180 | (ert-deftest image-tests-image-mask-p/tiff () | ||
| 181 | (image-skip-unless 'tiff) | ||
| 182 | (should-not (image-mask-p (create-image | ||
| 183 | (cdr (assq 'tiff image-tests--images)))))) | ||
| 184 | |||
| 185 | (ert-deftest image-tests-image-mask-p/webp () | ||
| 186 | (image-skip-unless 'webp) | ||
| 187 | (should-not (image-mask-p (create-image | ||
| 188 | (cdr (assq 'webp image-tests--images)))))) | ||
| 189 | |||
| 190 | (ert-deftest image-tests-image-mask-p/xbm () | ||
| 191 | (image-skip-unless 'xbm) | ||
| 192 | (should-not (image-mask-p (cdr (assq 'xbm image-tests--images))))) | ||
| 193 | |||
| 194 | (ert-deftest image-tests-image-mask-p/xpm () | ||
| 195 | (image-skip-unless 'xpm) | ||
| 196 | (should-not (image-mask-p (cdr (assq 'xpm image-tests--images))))) | ||
| 197 | |||
| 198 | (ert-deftest image-tests-image-mask-p/error-on-invalid-spec () | ||
| 199 | (skip-unless (display-images-p)) | ||
| 200 | (should-error (image-mask-p 'invalid-spec))) | ||
| 201 | |||
| 202 | |||
| 203 | ;;;; image-metadata | ||
| 204 | |||
| 205 | (declare-function image-metadata "image.c" (spec &optional frame)) | ||
| 206 | |||
| 207 | ;; TODO: These tests could be expanded with files that actually | ||
| 208 | ;; contain metadata. | ||
| 209 | |||
| 210 | (ert-deftest image-tests-image-metadata/gif () | ||
| 211 | (image-skip-unless 'gif) | ||
| 212 | (should (memq 'delay | ||
| 213 | (image-metadata | ||
| 214 | (create-image (cdr (assq 'gif image-tests--images))))))) | ||
| 215 | |||
| 216 | (ert-deftest image-tests-image-metadata/jpeg () | ||
| 217 | (image-skip-unless 'jpeg) | ||
| 218 | (should-not (image-metadata | ||
| 219 | (create-image (cdr (assq 'jpeg image-tests--images)))))) | ||
| 220 | |||
| 221 | (ert-deftest image-tests-image-metadata/pbm () | ||
| 222 | (image-skip-unless 'pbm) | ||
| 223 | (should-not (image-metadata (cdr (assq 'pbm image-tests--images))))) | ||
| 224 | |||
| 225 | (ert-deftest image-tests-image-metadata/png () | ||
| 226 | (image-skip-unless 'png) | ||
| 227 | (should-not (image-metadata (cdr (assq 'png image-tests--images))))) | ||
| 228 | |||
| 229 | (ert-deftest image-tests-image-metadata/svg () | ||
| 230 | (image-skip-unless 'svg) | ||
| 231 | (should-not (image-metadata (cdr (assq 'svg image-tests--images))))) | ||
| 232 | |||
| 233 | (ert-deftest image-tests-image-metadata/tiff () | ||
| 234 | (image-skip-unless 'tiff) | ||
| 235 | (should-not (image-metadata | ||
| 236 | (create-image (cdr (assq 'tiff image-tests--images)))))) | ||
| 237 | |||
| 238 | (ert-deftest image-tests-image-metadata/webp () | ||
| 239 | (image-skip-unless 'webp) | ||
| 240 | (should (memq 'delay | ||
| 241 | (image-metadata | ||
| 242 | (create-image (cdr (assq 'webp image-tests--images))))))) | ||
| 243 | |||
| 244 | (ert-deftest image-tests-image-metadata/xbm () | ||
| 245 | (image-skip-unless 'xbm) | ||
| 246 | (should-not (image-metadata (cdr (assq 'xbm image-tests--images))))) | ||
| 247 | |||
| 248 | (ert-deftest image-tests-image-metadata/xpm () | ||
| 249 | (image-skip-unless 'xpm) | ||
| 250 | (should-not (image-metadata (cdr (assq 'xpm image-tests--images))))) | ||
| 251 | |||
| 252 | (ert-deftest image-tests-image-metadata/nil-on-invalid-spec () | ||
| 253 | (skip-unless (display-images-p)) | ||
| 254 | (should-not (image-metadata 'invalid-spec))) | ||
| 255 | |||
| 256 | ;;; image-size-tests.el ends here | ||
diff --git a/test/src/image-tests.el b/test/src/image-tests.el index 0b2d42ab9f2..bf79faca52e 100644 --- a/test/src/image-tests.el +++ b/test/src/image-tests.el | |||
| @@ -19,26 +19,10 @@ | |||
| 19 | ;; You should have received a copy of the GNU General Public License | 19 | ;; You should have received a copy of the GNU General Public License |
| 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. |
| 21 | 21 | ||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; Most of these tests will only run in a GUI session, and not with | ||
| 25 | ;; "make check". You must run them manually in an interactive session | ||
| 26 | ;; with, for example, `M-x eval-buffer' followed by `M-x ert'. | ||
| 27 | ;; | ||
| 28 | ;; To run these tests from the command line, try: | ||
| 29 | ;; ./src/emacs -Q -l test/src/image-tests.el -eval "(ert t)" | ||
| 30 | |||
| 31 | ;;; Code: | 22 | ;;; Code: |
| 32 | 23 | ||
| 33 | (require 'ert) | 24 | (require 'ert) |
| 34 | 25 | ||
| 35 | (defmacro image-skip-unless (format) | ||
| 36 | `(skip-unless (and (display-images-p) | ||
| 37 | (image-type-available-p ,format)))) | ||
| 38 | |||
| 39 | |||
| 40 | ;;;; Image data | ||
| 41 | |||
| 42 | (defconst image-tests--images | 26 | (defconst image-tests--images |
| 43 | `((gif . ,(expand-file-name "test/data/image/black.gif" | 27 | `((gif . ,(expand-file-name "test/data/image/black.gif" |
| 44 | source-directory)) | 28 | source-directory)) |
| @@ -55,231 +39,23 @@ | |||
| 55 | (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) | 39 | (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) |
| 56 | (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))))) | 40 | (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))))) |
| 57 | 41 | ||
| 58 | |||
| 59 | ;;;; Load image | ||
| 60 | |||
| 61 | (defmacro image-tests-make-load-image-test (type) | ||
| 62 | `(ert-deftest ,(intern (format "image-tests-load-image/%s" | ||
| 63 | (eval type t))) | ||
| 64 | () | ||
| 65 | (image-skip-unless ,type) | ||
| 66 | (let* ((img (cdr (assq ,type image-tests--images))) | ||
| 67 | (file (if (listp img) | ||
| 68 | (plist-get (cdr img) :file) | ||
| 69 | img))) | ||
| 70 | (find-file file)) | ||
| 71 | (should (equal major-mode 'image-mode)) | ||
| 72 | ;; Cleanup | ||
| 73 | (kill-buffer (current-buffer)))) | ||
| 74 | |||
| 75 | (image-tests-make-load-image-test 'gif) | ||
| 76 | (image-tests-make-load-image-test 'jpeg) | ||
| 77 | (image-tests-make-load-image-test 'pbm) | ||
| 78 | (image-tests-make-load-image-test 'png) | ||
| 79 | (image-tests-make-load-image-test 'svg) | ||
| 80 | (image-tests-make-load-image-test 'tiff) | ||
| 81 | (image-tests-make-load-image-test 'webp) | ||
| 82 | (image-tests-make-load-image-test 'xbm) | ||
| 83 | (image-tests-make-load-image-test 'xpm) | ||
| 84 | |||
| 85 | |||
| 86 | ;;;; image-test-size | ||
| 87 | |||
| 88 | (declare-function image-size "image.c" (spec &optional pixels frame)) | ||
| 89 | |||
| 90 | (ert-deftest image-tests-image-size/gif () | ||
| 91 | (image-skip-unless 'gif) | ||
| 92 | (pcase (image-size (create-image (cdr (assq 'gif image-tests--images)))) | ||
| 93 | (`(,a . ,b) | ||
| 94 | (should (floatp a)) | ||
| 95 | (should (floatp b))))) | ||
| 96 | |||
| 97 | (ert-deftest image-tests-image-size/jpeg () | ||
| 98 | (image-skip-unless 'jpeg) | ||
| 99 | (pcase (image-size (create-image (cdr (assq 'jpeg image-tests--images)))) | ||
| 100 | (`(,a . ,b) | ||
| 101 | (should (floatp a)) | ||
| 102 | (should (floatp b))))) | ||
| 103 | |||
| 104 | (ert-deftest image-tests-image-size/pbm () | ||
| 105 | (image-skip-unless 'pbm) | ||
| 106 | (pcase (image-size (cdr (assq 'pbm image-tests--images))) | ||
| 107 | (`(,a . ,b) | ||
| 108 | (should (floatp a)) | ||
| 109 | (should (floatp b))))) | ||
| 110 | |||
| 111 | (ert-deftest image-tests-image-size/png () | ||
| 112 | (image-skip-unless 'png) | ||
| 113 | (pcase (image-size (cdr (assq 'png image-tests--images))) | ||
| 114 | (`(,a . ,b) | ||
| 115 | (should (floatp a)) | ||
| 116 | (should (floatp b))))) | ||
| 117 | |||
| 118 | (ert-deftest image-tests-image-size/svg () | ||
| 119 | (image-skip-unless 'svg) | ||
| 120 | (pcase (image-size (cdr (assq 'svg image-tests--images))) | ||
| 121 | (`(,a . ,b) | ||
| 122 | (should (floatp a)) | ||
| 123 | (should (floatp b))))) | ||
| 124 | |||
| 125 | (ert-deftest image-tests-image-size/tiff () | ||
| 126 | (image-skip-unless 'tiff) | ||
| 127 | (pcase (image-size (create-image (cdr (assq 'tiff image-tests--images)))) | ||
| 128 | (`(,a . ,b) | ||
| 129 | (should (floatp a)) | ||
| 130 | (should (floatp b))))) | ||
| 131 | |||
| 132 | (ert-deftest image-tests-image-size/webp () | ||
| 133 | (image-skip-unless 'webp) | ||
| 134 | (pcase (image-size (create-image (cdr (assq 'webp image-tests--images)))) | ||
| 135 | (`(,a . ,b) | ||
| 136 | (should (floatp a)) | ||
| 137 | (should (floatp b))))) | ||
| 138 | |||
| 139 | (ert-deftest image-tests-image-size/xbm () | ||
| 140 | (image-skip-unless 'xbm) | ||
| 141 | (pcase (image-size (cdr (assq 'xbm image-tests--images))) | ||
| 142 | (`(,a . ,b) | ||
| 143 | (should (floatp a)) | ||
| 144 | (should (floatp b))))) | ||
| 145 | |||
| 146 | (ert-deftest image-tests-image-size/xpm () | ||
| 147 | (image-skip-unless 'xpm) | ||
| 148 | (pcase (image-size (cdr (assq 'xpm image-tests--images))) | ||
| 149 | (`(,a . ,b) | ||
| 150 | (should (floatp a)) | ||
| 151 | (should (floatp b))))) | ||
| 152 | |||
| 153 | (ert-deftest image-tests-image-size/error-on-invalid-spec () | ||
| 154 | (skip-unless (display-images-p)) | ||
| 155 | (should-error (image-size 'invalid-spec))) | ||
| 156 | |||
| 157 | (ert-deftest image-tests-image-size/error-on-nongraphical-display () | 42 | (ert-deftest image-tests-image-size/error-on-nongraphical-display () |
| 158 | (skip-unless (not (display-images-p))) | 43 | (skip-unless (not (display-images-p))) |
| 159 | (should-error (image-size 'invalid-spec))) | 44 | (should-error (image-size 'invalid-spec))) |
| 160 | 45 | ||
| 161 | |||
| 162 | ;;;; image-mask-p | ||
| 163 | |||
| 164 | (declare-function image-mask-p "image.c" (spec &optional frame)) | ||
| 165 | |||
| 166 | (ert-deftest image-tests-image-mask-p/gif () | ||
| 167 | (image-skip-unless 'gif) | ||
| 168 | (should-not (image-mask-p (create-image | ||
| 169 | (cdr (assq 'gif image-tests--images)))))) | ||
| 170 | |||
| 171 | (ert-deftest image-tests-image-mask-p/jpeg () | ||
| 172 | (image-skip-unless 'jpeg) | ||
| 173 | (should-not (image-mask-p (create-image | ||
| 174 | (cdr (assq 'jpeg image-tests--images)))))) | ||
| 175 | |||
| 176 | (ert-deftest image-tests-image-mask-p/pbm () | ||
| 177 | (image-skip-unless 'pbm) | ||
| 178 | (should-not (image-mask-p (cdr (assq 'pbm image-tests--images))))) | ||
| 179 | |||
| 180 | (ert-deftest image-tests-image-mask-p/png () | ||
| 181 | (image-skip-unless 'png) | ||
| 182 | (should-not (image-mask-p (cdr (assq 'png image-tests--images))))) | ||
| 183 | |||
| 184 | (ert-deftest image-tests-image-mask-p/svg () | ||
| 185 | (image-skip-unless 'svg) | ||
| 186 | (should-not (image-mask-p (cdr (assq 'svg image-tests--images))))) | ||
| 187 | |||
| 188 | (ert-deftest image-tests-image-mask-p/tiff () | ||
| 189 | (image-skip-unless 'tiff) | ||
| 190 | (should-not (image-mask-p (create-image | ||
| 191 | (cdr (assq 'tiff image-tests--images)))))) | ||
| 192 | |||
| 193 | (ert-deftest image-tests-image-mask-p/webp () | ||
| 194 | (image-skip-unless 'webp) | ||
| 195 | (should-not (image-mask-p (create-image | ||
| 196 | (cdr (assq 'webp image-tests--images)))))) | ||
| 197 | |||
| 198 | (ert-deftest image-tests-image-mask-p/xbm () | ||
| 199 | (image-skip-unless 'xbm) | ||
| 200 | (should-not (image-mask-p (cdr (assq 'xbm image-tests--images))))) | ||
| 201 | |||
| 202 | (ert-deftest image-tests-image-mask-p/xpm () | ||
| 203 | (image-skip-unless 'xpm) | ||
| 204 | (should-not (image-mask-p (cdr (assq 'xpm image-tests--images))))) | ||
| 205 | |||
| 206 | (ert-deftest image-tests-image-mask-p/error-on-invalid-spec () | ||
| 207 | (skip-unless (display-images-p)) | ||
| 208 | (should-error (image-mask-p 'invalid-spec))) | ||
| 209 | |||
| 210 | (ert-deftest image-tests-image-mask-p/error-on-nongraphical-display () | 46 | (ert-deftest image-tests-image-mask-p/error-on-nongraphical-display () |
| 211 | (skip-unless (not (display-images-p))) | 47 | (skip-unless (not (display-images-p))) |
| 212 | (should-error (image-mask-p (cdr (assq 'xpm image-tests--images))))) | 48 | (should-error (image-mask-p (cdr (assq 'xpm image-tests--images))))) |
| 213 | 49 | ||
| 214 | |||
| 215 | ;;;; image-metadata | ||
| 216 | |||
| 217 | (declare-function image-metadata "image.c" (spec &optional frame)) | ||
| 218 | |||
| 219 | ;; TODO: These tests could be expanded with files that actually | ||
| 220 | ;; contain metadata. | ||
| 221 | |||
| 222 | (ert-deftest image-tests-image-metadata/gif () | ||
| 223 | (image-skip-unless 'gif) | ||
| 224 | (should (memq 'delay | ||
| 225 | (image-metadata | ||
| 226 | (create-image (cdr (assq 'gif image-tests--images))))))) | ||
| 227 | |||
| 228 | (ert-deftest image-tests-image-metadata/jpeg () | ||
| 229 | (image-skip-unless 'jpeg) | ||
| 230 | (should-not (image-metadata | ||
| 231 | (create-image (cdr (assq 'jpeg image-tests--images)))))) | ||
| 232 | |||
| 233 | (ert-deftest image-tests-image-metadata/pbm () | ||
| 234 | (image-skip-unless 'pbm) | ||
| 235 | (should-not (image-metadata (cdr (assq 'pbm image-tests--images))))) | ||
| 236 | |||
| 237 | (ert-deftest image-tests-image-metadata/png () | ||
| 238 | (image-skip-unless 'png) | ||
| 239 | (should-not (image-metadata (cdr (assq 'png image-tests--images))))) | ||
| 240 | |||
| 241 | (ert-deftest image-tests-image-metadata/svg () | ||
| 242 | (image-skip-unless 'svg) | ||
| 243 | (should-not (image-metadata (cdr (assq 'svg image-tests--images))))) | ||
| 244 | |||
| 245 | (ert-deftest image-tests-image-metadata/tiff () | ||
| 246 | (image-skip-unless 'tiff) | ||
| 247 | (should-not (image-metadata | ||
| 248 | (create-image (cdr (assq 'tiff image-tests--images)))))) | ||
| 249 | |||
| 250 | (ert-deftest image-tests-image-metadata/webp () | ||
| 251 | (image-skip-unless 'webp) | ||
| 252 | (should (memq 'delay | ||
| 253 | (image-metadata | ||
| 254 | (create-image (cdr (assq 'webp image-tests--images))))))) | ||
| 255 | |||
| 256 | (ert-deftest image-tests-image-metadata/xbm () | ||
| 257 | (image-skip-unless 'xbm) | ||
| 258 | (should-not (image-metadata (cdr (assq 'xbm image-tests--images))))) | ||
| 259 | |||
| 260 | (ert-deftest image-tests-image-metadata/xpm () | ||
| 261 | (image-skip-unless 'xpm) | ||
| 262 | (should-not (image-metadata (cdr (assq 'xpm image-tests--images))))) | ||
| 263 | |||
| 264 | (ert-deftest image-tests-image-metadata/nil-on-invalid-spec () | ||
| 265 | (skip-unless (display-images-p)) | ||
| 266 | (should-not (image-metadata 'invalid-spec))) | ||
| 267 | |||
| 268 | (ert-deftest image-tests-image-metadata/error-on-nongraphical-display () | 50 | (ert-deftest image-tests-image-metadata/error-on-nongraphical-display () |
| 269 | (skip-unless (not (display-images-p))) | 51 | (skip-unless (not (display-images-p))) |
| 270 | (should-error (image-metadata (cdr (assq 'xpm image-tests--images))))) | 52 | (should-error (image-metadata (cdr (assq 'xpm image-tests--images))))) |
| 271 | 53 | ||
| 272 | |||
| 273 | ;;;; ImageMagick | ||
| 274 | |||
| 275 | (ert-deftest image-tests-imagemagick-types () | 54 | (ert-deftest image-tests-imagemagick-types () |
| 276 | (skip-unless (fboundp 'imagemagick-types)) | 55 | (skip-unless (fboundp 'imagemagick-types)) |
| 277 | (when (fboundp 'imagemagick-types) | 56 | (when (fboundp 'imagemagick-types) |
| 278 | (should (listp (imagemagick-types))))) | 57 | (should (listp (imagemagick-types))))) |
| 279 | 58 | ||
| 280 | |||
| 281 | ;;;; Initialization | ||
| 282 | |||
| 283 | (ert-deftest image-tests-init-image-library () | 59 | (ert-deftest image-tests-init-image-library () |
| 284 | (skip-unless (fboundp 'init-image-library)) | 60 | (skip-unless (fboundp 'init-image-library)) |
| 285 | (declare-function init-image-library "image.c" (type)) | 61 | (declare-function init-image-library "image.c" (type)) |