]> code.delx.au - gnu-emacs/blob - test/lisp/faces-tests.el
Merge emacs-25 into master (using imerge)
[gnu-emacs] / test / lisp / faces-tests.el
1 ;;; faces-tests.el --- Tests for faces.el -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
4
5 ;; Author: Artur Malabarba <bruce.connor.am@gmail.com>
6 ;; Keywords:
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Code:
22
23 (require 'ert)
24 (require 'faces)
25
26 (defface faces--test1
27 '((t :background "black" :foreground "black"))
28 "")
29
30 (defface faces--test2
31 '((t :box 1))
32 "")
33
34 (ert-deftest faces--test-color-at-point ()
35 (with-temp-buffer
36 (insert (propertize "STRING" 'face '(faces--test2 faces--test1)))
37 (goto-char (point-min))
38 (should (equal (background-color-at-point) "black"))
39 (should (equal (foreground-color-at-point) "black")))
40 (with-temp-buffer
41 (insert (propertize "STRING" 'face '(:foreground "black" :background "black")))
42 (goto-char (point-min))
43 (should (equal (background-color-at-point) "black"))
44 (should (equal (foreground-color-at-point) "black")))
45 (with-temp-buffer
46 (emacs-lisp-mode)
47 (setq-local font-lock-comment-face 'faces--test1)
48 (setq-local font-lock-constant-face 'faces--test2)
49 (insert ";; `symbol'")
50 (font-lock-fontify-region (point-min) (point-max))
51 (goto-char (point-min))
52 (should (equal (background-color-at-point) "black"))
53 (should (equal (foreground-color-at-point) "black"))
54 (goto-char 6)
55 (should (equal (background-color-at-point) "black"))
56 (should (equal (foreground-color-at-point) "black"))))
57
58 (provide 'faces-tests)
59 ;;; faces-tests.el ends here