diff options
| author | Lars Ingebrigtsen | 2017-04-24 07:56:31 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2017-04-24 07:56:31 +0200 |
| commit | e589018b48f802d69f62ab1e7e266df1c7d8cf68 (patch) | |
| tree | c8d43d00816b84ec692714b3a4a7187651a83247 /test | |
| parent | fe304efa5155cd6a5c20a0731475a0ad6d087c4c (diff) | |
| download | emacs-e589018b48f802d69f62ab1e7e266df1c7d8cf68.tar.gz emacs-e589018b48f802d69f62ab1e7e266df1c7d8cf68.zip | |
Add image sizing tests for an image that's narrow
Diffstat (limited to 'test')
| -rw-r--r-- | test/data/image/blank-100x200.png | bin | 0 -> 423 bytes | |||
| -rw-r--r-- | test/manual/image-size-tests.el | 62 |
2 files changed, 45 insertions, 17 deletions
diff --git a/test/data/image/blank-100x200.png b/test/data/image/blank-100x200.png new file mode 100644 index 00000000000..ad26949e983 --- /dev/null +++ b/test/data/image/blank-100x200.png | |||
| Binary files differ | |||
diff --git a/test/manual/image-size-tests.el b/test/manual/image-size-tests.el index 301352eddb0..577c7658791 100644 --- a/test/manual/image-size-tests.el +++ b/test/manual/image-size-tests.el | |||
| @@ -22,15 +22,21 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | (defmacro im-should (width height &rest props) | 25 | (defmacro im-should (image width height &rest props) |
| 26 | `(unless (im-compare (im-image ,@props) ,width ,height) | 26 | `(let ((im (im-image ,image ,@props))) |
| 27 | (error "%s didn't succeed" ',props))) | 27 | (unless (im-compare im ,width ,height) |
| 28 | (error "%s didn't succeed; size is %s" | ||
| 29 | ',props (image-size im t))))) | ||
| 28 | 30 | ||
| 29 | (defun im-image (&rest props) | 31 | (defun im-image (type &rest props) |
| 30 | (let ((image-scaling-factor 1)) | 32 | (let ((image-scaling-factor 1)) |
| 31 | (apply | 33 | (apply |
| 32 | #'create-image | 34 | #'create-image |
| 33 | (expand-file-name "test/data/image/blank-200x100.png" source-directory) | 35 | (expand-file-name |
| 36 | (if (eq type :w) | ||
| 37 | "test/data/image/blank-200x100.png" | ||
| 38 | "test/data/image/blank-100x200.png") | ||
| 39 | source-directory) | ||
| 34 | 'imagemagick nil props))) | 40 | 'imagemagick nil props))) |
| 35 | 41 | ||
| 36 | (defun im-compare (image width height) | 42 | (defun im-compare (image width height) |
| @@ -41,24 +47,46 @@ | |||
| 41 | (defun image-size-tests () | 47 | (defun image-size-tests () |
| 42 | (unless (imagemagick-types) | 48 | (unless (imagemagick-types) |
| 43 | (error "This only makes sense if ImageMagick is installed")) | 49 | (error "This only makes sense if ImageMagick is installed")) |
| 50 | ;; Test the image that's wider than it is tall. | ||
| 44 | ;; Default sizes. | 51 | ;; Default sizes. |
| 45 | (im-should 200 100) | 52 | (im-should :w 200 100) |
| 46 | ;; Changing one dimension changes the other. | 53 | ;; Changing one dimension changes the other. |
| 47 | (im-should 100 50 :width 100) | 54 | (im-should :w 100 50 :width 100) |
| 48 | (im-should 100 50 :height 50) | 55 | (im-should :w 100 50 :height 50) |
| 49 | ;; The same with :max-width etc. | 56 | ;; The same with :max-width etc. |
| 50 | (im-should 100 50 :max-width 100) | 57 | (im-should :w 100 50 :max-width 100) |
| 51 | (im-should 100 50 :max-height 50) | 58 | (im-should :w 100 50 :max-height 50) |
| 52 | ;; :width wins over :max-width etc | 59 | ;; :width wins over :max-width etc |
| 53 | (im-should 300 150 :width 300 :max-width 100) | 60 | (im-should :w 300 150 :width 300 :max-width 100) |
| 54 | (im-should 400 200 :height 200 :max-height 100) | 61 | (im-should :w 400 200 :height 200 :max-height 100) |
| 55 | ;; Specifying both width and height is fine. | 62 | ;; Specifying both width and height is fine. |
| 56 | (im-should 300 50 :width 300 :height 50) | 63 | (im-should :w 300 50 :width 300 :height 50) |
| 57 | ;; A too-large :max-width (etc) has no effect. | 64 | ;; A too-large :max-width (etc) has no effect. |
| 58 | (im-should 200 100 :max-width 300) | 65 | (im-should :w 200 100 :max-width 300) |
| 59 | (im-should 200 100 :max-height 300) | 66 | (im-should :w 200 100 :max-height 300) |
| 60 | ;; Both max-width/height. | 67 | ;; Both max-width/height. |
| 61 | (im-should 100 50 :max-width 100 :max-height 75) | 68 | (im-should :w 100 50 :max-width 100 :max-height 75) |
| 62 | (im-should 50 25 :max-width 100 :max-height 25)) | 69 | (im-should :w 50 25 :max-width 100 :max-height 25) |
| 70 | |||
| 71 | ;; Test the image that's taller than it is wide. | ||
| 72 | (im-should :h 100 200) | ||
| 73 | ;; Changing one dimension changes the other. | ||
| 74 | (im-should :h 50 100 :width 50) | ||
| 75 | (im-should :h 50 100 :height 100) | ||
| 76 | ;; The same with :max-width etc. | ||
| 77 | (im-should :h 50 100 :max-width 50) | ||
| 78 | (im-should :h 50 100 :max-height 100) | ||
| 79 | ;; :width wins over :max-width etc | ||
| 80 | (im-should :h 300 600 :width 300 :max-width 100) | ||
| 81 | (im-should :h 150 300 :height 300 :max-height 100) | ||
| 82 | ;; Specifying both width and height is fine. | ||
| 83 | (im-should :h 300 50 :width 300 :height 50) | ||
| 84 | ;; A too-large :max-width (etc) has no effect. | ||
| 85 | (im-should :h 100 200 :max-width 300) | ||
| 86 | (im-should :h 100 200 :max-height 300) | ||
| 87 | ;; Both max-width/height. | ||
| 88 | (im-should :h 50 100 :max-width 75 :max-height 100) | ||
| 89 | (im-should :h 25 50 :max-width 25 :max-height 100) | ||
| 90 | ) | ||
| 63 | 91 | ||
| 64 | ;;; image-size-tests.el ends here | 92 | ;;; image-size-tests.el ends here |