aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2016-03-20 13:41:59 +0100
committerLars Magne Ingebrigtsen2016-03-20 13:41:59 +0100
commit21c89971c31d8f5c14814d2a18749495ed191d8f (patch)
treeac12bfd5940556d0f44ffa9634bf0058b961e2e2
parent4f9c775700d250d8626ce679a1fdd6da58a9fa11 (diff)
downloademacs-21c89971c31d8f5c14814d2a18749495ed191d8f.tar.gz
emacs-21c89971c31d8f5c14814d2a18749495ed191d8f.zip
Add more shr HTML rendering tests
-rw-r--r--test/data/shr/div-div.html1
-rw-r--r--test/data/shr/div-div.txt2
-rw-r--r--test/data/shr/div-p.html2
-rw-r--r--test/data/shr/li-div.html10
-rw-r--r--test/data/shr/li-div.txt6
-rw-r--r--test/lisp/net/shr-tests.el13
6 files changed, 29 insertions, 5 deletions
diff --git a/test/data/shr/div-div.html b/test/data/shr/div-div.html
new file mode 100644
index 00000000000..1c191ae44d8
--- /dev/null
+++ b/test/data/shr/div-div.html
@@ -0,0 +1 @@
<div>foo</div><div>Bar</div>
diff --git a/test/data/shr/div-div.txt b/test/data/shr/div-div.txt
new file mode 100644
index 00000000000..62715e12513
--- /dev/null
+++ b/test/data/shr/div-div.txt
@@ -0,0 +1,2 @@
1foo
2Bar
diff --git a/test/data/shr/div-p.html b/test/data/shr/div-p.html
index 810b2f75e3c..fcbdfc43293 100644
--- a/test/data/shr/div-p.html
+++ b/test/data/shr/div-p.html
@@ -1 +1 @@
<div>foo</div><p>Bar <div>foo</div><p>Bar</p>
diff --git a/test/data/shr/li-div.html b/test/data/shr/li-div.html
new file mode 100644
index 00000000000..eca3c511bd9
--- /dev/null
+++ b/test/data/shr/li-div.html
@@ -0,0 +1,10 @@
1<ul>
2 <li>
3 <div>
4 <p >This is the first paragraph of a list item.</div>
5 <p >This is the second paragraph of a list item.</li>
6 <li>
7 <div>This is the first paragraph of a list item.</div>
8 <div>This is the second paragraph of a list item.</div>
9 </li>
10</ul>
diff --git a/test/data/shr/li-div.txt b/test/data/shr/li-div.txt
new file mode 100644
index 00000000000..9fc54f2bdc6
--- /dev/null
+++ b/test/data/shr/li-div.txt
@@ -0,0 +1,6 @@
1* This is the first paragraph of a list item.
2
3 This is the second paragraph of a list item.
4
5* This is the first paragraph of a list item.
6 This is the second paragraph of a list item.
diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el
index 60788174d9c..6606ec58151 100644
--- a/test/lisp/net/shr-tests.el
+++ b/test/lisp/net/shr-tests.el
@@ -23,10 +23,14 @@
23 23
24;;; Code: 24;;; Code:
25 25
26(require 'shr)
27
26(defun shr-test (name) 28(defun shr-test (name)
27 (with-temp-buffer 29 (with-temp-buffer
28 (insert-file-contents (format "data/shr/%s.html" name)) 30 (insert-file-contents (format "data/shr/%s.html" name))
29 (let ((dom (libxml-parse-html-region (point-min) (point-max)))) 31 (let ((dom (libxml-parse-html-region (point-min) (point-max)))
32 (shr-width 80)
33 (shr-use-fonts nil))
30 (erase-buffer) 34 (erase-buffer)
31 (shr-insert-document dom) 35 (shr-insert-document dom)
32 (cons (buffer-substring-no-properties (point-min) (point-max)) 36 (cons (buffer-substring-no-properties (point-min) (point-max))
@@ -37,9 +41,10 @@
37(ert-deftest rendering () 41(ert-deftest rendering ()
38 (skip-unless (fboundp 'libxml-parse-html-region)) 42 (skip-unless (fboundp 'libxml-parse-html-region))
39 (dolist (file (directory-files "data/shr" nil "\\.html\\'")) 43 (dolist (file (directory-files "data/shr" nil "\\.html\\'"))
40 (let ((result (shr-test (replace-regexp-in-string 44 (let* ((name (replace-regexp-in-string "\\.html\\'" "" file))
41 "\\.html\\'" "" file)))) 45 (result (shr-test name)))
42 (should (equal (car result) (cdr result)))))) 46 (unless (equal (car result) (cdr result))
47 (should (not (list name (car result) (cdr result))))))))
43 48
44(require 'shr) 49(require 'shr)
45 50