74 lines
3.0 KiB
EmacsLisp
74 lines
3.0 KiB
EmacsLisp
;;; ebox-display-tests.el --- Display integration tests -*- lexical-binding: t; -*-
|
|
|
|
;;; Code:
|
|
|
|
(require 'ert)
|
|
(require 'ebox)
|
|
|
|
(ert-deftest ebox-display-invalid-input-preserves-windows ()
|
|
"Invalid input must fail before changing the caller's window layout."
|
|
(save-window-excursion
|
|
(split-window-right)
|
|
(let ((before (current-window-configuration))
|
|
(buffer (generate-new-buffer " *ebox-invalid-display*")))
|
|
(unwind-protect
|
|
(progn
|
|
(should-error (ebox-display-buffer buffer 'invalid-input))
|
|
(should (compare-window-configurations
|
|
before (current-window-configuration))))
|
|
(kill-buffer buffer)))))
|
|
|
|
(ert-deftest ebox-display-honors-native-display-action ()
|
|
"The caller chooses the display window without changing selection."
|
|
(save-window-excursion
|
|
(let* ((selected (selected-window))
|
|
(other (split-window-right))
|
|
(buffer (generate-new-buffer " *ebox-display-action*"))
|
|
(input (ebox-build '(box "Ready"))))
|
|
(unwind-protect
|
|
(progn
|
|
(should
|
|
(eq buffer
|
|
(ebox-display-buffer
|
|
buffer input
|
|
(list (lambda (target alist)
|
|
(let ((window (alist-get 'window alist)))
|
|
(set-window-buffer window target)
|
|
window))
|
|
(cons 'window other)))))
|
|
(should (eq selected (selected-window)))
|
|
(should (= 2 (length (window-list))))
|
|
(should (eq buffer (window-buffer other)))
|
|
(with-current-buffer buffer
|
|
(should (string-match-p "Ready" (buffer-string)))
|
|
(should ebox-buffer-mode)))
|
|
(kill-buffer buffer)))))
|
|
|
|
(ert-deftest ebox-display-honors-display-buffer-alist ()
|
|
"Native display rules also apply when no explicit action is supplied."
|
|
(let ((buffer (generate-new-buffer " *ebox-display-rule*")) called)
|
|
(unwind-protect
|
|
(let ((display-buffer-alist
|
|
(list (list (regexp-quote (buffer-name buffer))
|
|
(lambda (target _action)
|
|
(setq called target)
|
|
(selected-window))))))
|
|
(should (eq buffer (ebox-display-buffer buffer (ebox-build "Ready"))))
|
|
(should (eq buffer called)))
|
|
(kill-buffer buffer))))
|
|
|
|
(ert-deftest ebox-display-delivers-the-target-viewport-intent ()
|
|
"A newly displayed buffer uses the ordinary deferred viewport bridge."
|
|
(let ((buffer (generate-new-buffer " *ebox-display-viewport*")) frame)
|
|
(unwind-protect
|
|
(cl-letf (((symbol-function 'display-buffer)
|
|
(lambda (_buffer _action) (selected-window)))
|
|
((symbol-function 'ebox--window-size-change)
|
|
(lambda (target) (setq frame target))))
|
|
(ebox-display-buffer buffer (ebox-build "Ready"))
|
|
(should (eq frame (selected-frame))))
|
|
(kill-buffer buffer))))
|
|
|
|
(provide 'ebox-display-tests)
|
|
;;; ebox-display-tests.el ends here
|