diff options
| author | Andreas Politz <politza@hochschule-trier.de> | 2017-01-27 20:18:08 +0100 |
|---|---|---|
| committer | Andreas Politz <politza@hochschule-trier.de> | 2017-01-27 20:35:20 +0100 |
| commit | dd4d2da041afd4c7ea4d9d940272e56ff4b9d326 (patch) | |
| tree | ca9bb1b1037858efe303c9fde62e0bd8e9446cd8 | |
| parent | 9019efc8a47b34db342563037395c2f146bcda5f (diff) | |
Add tests for encrypted documents
| -rw-r--r-- | test/encrypted.pdf | bin | 0 -> 112372 bytes | |||
| -rw-r--r-- | test/pdf-info.ert | 7 | ||||
| -rw-r--r-- | test/run-tests.el | 16 |
3 files changed, 17 insertions, 6 deletions
diff --git a/test/encrypted.pdf b/test/encrypted.pdf Binary files differnew file mode 100644 index 0000000..a6c2ef2 --- /dev/null +++ b/test/encrypted.pdf diff --git a/test/pdf-info.ert b/test/pdf-info.ert index 82f3e38..161133f 100644 --- a/test/pdf-info.ert +++ b/test/pdf-info.ert @@ -6,8 +6,11 @@ (ert-deftest pdf-info-open/close () (pdf-test-with-test-pdf - (should-not (pdf-info-open)) - (should (pdf-info-close)))) + (should-not (pdf-info-open)) + (should (pdf-info-close))) + (pdf-test-with-encrypted-pdf + (should-error (pdf-info-open nil "Invalid Password")) + (should-not (pdf-info-open nil "pdftool")))) (ert-deftest pdf-info-metadata () (pdf-test-with-test-pdf diff --git a/test/run-tests.el b/test/run-tests.el index f05c092..7ccb514 100644 --- a/test/run-tests.el +++ b/test/run-tests.el @@ -55,11 +55,11 @@ (>= x 0))) edges))) -(defmacro pdf-test-with-test-pdf (&rest body) +(defmacro pdf-test-with-pdf (pdf-filename &rest body) (declare (indent 0) (debug t)) (let ((buffer (make-symbol "buffer"))) `(let ((,buffer (find-file-noselect - (expand-file-name "test.pdf"))) + (expand-file-name ,pdf-filename))) (pdf-info-epdfinfo-error-filename (make-temp-file "epdfinfo.log"))) (unwind-protect (progn @@ -67,8 +67,10 @@ (pdf-info-process-assert-running t) (with-current-buffer ,buffer ,@body)) (when (buffer-live-p ,buffer) - (set-buffer-modified-p nil) - (kill-buffer)) + (with-current-buffer ,buffer + (set-buffer-modified-p nil) + (let (kill-buffer-hook) + (kill-buffer)))) (when (file-exists-p pdf-info-epdfinfo-error-filename) (with-temp-buffer (insert-file-contents pdf-info-epdfinfo-error-filename) @@ -77,6 +79,12 @@ (delete-file pdf-info-epdfinfo-error-filename)) (pdf-info-quit))))) +(defmacro pdf-test-with-test-pdf (&rest body) + `(pdf-test-with-pdf "test.pdf" ,@body)) + +(defmacro pdf-test-with-encrypted-pdf (&rest body) + `(pdf-test-with-pdf "encrypted.pdf" ,@body)) + (dolist (file (directory-files "." t "\\.ert\\'")) (load-file file)) (ert-run-tests-batch-and-exit t) |
