diff options
| author | Eli Zaretskii | 2019-12-09 14:46:43 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-12-09 14:46:43 +0200 |
| commit | aed9584a0e26abead740805e48dcfecc00bc7ce8 (patch) | |
| tree | a74fff1c31649fa7598dd4c5781c97a71cf202a2 | |
| parent | 51176ee81e8e773d8b6ac06dd153846abee0c0f4 (diff) | |
| download | emacs-aed9584a0e26abead740805e48dcfecc00bc7ce8.tar.gz emacs-aed9584a0e26abead740805e48dcfecc00bc7ce8.zip | |
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)
| -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 @@ | |||
| 36 | "" | 36 | "" |
| 37 | :group 'faces--test) | 37 | :group 'faces--test) |
| 38 | 38 | ||
| 39 | (defface faces--test-extend | ||
| 40 | '((t :extend t :background "blue")) | ||
| 41 | "" | ||
| 42 | :group 'faces--test) | ||
| 43 | |||
| 44 | (defface faces--test-no-extend | ||
| 45 | '((t :extend nil :background "blue")) | ||
| 46 | "" | ||
| 47 | :group 'faces--test) | ||
| 48 | |||
| 49 | (defface faces--test-inherit-extend | ||
| 50 | '((t :inherit (faces--test-extend faces--test2) :background "blue")) | ||
| 51 | "" | ||
| 52 | :group 'faces--test) | ||
| 53 | |||
| 54 | (defface faces--test-inherit-no-extend | ||
| 55 | '((t :inherit (faces--test2 faces--test-no-extend) :background "blue")) | ||
| 56 | "" | ||
| 57 | :group 'faces--test) | ||
| 58 | |||
| 39 | (ert-deftest faces--test-color-at-point () | 59 | (ert-deftest faces--test-color-at-point () |
| 40 | (with-temp-buffer | 60 | (with-temp-buffer |
| 41 | (insert (propertize "STRING" 'face '(faces--test2 faces--test1))) | 61 | (insert (propertize "STRING" 'face '(faces--test2 faces--test1))) |
| @@ -69,5 +89,133 @@ | |||
| 69 | ;; face IDs to faces. | 89 | ;; face IDs to faces. |
| 70 | (should (> (face-id 'faces--test1) (face-id 'tooltip)))) | 90 | (should (> (face-id 'faces--test1) (face-id 'tooltip)))) |
| 71 | 91 | ||
| 92 | (ert-deftest faces--test-extend () | ||
| 93 | (should (equal (face-attribute 'faces--test-extend :extend) t)) | ||
| 94 | (should (equal (face-attribute 'faces--test-no-extend :extend) nil)) | ||
| 95 | (should (equal (face-attribute 'faces--test1 :extend) 'unspecified)) | ||
| 96 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 97 | 'unspecified)) | ||
| 98 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 99 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 100 | 'unspecified)) | ||
| 101 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 102 | nil)) | ||
| 103 | ) | ||
| 104 | |||
| 105 | (ert-deftest faces--test-extend-with-themes () | ||
| 106 | ;; Make sure the diff-mode faces are not defined. | ||
| 107 | (should-not (featurep 'diff-mode)) | ||
| 108 | (defface diff-changed-face | ||
| 109 | '((t :extend t :weight bold)) | ||
| 110 | "") | ||
| 111 | (defface diff-added | ||
| 112 | '((t :background "grey")) | ||
| 113 | "") | ||
| 114 | (defface diff-file-header-face | ||
| 115 | '((t :extend nil :foreground "cyan")) | ||
| 116 | "") | ||
| 117 | (should (equal (face-attribute 'diff-changed-face :extend) t)) | ||
| 118 | (should (equal (face-attribute 'diff-added :extend) 'unspecified)) | ||
| 119 | (should (equal (face-attribute 'diff-file-header-face :extend) nil)) | ||
| 120 | (load-theme 'manoj-dark t t) | ||
| 121 | (load-theme 'tsdh-light t t) | ||
| 122 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 123 | 'unspecified)) | ||
| 124 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 125 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 126 | 'unspecified)) | ||
| 127 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 128 | nil)) | ||
| 129 | (should (equal (face-attribute 'diff-changed-face :extend) t)) | ||
| 130 | (should (equal (face-attribute 'diff-added :extend) 'unspecified)) | ||
| 131 | (should (equal (face-attribute 'diff-file-header-face :extend) nil)) | ||
| 132 | (enable-theme 'manoj-dark) | ||
| 133 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 134 | 'unspecified)) | ||
| 135 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 136 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 137 | 'unspecified)) | ||
| 138 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 139 | nil)) | ||
| 140 | (should (equal (face-attribute 'diff-changed-face :extend) 'unspecified)) ; should be t | ||
| 141 | (should (equal (face-attribute 'diff-added :extend) t)) | ||
| 142 | (should (equal (face-attribute 'diff-file-header-face :extend) 'unspecified)) ; should be nil | ||
| 143 | (defface faces--test-face3 | ||
| 144 | '((t :inherit diff-added :weight bold)) | ||
| 145 | "") | ||
| 146 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) | ||
| 147 | (disable-theme 'manoj-dark) | ||
| 148 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 149 | 'unspecified)) | ||
| 150 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 151 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 152 | 'unspecified)) | ||
| 153 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 154 | nil)) | ||
| 155 | (should (equal (face-attribute 'diff-changed-face :extend) t)) | ||
| 156 | (should (equal (face-attribute 'diff-added :extend) 'unspecified)) | ||
| 157 | (should (equal (face-attribute 'diff-file-header-face :extend) nil)) | ||
| 158 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) | ||
| 159 | (defface diff-indicator-changed | ||
| 160 | '((t (:weight bold :extend t))) | ||
| 161 | "") | ||
| 162 | (enable-theme 'tsdh-light) | ||
| 163 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 164 | 'unspecified)) | ||
| 165 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 166 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 167 | 'unspecified)) | ||
| 168 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 169 | nil)) | ||
| 170 | (should (equal (face-attribute 'diff-changed-face :extend) t)) | ||
| 171 | (should (equal (face-attribute 'diff-added :extend) t)) | ||
| 172 | (should (equal (face-attribute 'diff-file-header-face :extend) nil)) | ||
| 173 | (should (equal (face-attribute 'diff-indicator-changed :extend) 'unspecified)) ; should be t | ||
| 174 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) | ||
| 175 | (frame-set-background-mode (selected-frame) 'dark) | ||
| 176 | (should (equal (face-attribute 'faces--test-inherit-extend :extend) | ||
| 177 | 'unspecified)) | ||
| 178 | (should (equal (face-attribute 'faces--test-inherit-extend :extend nil t) t)) | ||
| 179 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend) | ||
| 180 | 'unspecified)) | ||
| 181 | (should (equal (face-attribute 'faces--test-inherit-no-extend :extend nil t) | ||
| 182 | nil)) | ||
| 183 | (should (equal (face-attribute 'diff-changed-face :extend) t)) | ||
| 184 | (should (equal (face-attribute 'diff-added :extend) t)) | ||
| 185 | (should (equal (face-attribute 'diff-file-header-face :extend) nil)) | ||
| 186 | (should (equal (face-attribute 'diff-indicator-changed :extend) 'unspecified)) ; should be t | ||
| 187 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) | ||
| 188 | (or noninteractive | ||
| 189 | (let ((fr (make-frame))) | ||
| 190 | (should (equal (face-attribute 'faces--test-inherit-extend :extend fr) | ||
| 191 | 'unspecified)) | ||
| 192 | (should (equal (face-attribute 'faces--test-inherit-extend :extend fr t) | ||
| 193 | t)) | ||
| 194 | (should (equal (face-attribute 'faces--test-inherit-no-extend | ||
| 195 | :extend fr) | ||
| 196 | 'unspecified)) | ||
| 197 | (should (equal (face-attribute 'faces--test-inherit-no-extend | ||
| 198 | :extend fr t) | ||
| 199 | nil)) | ||
| 200 | (should (equal (face-attribute 'diff-changed-face :extend fr) t)) | ||
| 201 | (should (equal (face-attribute 'diff-added :extend fr) t)) | ||
| 202 | (should (equal (face-attribute 'diff-file-header-face :extend fr) nil)) | ||
| 203 | (should (equal (face-attribute 'diff-indicator-changed :extend fr) | ||
| 204 | 'unspecified)) ; should be t | ||
| 205 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) t)) | ||
| 206 | )) | ||
| 207 | (disable-theme 'tsdh-light) | ||
| 208 | (should (equal (face-attribute 'diff-indicator-changed :extend) t)) | ||
| 209 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) | ||
| 210 | (or noninteractive | ||
| 211 | (let ((fr (make-frame))) | ||
| 212 | (should (equal (face-attribute 'diff-changed-face :extend fr) t)) | ||
| 213 | (should (equal (face-attribute 'diff-added :extend fr) 'unspecified)) | ||
| 214 | (should (equal (face-attribute 'diff-file-header-face :extend fr) nil)) | ||
| 215 | (should (equal (face-attribute 'diff-indicator-changed :extend fr) t)) | ||
| 216 | (should (equal (face-attribute 'faces--test-face3 :extend nil t) 'unspecified)) | ||
| 217 | )) | ||
| 218 | ) | ||
| 219 | |||
| 72 | (provide 'faces-tests) | 220 | (provide 'faces-tests) |
| 73 | ;;; faces-tests.el ends here | 221 | ;;; faces-tests.el ends here |