basic testing framework

This commit is contained in:
Sascha Kruse 2013-02-22 22:48:16 +00:00
parent 81fa1dfc02
commit 23f0230baa
11 changed files with 639 additions and 0 deletions

50
test/dunstrc.default Normal file
View File

@ -0,0 +1,50 @@
[global]
font = Monospace 8
allow_markup = yes
format = "<b>%s</b>\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

View File

@ -0,0 +1,50 @@
[global]
font = Monospace 8
allow_markup = yes
format = "<b>%s</b>\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

View File

@ -0,0 +1,50 @@
[global]
font = Monospace 8
allow_markup = yes
format = "<b>%s</b>\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

50
test/dunstrc.markup Normal file
View File

@ -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

50
test/dunstrc.nomarkup Normal file
View File

@ -0,0 +1,50 @@
[global]
font = Monospace 8
allow_markup = no
format = "<b>%s</b>\n<i>%b</i>"
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

50
test/dunstrc.nowrap Normal file
View File

@ -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

54
test/dunstrc.run_script Normal file
View File

@ -0,0 +1,54 @@
[global]
font = Monospace 8
allow_markup = yes
format = "<b>%s</b>\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

50
test/dunstrc.show_age Normal file
View File

@ -0,0 +1,50 @@
[global]
font = Monospace 8
allow_markup = yes
format = "<b>%s</b>\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

64
test/notify.py Executable file
View File

@ -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

3
test/script_test.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
notify-send "Success" "ooooh yeah"

168
test/test.sh Executable file
View File

@ -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 "<i>italic body</i>" -u "n"
./notify.py -a "dunst tester" -s "critical" -b "<b>bold body</b>" -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 "<b>bold</b> <i>italic</i>"
./notify.py -a "dunst tester" -s "<b>broken markup</i>"
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 "<b>bold</b><i>italic</i>"
./notify.py -a "dunst tester" -s "<b>broken markup</i>"
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