aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Kangas2022-09-08 02:35:37 +0200
committerStefan Kangas2022-09-08 02:35:37 +0200
commit5b87429d99bf99c0adde371a5ecfd2c745fc3489 (patch)
treec56a71531c040404b41e205fe13f38f398600002 /test/src
parentffe50d41d98cf05622288b33cd014be18319dce0 (diff)
downloademacs-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>.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/image-tests.el224
1 files changed, 0 insertions, 224 deletions
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))