diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/font-parse-testsuite.el | 135 |
2 files changed, 139 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 7b0de7e9e1e..b03e372b8b9 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-01-26 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * font-parse-testsuite.el (test-font-parse-data): New file. | ||
| 4 | |||
| 1 | 2011-01-13 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2011-01-13 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 6 | ||
| 3 | * indent/prolog.prolog: Add tokenizing tests. | 7 | * indent/prolog.prolog: Add tokenizing tests. |
diff --git a/test/font-parse-testsuite.el b/test/font-parse-testsuite.el new file mode 100644 index 00000000000..02923159e83 --- /dev/null +++ b/test/font-parse-testsuite.el | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | ;;; redisplay-testsuite.el --- Test suite for redisplay. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Chong Yidong <cyd@stupidchicken.com> | ||
| 6 | ;; Keywords: internal | ||
| 7 | ;; Human-Keywords: internal | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Commentary: | ||
| 25 | |||
| 26 | ;; Type M-x test-font-parse RET to generate the test buffer. | ||
| 27 | |||
| 28 | ;; TODO: Convert to ERT format. | ||
| 29 | |||
| 30 | ;;; Code: | ||
| 31 | |||
| 32 | (defvar test-font-parse-data | ||
| 33 | '((" " " " nil nil nil nil) | ||
| 34 | ("Monospace" "Monospace" nil nil nil nil) | ||
| 35 | ("Foo1" "Foo1" nil nil nil nil) | ||
| 36 | ("12" "nil" 12.0 nil nil nil) | ||
| 37 | ("12 " "12 " nil nil nil nil) | ||
| 38 | ;; Fontconfig format | ||
| 39 | ("Foo:" "Foo" nil nil nil nil) | ||
| 40 | ("Foo-8" "Foo" 8.0 nil nil nil) | ||
| 41 | ("Foo-18:" "Foo" 18.0 nil nil nil) | ||
| 42 | ("Foo-18:light" "Foo" 18.0 light nil nil) | ||
| 43 | ("Foo 10:weight=bold" "Foo 10" nil bold nil nil) | ||
| 44 | ("Foo-12:weight=bold" "Foo" 12.0 bold nil nil) | ||
| 45 | ("Foo 8-20:slant=oblique" "Foo 8" 20.0 nil oblique nil) | ||
| 46 | ("Foo:light:roman" "Foo" nil light roman nil) | ||
| 47 | ("Foo:italic:roman" "Foo" nil nil roman nil) | ||
| 48 | ("Foo 12:light:oblique" "Foo 12" nil light oblique nil) | ||
| 49 | ("Foo-12:demibold:oblique" "Foo" 12.0 demibold oblique nil) | ||
| 50 | ("Foo:black:proportional" "Foo" nil black nil 0) | ||
| 51 | ("Foo-10:black:proportional" "Foo" 10.0 black nil 0) | ||
| 52 | ("Foo:weight=normal" "Foo" nil normal nil nil) | ||
| 53 | ("Foo:weight=bold" "Foo" nil bold nil nil) | ||
| 54 | ("Foo:weight=bold:slant=italic" "Foo" nil bold italic) | ||
| 55 | ("Foo:weight=bold:slant=italic:mono" "Foo" nil bold italic 100) | ||
| 56 | ("Foo-10:demibold:slant=normal" "Foo" 10.0 demibold normal nil) | ||
| 57 | ("Foo 11-16:oblique:weight=bold" "Foo 11" 16.0 bold oblique nil) | ||
| 58 | ("Foo:oblique:randomprop=randomtag:weight=bold" | ||
| 59 | "Foo" nil bold oblique nil) | ||
| 60 | ("Foo:randomprop=randomtag:bar=baz" "Foo" nil nil nil nil) | ||
| 61 | ("Foo Book Light:bar=baz" "Foo Book Light" nil nil nil nil) | ||
| 62 | ("Foo Book Light 10:bar=baz" "Foo Book Light 10" nil nil nil nil) | ||
| 63 | ("Foo Book Light-10:bar=baz" "Foo Book Light" 10.0 nil nil nil) | ||
| 64 | ;; GTK format | ||
| 65 | ("Oblique" "nil" nil nil oblique nil) | ||
| 66 | ("Bold 17" "nil" 17.0 bold nil nil) | ||
| 67 | ("17 Bold" "17" nil bold nil nil) | ||
| 68 | ("Book Oblique 2" "nil" 2.0 book oblique nil) | ||
| 69 | ("Bar 7" "Bar" 7.0 nil nil nil) | ||
| 70 | ("Bar Ultra-Light" "Bar" nil ultra-light nil nil) | ||
| 71 | ("Bar Light 8" "Bar" 8.0 light nil nil) | ||
| 72 | ("Bar Book Medium 9" "Bar" 9.0 medium nil nil) | ||
| 73 | ("Bar Semi-Bold Italic 10" "Bar" 10.0 semi-bold italic nil) | ||
| 74 | ("Bar Semi-Condensed Bold Italic 11" "Bar" 11.0 bold italic nil) | ||
| 75 | ("Foo 10 11" "Foo 10" 11.0 nil nil nil) | ||
| 76 | ("Foo 1985 Book" "Foo 1985" nil book nil nil) | ||
| 77 | ("Foo 1985 A Book" "Foo 1985 A" nil book nil nil) | ||
| 78 | ("Foo A Book 12 A" "Foo A Book 12 A" nil nil nil nil) | ||
| 79 | ("Foo 1985 Book 12 Oblique" "Foo 1985 Book 12" nil nil oblique nil) | ||
| 80 | ("Foo 1985 Book 12 Italic 10" "Foo 1985 Book 12" 10.0 nil italic nil) | ||
| 81 | ("Foo Book Bar 6 Italic" "Foo Book Bar 6" nil nil italic nil) | ||
| 82 | ("Foo Book Bar Bold" "Foo Book Bar" nil bold nil nil)) | ||
| 83 | "List of font names parse data. | ||
| 84 | Each element should have the form | ||
| 85 | (NAME FAMILY SIZE WEIGHT SLANT SPACING) | ||
| 86 | where NAME is the name to parse, and the remainder are the | ||
| 87 | expected font properties from parsing NAME.") | ||
| 88 | |||
| 89 | (defun test-font-parse () | ||
| 90 | "Test font name parsing." | ||
| 91 | (interactive) | ||
| 92 | (switch-to-buffer (generate-new-buffer "*Font Pase Test*")) | ||
| 93 | (setq show-trailing-whitespace nil) | ||
| 94 | (let ((pass-face '((t :foreground "green"))) | ||
| 95 | (fail-face '((t :foreground "red")))) | ||
| 96 | (dolist (test test-font-parse-data) | ||
| 97 | (let* ((name (nth 0 test)) | ||
| 98 | (fs (font-spec :name name)) | ||
| 99 | (family (symbol-name (font-get fs :family))) | ||
| 100 | (size (font-get fs :size)) | ||
| 101 | (weight (font-get fs :weight)) | ||
| 102 | (slant (font-get fs :slant)) | ||
| 103 | (spacing (font-get fs :spacing))) | ||
| 104 | (insert name) | ||
| 105 | (if (> (current-column) 20) | ||
| 106 | (insert "\n")) | ||
| 107 | (indent-to-column 21) | ||
| 108 | (insert (propertize family | ||
| 109 | 'face (if (equal family (nth 1 test)) | ||
| 110 | pass-face | ||
| 111 | fail-face))) | ||
| 112 | (indent-to-column 40) | ||
| 113 | (insert (propertize (format "%s" size) | ||
| 114 | 'face (if (equal size (nth 2 test)) | ||
| 115 | pass-face | ||
| 116 | fail-face))) | ||
| 117 | (indent-to-column 48) | ||
| 118 | (insert (propertize (format "%s" weight) | ||
| 119 | 'face (if (eq weight (nth 3 test)) | ||
| 120 | pass-face | ||
| 121 | fail-face))) | ||
| 122 | (indent-to-column 60) | ||
| 123 | (insert (propertize (format "%s" slant) | ||
| 124 | 'face (if (eq slant (nth 4 test)) | ||
| 125 | pass-face | ||
| 126 | fail-face))) | ||
| 127 | (indent-to-column 69) | ||
| 128 | (insert (propertize (format "%s" spacing) | ||
| 129 | 'face (if (eq spacing (nth 5 test)) | ||
| 130 | pass-face | ||
| 131 | fail-face))) | ||
| 132 | (insert "\n")))) | ||
| 133 | (goto-char (point-min))) | ||
| 134 | |||
| 135 | ;;; font-parse-testsuite.el ends here. | ||