diff options
| author | Mark Oteiza | 2017-09-24 22:28:51 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2017-09-26 17:48:00 -0400 |
| commit | a17f30d7cdfa3983f8c97e474015777ec051de35 (patch) | |
| tree | 9c56ff4e146b9f1c071cb31541e00a1b3fa2e215 /test | |
| parent | 52a1da03b226b8686856259ac5d9474a8462322a (diff) | |
| download | emacs-a17f30d7cdfa3983f8c97e474015777ec051de35.tar.gz emacs-a17f30d7cdfa3983f8c97e474015777ec051de35.zip | |
Add MIME apps spec utilities
Facilitates finding associations between MIME types and desktop files
that report an association with that type. Combined with mailcap.el's
MIME facilities, it should be easy to use desktop files.
* lisp/xdg.el (xdg-mime-table): New variable.
(xdg-mime-apps-files, xdg-mime-collect-associations, xdg-mime-apps):
New functions.
* test/data/xdg/mimeapps.list: New file.
* test/data/xdg/mimeinfo.cache: New file.
* test/lisp/xdg-tests.el (xdg-mime-associations): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/data/xdg/mimeapps.list | 9 | ||||
| -rw-r--r-- | test/data/xdg/mimeinfo.cache | 4 | ||||
| -rw-r--r-- | test/lisp/xdg-tests.el | 12 |
3 files changed, 25 insertions, 0 deletions
diff --git a/test/data/xdg/mimeapps.list b/test/data/xdg/mimeapps.list new file mode 100644 index 00000000000..27fbd94b16b --- /dev/null +++ b/test/data/xdg/mimeapps.list | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [Default Applications] | ||
| 2 | x-test/foo=a.desktop | ||
| 3 | |||
| 4 | [Added Associations] | ||
| 5 | x-test/foo=b.desktop | ||
| 6 | x-test/baz=a.desktop | ||
| 7 | |||
| 8 | [Removed Associations] | ||
| 9 | x-test/foo=c.desktop;d.desktop | ||
diff --git a/test/data/xdg/mimeinfo.cache b/test/data/xdg/mimeinfo.cache new file mode 100644 index 00000000000..6e54f604fa0 --- /dev/null +++ b/test/data/xdg/mimeinfo.cache | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | [MIME Cache] | ||
| 2 | x-test/foo=c.desktop;d.desktop | ||
| 3 | x-test/bar=a.desktop;c.desktop | ||
| 4 | x-test/baz=b.desktop;d.desktop | ||
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el index b80f5e85524..eaf03ab9a03 100644 --- a/test/lisp/xdg-tests.el +++ b/test/lisp/xdg-tests.el | |||
| @@ -65,4 +65,16 @@ | |||
| 65 | (should (equal (xdg-desktop-strings " ") nil)) | 65 | (should (equal (xdg-desktop-strings " ") nil)) |
| 66 | (should (equal (xdg-desktop-strings "a; ;") '("a" " ")))) | 66 | (should (equal (xdg-desktop-strings "a; ;") '("a" " ")))) |
| 67 | 67 | ||
| 68 | (ert-deftest xdg-mime-associations () | ||
| 69 | "Test reading MIME associations from files." | ||
| 70 | (let* ((apps (expand-file-name "mimeapps.list" xdg-tests-data-dir)) | ||
| 71 | (cache (expand-file-name "mimeinfo.cache" xdg-tests-data-dir)) | ||
| 72 | (fs (list apps cache))) | ||
| 73 | (should (equal (xdg-mime-collect-associations "x-test/foo" fs) | ||
| 74 | '("a.desktop" "b.desktop"))) | ||
| 75 | (should (equal (xdg-mime-collect-associations "x-test/bar" fs) | ||
| 76 | '("a.desktop" "c.desktop"))) | ||
| 77 | (should (equal (xdg-mime-collect-associations "x-test/baz" fs) | ||
| 78 | '("a.desktop" "b.desktop" "d.desktop"))))) | ||
| 79 | |||
| 68 | ;;; xdg-tests.el ends here | 80 | ;;; xdg-tests.el ends here |