From fe10119933602207aabf32e32796390048b0d287 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 1 Jul 2017 22:39:47 -0400 Subject: [PATCH] tests: Test the notifications. --- tests/examples/awful/notification/corner.lua | 20 +++++++++++++ tests/examples/naughty/actions.lua | 19 ++++++++++++ tests/examples/naughty/colors.lua | 19 ++++++++++++ tests/examples/naughty/helloworld.lua | 18 ++++++++++++ tests/examples/naughty/shape.lua | 31 ++++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 tests/examples/awful/notification/corner.lua create mode 100644 tests/examples/naughty/actions.lua create mode 100644 tests/examples/naughty/colors.lua create mode 100644 tests/examples/naughty/helloworld.lua create mode 100644 tests/examples/naughty/shape.lua diff --git a/tests/examples/awful/notification/corner.lua b/tests/examples/awful/notification/corner.lua new file mode 100644 index 00000000..9cbc9128 --- /dev/null +++ b/tests/examples/awful/notification/corner.lua @@ -0,0 +1,20 @@ +--DOC_HIDE_ALL +local naughty = require("naughty") --DOC_HIDE + +for _, pos in ipairs { + "top_left", + "top_middle", + "top_right", + "bottom_left", + "bottom_middle", + "bottom_right", +} do + naughty.notify { + title = pos, + position = pos, + text = "", + } +end + + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/naughty/actions.lua b/tests/examples/naughty/actions.lua new file mode 100644 index 00000000..f21d73ef --- /dev/null +++ b/tests/examples/naughty/actions.lua @@ -0,0 +1,19 @@ +--DOC_NO_USAGE +--DOC_HIDE_ALL +-- local naughty = require("naughty") + +dbus.notify_send( + --[[data]] { + member = "Notify", + }, + --[[app_name]] "Notification demo", + --[[replaces_id]] nil, + --[[icon]] "", + --[[title]] "You got a message!", + --[[text]] "This is a message from above.\nAwesomeWM is your faith.", + {"Accept", "Dismiss", "Forward"}, + --[[hints]] {}, + --[[expire]] 5 +) + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/naughty/colors.lua b/tests/examples/naughty/colors.lua new file mode 100644 index 00000000..2149e429 --- /dev/null +++ b/tests/examples/naughty/colors.lua @@ -0,0 +1,19 @@ + +local beautiful = require("beautiful") --DOC_HIDE + +local text = [[An important +notification +]] + +require("naughty").notify { + title = "Hello world!", + text = text, + icon = beautiful.icon, + bg = "#0000ff", + fg = "#ff0000", + font = "verdana 14", + border_width = 1, + border_color = "#ff0000" +} + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/naughty/helloworld.lua b/tests/examples/naughty/helloworld.lua new file mode 100644 index 00000000..5c6daecc --- /dev/null +++ b/tests/examples/naughty/helloworld.lua @@ -0,0 +1,18 @@ +--DOC_HIDE_ALL +-- local naughty = require("naughty") + +dbus.notify_send( + --[[data]] { + member = "Notify", + }, + --[[app_name]] "Notification demo", + --[[replaces_id]] nil, + --[[icon]] "", + --[[title]] "Hello world!", + --[[text]] "The notification content", + --[[actions]] {}, + --[[hints]] {}, + --[[expire]] 5 +) + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/naughty/shape.lua b/tests/examples/naughty/shape.lua new file mode 100644 index 00000000..b685b605 --- /dev/null +++ b/tests/examples/naughty/shape.lua @@ -0,0 +1,31 @@ + +local beautiful = require("beautiful") --DOC_HIDE +local gears = {shape=require("gears.shape")} --DOC_HIDE +local naughty = require("naughty") --DOC_HIDE + +local text = [[An important +notification +]] + +local shapes = { + gears.shape.rounded_rect, + gears.shape.hexagon, + gears.shape.octogon, + function(cr, w, h) + return gears.shape.infobubble(cr, w, h, 20, 10, w/2 - 10) + end +} + +for _, s in ipairs(shapes) do + naughty.notify { + title = "Hello world!", + text = text, + icon = beautiful.icon, + shape = s, + border_width = 3, + border_color = beautiful.bg_highlight, + margin = 15, + } +end + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80