3 test_description="emacs notmuch-show charset handling"
4 . $(dirname "$0")/test-lib.sh || exit 1
5 . $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
8 UTF8_YEN=$'\xef\xbf\xa5'
13 # Add four messages with unusual encoding requirements:
15 # 1) text/plain in quoted-printable big5
17 [id]=test-plain@example.com \
18 '[content-type]="text/plain; charset=big5"' \
19 '[content-transfer-encoding]=quoted-printable' \
20 '[body]="Yen: =A2=44"'
22 # 2) text/plain in 8bit big5
24 [id]=test-plain-8bit@example.com \
25 '[content-type]="text/plain; charset=big5"' \
26 '[content-transfer-encoding]=8bit' \
27 '[body]="Yen: '$BIG5_YEN'"'
29 # 3) text/html in quoted-printable big5
31 [id]=test-html@example.com \
32 '[content-type]="text/html; charset=big5"' \
33 '[content-transfer-encoding]=quoted-printable' \
34 '[body]="<html><body>Yen: =A2=44</body></html>"'
36 # 4) application/octet-stream in quoted-printable of big5 text
38 [id]=test-binary@example.com \
39 '[content-type]="application/octet-stream"' \
40 '[content-transfer-encoding]=quoted-printable' \
41 '[body]="Yen: =A2=44"'
43 notmuch new > /dev/null
47 test_begin_subtest "Text parts are decoded when rendering"
48 test_emacs '(notmuch-show "id:test-plain@example.com")
49 (test-visible-output "OUTPUT.raw")'
50 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
54 test_expect_equal_file EXPECTED OUTPUT
56 test_begin_subtest "8bit text parts are decoded when rendering"
57 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
58 (test-visible-output "OUTPUT.raw")'
59 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
63 test_expect_equal_file EXPECTED OUTPUT
65 test_begin_subtest "HTML parts are decoded when rendering"
66 test_emacs '(notmuch-show "id:test-html@example.com")
67 (test-visible-output "OUTPUT.raw")'
68 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
73 test_expect_equal_file EXPECTED OUTPUT
77 test_begin_subtest "Text parts are not decoded when saving"
79 test_emacs '(notmuch-show "id:test-plain@example.com")
80 (search-forward "Yen")
81 (let ((standard-input "\"part\""))
82 (notmuch-show-save-part))'
86 test_expect_equal_file part EXPECTED
88 test_begin_subtest "8bit text parts are not decoded when saving"
90 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
91 (search-forward "Yen")
92 (let ((standard-input "\"part\""))
93 (notmuch-show-save-part))'
97 test_expect_equal_file part EXPECTED
99 test_begin_subtest "HTML parts are not decoded when saving"
101 test_emacs '(notmuch-show "id:test-html@example.com")
102 (search-forward "Yen")
103 (let ((standard-input "\"part\""))
104 (notmuch-show-save-part))'
106 <html><body>Yen: $BIG5_YEN</body></html>
108 test_expect_equal_file part EXPECTED
110 test_begin_subtest "Binary parts are not decoded when saving"
112 test_emacs '(notmuch-show "id:test-binary@example.com")
113 (search-forward "application/")
114 (let ((standard-input "\"part\""))
115 (notmuch-show-save-part))'
119 test_expect_equal_file part EXPECTED
121 # Test message viewing
123 test_begin_subtest "Text message are not decoded when viewing"
124 test_emacs '(notmuch-show "id:test-plain@example.com")
125 (notmuch-show-view-raw-message)
126 (test-visible-output "OUTPUT.raw")'
127 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
131 test_expect_equal_file EXPECTED OUTPUT
133 test_begin_subtest "8bit text message are not decoded when viewing"
134 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
135 (notmuch-show-view-raw-message)
136 (test-visible-output "OUTPUT.raw")'
137 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
141 test_expect_equal_file EXPECTED OUTPUT