From a81a187de9f4aa9f208bfe6931d577733b6f6f0c Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sun, 23 Oct 2022 15:11:56 +0800 Subject: [PATCH 2/2] test-org-fold.el: Add test for inline image displaying when cycling * testing/lisp/test-org-fold.el (test-org-fold/org-fold-display-inline-images): Add unit test for inline image displaying when cycling. --- testing/lisp/test-org-fold.el | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index 8b19ffbc9..664be4551 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -662,6 +662,67 @@ Unfolded Paragraph. (org-fold-check-before-invisible-edit kind) (should (org-invisible-p (1- (point)))))))))) +(ert-deftest test-org-fold/org-fold-display-inline-images () + "Test inline images displaying when cycling." + (let* ((org-cycle-inline-images-display t) + (images-dir (expand-file-name "examples/images/" org-test-dir)) + (org-logo-image (expand-file-name "Org mode logo mono-color.png" images-dir))) + ;; `org-cycle' -(state)-> `'children' display child inline images. + (org-test-with-temp-text + (format "* Heading 1 +[[file:%s]] +" org-logo-image) + (org-overview) + ;; (org-cycle) + ;; (org-cycle-internal-local) + ;; (org-cycle-display-inline-images 'children) + (org-fold-show-children) + (run-hook-with-args 'org-cycle-hook 'children) + (org-next-link) + (should org-inline-image-overlays) + (should (overlays-at (point))) + (org-toggle-inline-images) + (should-not (overlays-at (point)))) + + ;; `org-cycle' -(state)-> `'subtree' display subtrees inline images. + (org-test-with-temp-text + (format "* Heading 1 +[[file:%s]] +** Subheading 1 +[[file:%s]] +** Subheading 2 +[[file:%s]]" org-logo-image org-logo-image org-logo-image) + (org-overview) + ;; (org-cycle) + ;; (org-cycle) + ;; (org-cycle-internal-global) + (org-fold-show-subtree) + (run-hook-with-args 'org-cycle-hook 'subtree) + (org-next-link) + (org-next-link) + ;; (should org-inline-image-overlays) + (should (overlays-at (point))) + (org-toggle-inline-images) + (should-not (overlays-at (point)))) + + ;; `org-cycle' -(state)-> `'folded' remove inline image overlays. + (org-test-with-temp-text + (format "* Heading 1 +[[file:%s]] +** Subheading 1 +[[file:%s]] +** Subheading 2 +[[file:%s]]" org-logo-image org-logo-image org-logo-image) + (org-overview) + (org-show-subtree) + (org-fold-subtree t) + (run-hook-with-args 'org-cycle-hook 'folded) + (should (null org-inline-image-overlays)) + (should (null (overlays-in (point-min) (point-max)))) + (org-show-subtree) + (should-not org-inline-image-overlays) + (should-not (overlays-in (point-min) (point-max)))))) + (provide 'test-org-fold) ;;; test-org-fold.el ends here -- 2.38.0