diff options
| author | Po Lu | 2022-06-12 22:04:47 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-12 22:04:47 +0800 |
| commit | 1dd92bb7b8817038577626a13d7464a09e4d8a27 (patch) | |
| tree | 7a1b93f277c7b0b2ded6290ce2ba39189c0e97fe /test | |
| parent | 6263f586b87a952e00103a82af1dd0360c1a238d (diff) | |
| download | emacs-1dd92bb7b8817038577626a13d7464a09e4d8a27.tar.gz emacs-1dd92bb7b8817038577626a13d7464a09e4d8a27.zip | |
Fix encoding of multibyte ToolTalk filenames
* lisp/select.el (xselect-convert-to-dt-netfile): Encode file
name before computing its tooltalk name, since the indices work
on bytes.
* test/lisp/dnd-tests.el (dnd-tests-begin-file-drag): Add test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/dnd-tests.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/lisp/dnd-tests.el b/test/lisp/dnd-tests.el index c4b7567f22e..dfd441b56df 100644 --- a/test/lisp/dnd-tests.el +++ b/test/lisp/dnd-tests.el | |||
| @@ -184,10 +184,15 @@ This function only tries to handle strings." | |||
| 184 | (not (eq window-system 'x)))) | 184 | (not (eq window-system 'x)))) |
| 185 | (let ((normal-temp-file (expand-file-name (make-temp-name "dnd-test") | 185 | (let ((normal-temp-file (expand-file-name (make-temp-name "dnd-test") |
| 186 | temporary-file-directory)) | 186 | temporary-file-directory)) |
| 187 | (normal-multibyte-file (expand-file-name | ||
| 188 | (make-temp-name "тест-на-перетаскивание") | ||
| 189 | temporary-file-directory)) | ||
| 187 | (remote-temp-file (dnd-tests-make-temp-name))) | 190 | (remote-temp-file (dnd-tests-make-temp-name))) |
| 188 | ;; Touch those files if they don't exist. | 191 | ;; Touch those files if they don't exist. |
| 189 | (unless (file-exists-p normal-temp-file) | 192 | (unless (file-exists-p normal-temp-file) |
| 190 | (write-region "" 0 normal-temp-file)) | 193 | (write-region "" 0 normal-temp-file)) |
| 194 | (unless (file-exists-p normal-multibyte-file) | ||
| 195 | (write-region "" 0 normal-multibyte-file)) | ||
| 191 | (unless (file-exists-p remote-temp-file) | 196 | (unless (file-exists-p remote-temp-file) |
| 192 | (write-region "" 0 remote-temp-file)) | 197 | (write-region "" 0 remote-temp-file)) |
| 193 | (unwind-protect | 198 | (unwind-protect |
| @@ -239,8 +244,20 @@ This function only tries to handle strings." | |||
| 239 | (dnd-begin-file-drag normal-temp-file) | 244 | (dnd-begin-file-drag normal-temp-file) |
| 240 | (not dnd-last-dragged-remote-file))) | 245 | (not dnd-last-dragged-remote-file))) |
| 241 | ;; Test that links to remote files can't be created. | 246 | ;; Test that links to remote files can't be created. |
| 242 | (should-error (dnd-begin-file-drag remote-temp-file nil 'link))) | 247 | (should-error (dnd-begin-file-drag remote-temp-file nil 'link)) |
| 248 | ;; Test dragging a file with a multibyte filename. | ||
| 249 | (should (eq (dnd-begin-file-drag normal-multibyte-file) 'copy)) | ||
| 250 | ;; Test that the ToolTalk filename is encodes and decodes correctly. | ||
| 251 | (let* ((netfile-data (cdr (dnd-tests-verify-selection-data '_DT_NETFILE))) | ||
| 252 | (parsed (dnd-tests-parse-tt-netfile netfile-data)) | ||
| 253 | (filename (encode-coding-string normal-multibyte-file | ||
| 254 | (or file-name-coding-system | ||
| 255 | default-file-name-coding-system)))) | ||
| 256 | (should (equal (nth 0 parsed) (system-name))) | ||
| 257 | (should (equal (nth 1 parsed) filename)) | ||
| 258 | (should (equal (nth 2 parsed) filename)))) | ||
| 243 | (delete-file normal-temp-file) | 259 | (delete-file normal-temp-file) |
| 260 | (delete-file normal-multibyte-file) | ||
| 244 | (delete-file remote-temp-file)))) | 261 | (delete-file remote-temp-file)))) |
| 245 | 262 | ||
| 246 | (ert-deftest dnd-tests-begin-drag-files () | 263 | (ert-deftest dnd-tests-begin-drag-files () |