diff options
author | Eli Zaretskii <eliz@gnu.org> | 2019-12-09 14:46:43 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2019-12-09 14:46:43 +0200 |
commit | aed9584a0e26abead740805e48dcfecc00bc7ce8 (patch) | |
tree | a74fff1c31649fa7598dd4c5781c97a71cf202a2 /test | |
parent | 51176ee81e8e773d8b6ac06dd153846abee0c0f4 (diff) | |
download | emacs-aed9584a0e26abead740805e48dcfecc00bc7ce8.tar.gz |
Add more tests for face :extend attribute
* test/lisp/faces-tests.el (faces--test-extend-with-themes):
New set of tests for verifying the :extend attribute across
theme loading and unloading, and also via face inheritance.
(Bug#37774)
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/faces-tests.el | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/test/lisp/faces-tests.el b/test/lisp/faces-tests.el index f00c93cedcb..7cba4b26ebe 100644 --- a/test/lisp/faces-tests.el +++ b/test/lisp/faces-tests.el @@ -36,6 +36,26 @@ "" :group 'faces--test) +(defface faces--test-extend + '((t :extend t :background "blue")) + "" + :group 'faces--test) + +(defface faces--test-no-extend + '((t :extend nil :background "blue")) + "" + :group 'faces--test) + +(defface faces--test-inherit-extend + '((t :inherit (faces--test-extend faces--test2) :background "blue")) + "" + :group 'faces--test) + +(defface faces--test-inherit-no-extend + '((t :inherit (faces--test2 faces--test-no-extend) :background "blue")) + "" + :group 'faces--test) + (ert-deftest faces--test-color-at-point () (with-temp-buffer (insert (propertize "STRING" 'face '(faces--test2 faces--test1))) @@ -69,5 +89,133 @@ ;; face IDs to faces. (should (> (face-id 'faces--test1) (face-id 'tooltip)))) +(ert-deftest faces--test-extend () + (should (equal (face-attribute 'faces--test-extend :extend) t)) + (should (equal (face-attribute 'faces--test-no-extend :extend) nil)) + (should (equal (face-attribute 'faces--test1 :extend) 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + ) + +(ert-deftest faces--test-extend-with-themes () + ;; Make sure the diff-mode faces are not defined. + (should-not (featurep 'diff-mode)) + (defface diff-changed-face + '((t :extend t :weight bold)) + "") + (defface diff-added + '((t :background "grey")) + "") + (defface diff-file-header-face + '((t :extend nil :foreground "cyan")) + "") + (should (equal (face-attribute 'diff-changed-face :extend) t)) + (should (equal (face-attribute 'diff-added :extend) 'unspecified)) + (should (equal (face-attribute 'diff-file-header-face :extend) nil)) + (load-theme 'manoj-dark t t) + (load-theme 'tsdh-light t t) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend) t)) + (should (equal (face-attribute 'diff-added :extend) 'unspecified)) + (should (equal (face-attribute 'diff-file-header-face :extend) nil)) + (enable-theme 'manoj-dark) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend) 'unspecified)) ; should be t + (should (equal (face-attribute 'diff-added :extend) t)) + (should (equal (face-attribute 'diff-file-header-face :extend) 'unspecified)) ; should be nil + (defface faces--test-face3 + '((t :inherit diff-added :weight bold)) + "") + (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) + (disable-theme 'manoj-dark) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend) t)) + (should (equal (face-attribute 'diff-added :extend) 'unspecified)) + (should (equal (face-attribute 'diff-file-header-face :extend) nil)) + (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) + (defface diff-indicator-changed + '((t (:weight bold :extend t))) + "") + (enable-theme 'tsdh-light) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend) t)) + (should (equal (face-attribute 'diff-added :extend) t)) + (should (equal (face-attribute 'diff-file-header-face :extend) nil)) + (should (equal (face-attribute 'diff-indicator-changed :extend) 'unspecified)) ; should be t + (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) + (frame-set-background-mode (selected-frame) 'dark) + (should (equal (face-attribute 'faces--test-inherit-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend) t)) + (should (equal (face-attribute 'diff-added :extend) t)) + (should (equal (face-attribute 'diff-file-header-face :extend) nil)) + (should (equal (face-attribute 'diff-indicator-changed :extend) 'unspecified)) ; should be t + (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) + (or noninteractive + (let ((fr (make-frame))) + (should (equal (face-attribute 'faces--test-inherit-extend :extend fr) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-extend :extend fr t) + t)) + (should (equal (face-attribute 'faces--test-inherit-no-extend + :extend fr) + 'unspecified)) + (should (equal (face-attribute 'faces--test-inherit-no-extend + :extend fr t) + nil)) + (should (equal (face-attribute 'diff-changed-face :extend fr) t)) + (should (equal (face-attribute 'diff-added :extend fr) t)) + (should (equal (face-attribute 'diff-file-header-face :extend fr) nil)) + (should (equal (face-attribute 'diff-indicator-changed :extend fr) + 'unspecified)) ; should be t + (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) + )) + (disable-theme 'tsdh-light) + (should (equal (face-attribute 'diff-indicator-changed :extend) t)) + (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) + (or noninteractive + (let ((fr (make-frame))) + (should (equal (face-attribute 'diff-changed-face :extend fr) t)) + (should (equal (face-attribute 'diff-added :extend fr) 'unspecified)) + (should (equal (face-attribute 'diff-file-header-face :extend fr) nil)) + (should (equal (face-attribute 'diff-indicator-changed :extend fr) t)) + (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) + )) + ) + (provide 'faces-tests) ;;; faces-tests.el ends here |