3 test_description="emacs notmuch-show charset handling"
4 . $(dirname "$0")/test-lib.sh || exit 1
7 UTF8_YEN=$'\xef\xbf\xa5'
10 # Add four messages with unusual encoding requirements:
12 # 1) text/plain in quoted-printable big5
14 [id]=test-plain@example.com \
15 '[content-type]="text/plain; charset=big5"' \
16 '[content-transfer-encoding]=quoted-printable' \
17 '[body]="Yen: =A2=44"'
19 # 2) text/plain in 8bit big5
21 [id]=test-plain-8bit@example.com \
22 '[content-type]="text/plain; charset=big5"' \
23 '[content-transfer-encoding]=8bit' \
24 '[body]="Yen: '$BIG5_YEN'"'
26 # 3) text/html in quoted-printable big5
28 [id]=test-html@example.com \
29 '[content-type]="text/html; charset=big5"' \
30 '[content-transfer-encoding]=quoted-printable' \
31 '[body]="<html><body>Yen: =A2=44</body></html>"'
33 # 4) application/octet-stream in quoted-printable of big5 text
35 [id]=test-binary@example.com \
36 '[content-type]="application/octet-stream"' \
37 '[content-transfer-encoding]=quoted-printable' \
38 '[body]="Yen: =A2=44"'
40 notmuch new > /dev/null
44 test_begin_subtest "Text parts are decoded when rendering"
45 test_emacs '(notmuch-show "id:test-plain@example.com")
46 (test-visible-output "OUTPUT.raw")'
47 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
51 test_expect_equal_file EXPECTED OUTPUT
53 test_begin_subtest "8bit text parts are decoded when rendering"
54 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
55 (test-visible-output "OUTPUT.raw")'
56 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
60 test_expect_equal_file EXPECTED OUTPUT
62 test_begin_subtest "HTML parts are decoded when rendering"
63 test_emacs '(notmuch-show "id:test-html@example.com")
64 (test-visible-output "OUTPUT.raw")'
65 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
70 test_expect_equal_file EXPECTED OUTPUT
74 test_begin_subtest "Text parts are not decoded when saving"
76 test_emacs '(notmuch-show "id:test-plain@example.com")
77 (search-forward "Yen")
78 (let ((standard-input "\"part\""))
79 (notmuch-show-save-part))'
83 test_expect_equal_file part EXPECTED
85 test_begin_subtest "8bit text parts are not decoded when saving"
87 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
88 (search-forward "Yen")
89 (let ((standard-input "\"part\""))
90 (notmuch-show-save-part))'
94 test_expect_equal_file part EXPECTED
96 test_begin_subtest "HTML parts are not decoded when saving"
98 test_emacs '(notmuch-show "id:test-html@example.com")
99 (search-forward "Yen")
100 (let ((standard-input "\"part\""))
101 (notmuch-show-save-part))'
103 <html><body>Yen: $BIG5_YEN</body></html>
105 test_expect_equal_file part EXPECTED
107 test_begin_subtest "Binary parts are not decoded when saving"
109 test_emacs '(notmuch-show "id:test-binary@example.com")
110 (search-forward "application/")
111 (let ((standard-input "\"part\""))
112 (notmuch-show-save-part))'
116 test_expect_equal_file part EXPECTED
118 # Test message viewing
120 test_begin_subtest "Text message are not decoded when viewing"
121 test_emacs '(notmuch-show "id:test-plain@example.com")
122 (notmuch-show-view-raw-message)
123 (test-visible-output "OUTPUT.raw")'
124 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
128 test_expect_equal_file EXPECTED OUTPUT
130 test_begin_subtest "8bit text message are not decoded when viewing"
131 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
132 (notmuch-show-view-raw-message)
133 (test-visible-output "OUTPUT.raw")'
134 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
138 test_expect_equal_file EXPECTED OUTPUT