[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select 7bbc43e 2/7: Add image sizing tests fo
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select 7bbc43e 2/7: Add image sizing tests for an image that's narrow |
Date: |
Mon, 24 Apr 2017 21:17:11 -0400 (EDT) |
branch: feature/gnus-select
commit 7bbc43ec772be07363ba87a45924e1b7a367da0f
Author: Lars Ingebrigtsen <address@hidden>
Commit: Andrew G Cohen <address@hidden>
Add image sizing tests for an image that's narrow
---
test/data/image/blank-100x200.png | Bin 0 -> 423 bytes
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 0000000..ad26949
Binary files /dev/null and b/test/data/image/blank-100x200.png differ
diff --git a/test/manual/image-size-tests.el b/test/manual/image-size-tests.el
index 301352e..577c765 100644
--- a/test/manual/image-size-tests.el
+++ b/test/manual/image-size-tests.el
@@ -22,15 +22,21 @@
;;; Code:
-(defmacro im-should (width height &rest props)
- `(unless (im-compare (im-image ,@props) ,width ,height)
- (error "%s didn't succeed" ',props)))
+(defmacro im-should (image width height &rest props)
+ `(let ((im (im-image ,image ,@props)))
+ (unless (im-compare im ,width ,height)
+ (error "%s didn't succeed; size is %s"
+ ',props (image-size im t)))))
-(defun im-image (&rest props)
+(defun im-image (type &rest props)
(let ((image-scaling-factor 1))
(apply
#'create-image
- (expand-file-name "test/data/image/blank-200x100.png" source-directory)
+ (expand-file-name
+ (if (eq type :w)
+ "test/data/image/blank-200x100.png"
+ "test/data/image/blank-100x200.png")
+ source-directory)
'imagemagick nil props)))
(defun im-compare (image width height)
@@ -41,24 +47,46 @@
(defun image-size-tests ()
(unless (imagemagick-types)
(error "This only makes sense if ImageMagick is installed"))
+ ;; Test the image that's wider than it is tall.
;; Default sizes.
- (im-should 200 100)
+ (im-should :w 200 100)
;; Changing one dimension changes the other.
- (im-should 100 50 :width 100)
- (im-should 100 50 :height 50)
+ (im-should :w 100 50 :width 100)
+ (im-should :w 100 50 :height 50)
;; The same with :max-width etc.
- (im-should 100 50 :max-width 100)
- (im-should 100 50 :max-height 50)
+ (im-should :w 100 50 :max-width 100)
+ (im-should :w 100 50 :max-height 50)
;; :width wins over :max-width etc
- (im-should 300 150 :width 300 :max-width 100)
- (im-should 400 200 :height 200 :max-height 100)
+ (im-should :w 300 150 :width 300 :max-width 100)
+ (im-should :w 400 200 :height 200 :max-height 100)
;; Specifying both width and height is fine.
- (im-should 300 50 :width 300 :height 50)
+ (im-should :w 300 50 :width 300 :height 50)
;; A too-large :max-width (etc) has no effect.
- (im-should 200 100 :max-width 300)
- (im-should 200 100 :max-height 300)
+ (im-should :w 200 100 :max-width 300)
+ (im-should :w 200 100 :max-height 300)
;; Both max-width/height.
- (im-should 100 50 :max-width 100 :max-height 75)
- (im-should 50 25 :max-width 100 :max-height 25))
+ (im-should :w 100 50 :max-width 100 :max-height 75)
+ (im-should :w 50 25 :max-width 100 :max-height 25)
+
+ ;; Test the image that's taller than it is wide.
+ (im-should :h 100 200)
+ ;; Changing one dimension changes the other.
+ (im-should :h 50 100 :width 50)
+ (im-should :h 50 100 :height 100)
+ ;; The same with :max-width etc.
+ (im-should :h 50 100 :max-width 50)
+ (im-should :h 50 100 :max-height 100)
+ ;; :width wins over :max-width etc
+ (im-should :h 300 600 :width 300 :max-width 100)
+ (im-should :h 150 300 :height 300 :max-height 100)
+ ;; Specifying both width and height is fine.
+ (im-should :h 300 50 :width 300 :height 50)
+ ;; A too-large :max-width (etc) has no effect.
+ (im-should :h 100 200 :max-width 300)
+ (im-should :h 100 200 :max-height 300)
+ ;; Both max-width/height.
+ (im-should :h 50 100 :max-width 75 :max-height 100)
+ (im-should :h 25 50 :max-width 25 :max-height 100)
+ )
;;; image-size-tests.el ends here
- [Emacs-diffs] feature/gnus-select updated (6ff9a4f -> e7fd724), Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 66d1ec0 6/7: Remove s_client usage from tls.el, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select bcf49f6 5/7: Further robustify cedet bootstrap to loaddefs not yet built, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select e528a75 4/7: Fix XBM colour rendering in NS port (bug#22060), Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 5d21c62 3/7: Add support for IRCv3 message tags., Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select e7fd724 7/7: Don't advertise s_client in tls.el docs, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select ec5a249 1/7: Needlessly refactor tests for clarity, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 7bbc43e 2/7: Add image sizing tests for an image that's narrow,
Andrew G Cohen <=