Export hint and add test case
[cl-notify.git] / notify-test.lisp
blobcca0bee135bfa343c8dcd91c3e9bf23984ea81c4
1 (defpackage :notify-test
2 (:use :cl :cl-notify))
3 (in-package :notify-test)
5 (notify-init)
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Tests ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ;;;;;;;;;;;;;;;;;;;;;;; Test 1: Generate a notification ;;;;;;;;;;;;;;;;;;;;;;;;
11 (dispatch-notification "Summary"
12 :body "Some rather longer content. Blah Blah Blah."
13 :timeout 3000)
15 ;;;;;;;;;;;;;;;;;; Test 2: Callbacks (not implemented) ;;;;;;;;;;;;;;;;;;
17 ;; See test-default-action.c and test-multi-actions.c
19 (warn "Test 2: Not implemented.")
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Test 3: Images ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 ;; First create a notification with a stock icon
24 (dispatch-notification "Icon Test"
25 :body "Testing stock icon"
26 :icon "appointment-new"
27 :timeout 3000)
29 ;; Now try an icon by uri. This assumes that the working directory is set to the
30 ;; cl-notify source directory.
32 (dispatch-notification "Own icon test"
33 :body "Thank you, Conrad Barski!"
34 :icon (format nil "file://~A"
35 (namestring (merge-pathnames
36 "lisplogo_warning_128.png"))))
38 (warn "Test 3: We don't know enough to play with pixbufs yet.")
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Test 4: Markup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42 (dispatch-notification "Markup test"
43 :body "<b>bold</b>, <u>underlined</u>, <i>italic</i>,
44 <a href='http://www.google.com'>linked</a> text"
45 :timeout 3000)
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Test 5: Replace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49 (with-notification n
50 ("Replace me!" :timeout 5000)
51 (show-notification n)
52 (sleep 2)
53 (setf (summary n nil) "Replaced")
54 (setf (body n) "Here's some new body text."))
56 ;;;;;;;;;;;;;;;;;;;;;;;; Test 6: Attaching to widgets. ;;;;;;;;;;;;;;;;;;;;;;;;;
58 ;; See test-replace-widget.c
60 (warn "Attachment to widgets not implemented.")
62 ;;;;;;;;;;;;;;;;;;;;;;;;; Test 7: Getting server info ;;;;;;;;;;;;;;;;;;;;;;;;;;
63 (destructuring-bind (name vendor version specversion)
64 (server-info)
65 (format t "Server info~%~%~:{~A:~1,15T~A~%~}"
66 `(("Name" ,name)
67 ("Vendor" ,vendor)
68 ("Version" ,version)
69 ("Spec. Version" ,specversion))))
71 ;; See test-server-info.c
72 (warn "get-server-caps not implemented: avoiding GList.")
74 (dispatch-notification "Low"
75 :body "Put the washing out"
76 :urgency :low)
77 (dispatch-notification "Medium"
78 :body "Drink coffee!"
79 :urgency :normal)
80 (dispatch-notification "High"
81 :body "Plug your laptop in!!"
82 :urgency :critical)
84 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; Test 8: Setting a hint ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
86 (with-notification n ("X, Y Test"
87 :body "This notification should point to 150, 10")
89 (setf (hint n "x" :int) 150)
90 (setf (hint n "y" :int) 150)
92 (show-notification n))