[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/popup 72c6e4d 027/184: Port some test cases from popup-int
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/popup 72c6e4d 027/184: Port some test cases from popup-interactive-test.el |
Date: |
Wed, 6 Oct 2021 00:01:00 -0400 (EDT) |
branch: elpa/popup
commit 72c6e4d84a6cb786b18ecaeb61445d5bab71d88e
Author: yuuki arisawa <yuuki.ari@gmail.com>
Commit: yuuki arisawa <yuuki.ari@gmail.com>
Port some test cases from popup-interactive-test.el
- delete
- hide
- tip
---
tests/popup-test.el | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
diff --git a/tests/popup-test.el b/tests/popup-test.el
index e51e01f..37ccd07 100644
--- a/tests/popup-test.el
+++ b/tests/popup-test.el
@@ -1,18 +1,111 @@
(require 'ert)
(require 'popup)
+;; for "every" function
+(require 'cl)
+
(defmacro popup-test-with-common-setup (&rest body)
(declare (indent 0) (debug t))
`(save-excursion
(with-temp-buffer
+ (switch-to-buffer (current-buffer))
(erase-buffer)
(let ((popup (popup-create (point) 10 10)))
,@body
(popup-delete popup)))))
+(defun popup-test-helper-overlays-to-text ()
+ "Create a new buffer called *text* containing the visible text
+of the current buffer, ie. it converts overlays containing text
+into real text."
+ (interactive)
+ (let ((tb (get-buffer-create "*text*"))
+ (s (point-min))
+ (os (overlays-in (point-min) (point-max))))
+ (with-current-buffer tb
+ (erase-buffer))
+ (setq os (sort os (lambda (o1 o2)
+ (< (overlay-start o1)
+ (overlay-start o2)))))
+ (mapc (lambda (o)
+ (let ((bt (buffer-substring-no-properties s (overlay-start o)))
+ (b (overlay-get o 'before-string))
+ (text (or (overlay-get o 'display)
+ (buffer-substring-no-properties (overlay-start o)
(overlay-end o))))
+ (a (overlay-get o 'after-string))
+ (inv (overlay-get o 'invisible)))
+ (with-current-buffer tb
+ (insert bt)
+ (unless inv
+ (when b (insert b))
+ (insert text)
+ (when a (insert a))))
+ (setq s (overlay-end o))))
+ os)
+ (let ((x (buffer-substring-no-properties s (point-max))))
+ (with-current-buffer tb
+ (insert x)
+ (buffer-string)))))
+
+(defun popup-test-helper-match-contents (contents)
+ (if (listp contents)
+ (mapcar (lambda (content)
+ (string-match content
+ (popup-test-helper-overlays-to-text)))
+ contents)))
+
+(defun popup-test-helper-input (key)
+ (push key unread-command-events))
+
(ert-deftest popup-test-simple ()
(popup-test-with-common-setup
(popup-set-list popup '("foo" "bar" "baz"))
(popup-draw popup)
- (should (equal (popup-list popup) '("foo" "bar" "baz")))))
+ (should (equal (popup-list popup) '("foo" "bar" "baz")))
+ (should (every #'identity
+ (popup-test-helper-match-contents '("foo" "bar" "baz"))))
+ ))
+
+(ert-deftest popup-test-delete ()
+ (popup-test-with-common-setup
+ (popup-delete popup)
+ (should-not (popup-live-p popup))))
+
+(ert-deftest popup-test-hide ()
+ (popup-test-with-common-setup
+ (popup-set-list popup '("foo" "bar" "baz"))
+ (popup-draw popup)
+ (popup-hide popup)
+ (should (equal (popup-list popup) '("foo" "bar" "baz")))
+ (should-not (every #'identity
+ (popup-test-helper-match-contents '("foo" "bar"
"baz"))))
+ ))
+
+(ert-deftest popup-test-tip ()
+ (popup-test-with-common-setup
+ (popup-tip
+ "Start isearch on POPUP. This function is synchronized, meaning
+event loop waits for quiting of isearch.
+
+CURSOR-COLOR is a cursor color during isearch. The default value
+is `popup-isearch-cursor-color'.
+
+KEYMAP is a keymap which is used when processing events during
+event loop. The default value is `popup-isearch-keymap'.
+
+CALLBACK is a function taking one argument. `popup-isearch' calls
+CALLBACK, if specified, after isearch finished or isearch
+canceled. The arguments is whole filtered list of items.
+
+HELP-DELAY is a delay of displaying helps."
+ :nowait t)
+ ;; (should (equal (popup-list popup) '("foo" "bar" "baz")))
+ (should
+ (every #'identity
+ (popup-test-helper-match-contents
+ '("CURSOR-COLOR is a cursor color during isearch"))))
+ ))
+
+
+
- [nongnu] elpa/popup 098170f 006/184: Added :always option for :scroll-bar argument., (continued)
- [nongnu] elpa/popup 098170f 006/184: Added :always option for :scroll-bar argument., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 2cad059 015/184: Initial commit, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 03b23bf 017/184: Merge branch 'master' of github.com:m2ym/popup-el, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup c85ccd3 013/184: Use inhibit-read-only instead of buffer-read-only, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 2609811 022/184: Add Travis CI configuration, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup e76230b 059/184: Add summary-face keyword argument to popup-set-line-item, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup ab23548 031/184: Change popup-test-helper-overlays-to-text spec and function name to return overlays buffer., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 498cb64 061/184: Define popup-summary-face, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 54ed4bd 048/184: Add test case:popup-next, popup-previous, popup-select, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup fd8a372 039/184: Remove unused code., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 72c6e4d 027/184: Port some test cases from popup-interactive-test.el,
ELPA Syncer <=
- [nongnu] elpa/popup 180516e 079/184: Use cl-lib functions instead of cl, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 28cb27c 074/184: Add next/previous page commands., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 7fda072 042/184: Add check for row position., ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 2593e06 071/184: Add test for #18, #19, #20, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 48b0fa4 020/184: Add a simple test using ERT, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup e208b13 035/184: Setup for batch mode, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 9814c88 038/184: Add test for test helper, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 581f35b 062/184: Define popup-menu-summary-face, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup 4e19acb 036/184: Remove dependency on auto-complete, ELPA Syncer, 2021/10/06
- [nongnu] elpa/popup bec50cc 076/184: Merge pull request #41 from kostafey/master, ELPA Syncer, 2021/10/06