diff --git a/test/dunstrc.default b/test/dunstrc.default new file mode 100644 index 0000000..200eb38 --- /dev/null +++ b/test/dunstrc.default @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.ignore_newline b/test/dunstrc.ignore_newline new file mode 100644 index 0000000..de3f9e9 --- /dev/null +++ b/test/dunstrc.ignore_newline @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = yes + geometry = "200x0-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.ignore_newline_no_wrap b/test/dunstrc.ignore_newline_no_wrap new file mode 100644 index 0000000..63ebac8 --- /dev/null +++ b/test/dunstrc.ignore_newline_no_wrap @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = no + ignore_newline = yes + geometry = "250x0-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.markup b/test/dunstrc.markup new file mode 100644 index 0000000..eba3aea --- /dev/null +++ b/test/dunstrc.markup @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.nomarkup b/test/dunstrc.nomarkup new file mode 100644 index 0000000..bb30e33 --- /dev/null +++ b/test/dunstrc.nomarkup @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = no + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.nowrap b/test/dunstrc.nowrap new file mode 100644 index 0000000..f9d0a0a --- /dev/null +++ b/test/dunstrc.nowrap @@ -0,0 +1,50 @@ +[global] + font = Monospace-10 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = no + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2; + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst: + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/dunstrc.run_script b/test/dunstrc.run_script new file mode 100644 index 0000000..32555dc --- /dev/null +++ b/test/dunstrc.run_script @@ -0,0 +1,54 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 + +[script test] + summary = trigger + script = script_test.sh diff --git a/test/dunstrc.show_age b/test/dunstrc.show_age new file mode 100644 index 0000000..1c3b5c7 --- /dev/null +++ b/test/dunstrc.show_age @@ -0,0 +1,50 @@ +[global] + font = Monospace 8 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = left + bounce_freq = 0 + show_age_threshold = 2 + word_wrap = yes + ignore_newline = no + geometry = "300x5-30+20" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = frame + startup_notification = false + dmenu = /usr/bin/dmenu -p dunst + browser = /usr/bin/firefox -new-tab + +[frame] + width = 3 + color = "#aaaaaa" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + history = ctrl+grave + context = ctrl+shift+period + +[urgency_low] + background = "#222222" + foreground = "#888888" + timeout = 10 + +[urgency_normal] + background = "#285577" + foreground = "#ffffff" + timeout = 10 + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + timeout = 0 diff --git a/test/notify.py b/test/notify.py new file mode 100755 index 0000000..6a8d057 --- /dev/null +++ b/test/notify.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python2 + +import pynotify +import sys + +from optparse import OptionParser + +def action_callback(arg): + print "action invoked (%s)" % (arg) + +parser = OptionParser() + +parser.add_option("-a", "--appname", dest="appname", action="store", default="dunst tester") +parser.add_option("-s", "--summary", dest="summary", action="store", default="summary") +parser.add_option("-b", "--body", dest="body", action="store", default="body") +parser.add_option("-u", "--urgency", dest="urgency", action="store", default="n") +parser.add_option("-A", "--action", dest="action", action="store", default=None) +parser.add_option("-w", "--wait", dest="wait", action="store_true", default=False) +parser.add_option("-t", "--timeout", dest="timeout", action="store", default=-1) +parser.add_option("-H", "--hint", dest="hint", action="store", default=None) +parser.add_option("-r", "--replaces", dest="id", action="store", default=0) +parser.add_option("-c", "--close", dest="close", action="store", default=0) +parser.add_option("-p", "--print_id", dest="print_id", action="store_true", default=False) + +(o, args) = parser.parse_args() + + +pynotify.init(o.appname) + +n = pynotify.Notification(o.summary, o.body) + +try: + if o.urgency[0] == "l": + n.set_urgency(pynotify.URGENCY_LOW) + if o.urgency[0] == "n": + n.set_urgency(pynotify.URGENCY_NORMAL) + if o.urgency[0] == "c": + n.set_urgency(pynotify.URGENCY_CRITICAL) +except: + pass + + +if o.action: + n.add_action(o.action.split(":")[0], o.action.split(":")[1], action_callback, None) + +if o.id: + n.props.id = int(o.id) + +if o.close: + n.props.id = int(o.id) + n.close() + sys.exit(0) + +# FIXME hints + +n.set_timeout(int(o.timeout)) + +n.show() + +if o.print_id: + nid = n.props.id + print nid + +# FIXME wait diff --git a/test/script_test.sh b/test/script_test.sh new file mode 100755 index 0000000..8d35f70 --- /dev/null +++ b/test/script_test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +notify-send "Success" "ooooh yeah" diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..c490675 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,168 @@ +#!/bin/bash + +function keypress { + echo "press enter to continue..." + read key +} + +function basic_notifications { + ./notify.py -a "dunst tester" -s "normal" -b "italic body" -u "n" + ./notify.py -a "dunst tester" -s "critical" -b "bold body" -u "c" + ./notify.py -a "dunst tester" -s "long body" -b "This is a notification with a very long body" + ./notify.py -a "dunst tester" -s "duplucate" + ./notify.py -a "dunst tester" -s "duplucate" + ./notify.py -a "dunst tester" -s "duplucate" + ./notify.py -a "dunst tester" -s "url" -b "www.google.de" + +} + +function show_age { + killall dunst + ../dunst -config dunstrc.show_age & + ./notify.py -a "dunst tester" -s "Show Age" -b "These should print their age after 2 seconds" -u "c" + basic_notifications + keypress +} + +function run_script { + killall dunst + PATH=".:$PATH" ../dunst -config dunstrc.run_script & + ./notify.py -a "dunst tester" -s "Run Script" -b "After Keypress, 2 other notification should pop up. THis needs notify-send installed" -u "c" + keypress + ./notify.py -a "dunst tester" -s "trigger" -b "this should trigger a notification" -u "c" + keypress +} + +function ignore_newline { + killall dunst + ../dunst -config dunstrc.ignore_newline_no_wrap & + ./notify.py -a "dunst tester" -s "Ignore Newline No Wrap" -b "There should be no newline anywhere" -u "c" + ./notify.py -a "dunst tester" -s "Th\nis\n\n\n is\n fu\nll of \n" -s "\nnew\nlines" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.ignore_newline & + ./notify.py -a "dunst tester" -s "Ignore Newline" -b "The only newlines you should encounter here are wordwraps. That's why I'm so long." -u "c" + ./notify.py -a "dunst tester" -s "Th\nis\n\n\n is\n fu\nll of \n" -b "\nnew\nlines" -u "c" + basic_notifications + keypress +} + +function replace { + killall dunst + ../dunst -config dunstrc.default & + id=$(./notify.py -a "dunst tester" -s "Replace" -b "this should get replaces after keypress" -p) + keypress + id=$(./notify.py -a "dunst tester" -s "Success?" -b "I hope this is not a new notification" -r $id) + keypress + +} + +function markup { + killall dunst + ../dunst -config dunstrc.markup "200x0+10+10" & + ./notify.py -a "dunst tester" -s "Markup Tests" -u "c" + ./notify.py -a "dunst tester" -s "bold italic" + ./notify.py -a "dunst tester" -s "broken markup" + keypress + + killall dunst + ../dunst -config dunstrc.nomarkup "200x0+10+10" & + ./notify.py -a "dunst tester" -s "NO Markup Tests" -u "c" + ./notify.py -a "dunst tester" -s "bolditalic" + ./notify.py -a "dunst tester" -s "broken markup" + keypress + +} + +function corners { + killall dunst + ../dunst -config dunstrc.default -geom "200x0+10+10" & + ./notify.py -a "dunst tester" -s "upper left" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "200x0-10+10" & + ./notify.py -a "dunst tester" -s "upper right" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "200x0-10-10" & + ./notify.py -a "dunst tester" -s "lower right" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "200x0+10-10" & + ./notify.py -a "dunst tester" -s "lower left" -u "c" + basic_notifications + keypress + +} + +function geometry { + killall dunst + ../dunst -config dunstrc.default -geom "0x0" & + ./notify.py -a "dunst tester" -s "0x0" -u "c" + basic_notifications + keypress + + + killall dunst + ../dunst -config dunstrc.default -geom "200x0" & + ./notify.py -a "dunst tester" -s "200x0" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "200x2" & + ./notify.py -a "dunst tester" -s "200x2" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "200x1" & + ./notify.py -a "dunst tester" -s "200x1" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "0x1" & + ./notify.py -a "dunst tester" -s "0x1" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "-300x1" & + ./notify.py -a "dunst tester" -s "-300x1" -u "c" + basic_notifications + keypress + + killall dunst + ../dunst -config dunstrc.default -geom "-300x1-20-20" & + ./notify.py -a "dunst tester" -s "-300x1-20-20" -u "c" + basic_notifications + keypress +} + +if [ -n "$1" ]; then + while [ -n "$1" ]; do + $1 + shift + done +else + geometry + corners + show_age + run_script + ignore_newline + replace + markup + corners + geometry +fi + +killall dunst