From 4026faf46b093d2f4207732f4019a595e08e8ada Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Thu, 28 Oct 2010 14:55:08 -0400 Subject: [PATCH] Add tests for transient and resident --- tests/Makefile.am | 8 ++++ tests/test-resident.c | 102 +++++++++++++++++++++++++++++++++++++++++ tests/test-transient.c | 52 +++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 tests/test-resident.c create mode 100644 tests/test-transient.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 115cbd9..706730d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,8 +13,10 @@ noinst_PROGRAMS = \ test-error \ test-markup \ test-persistence \ + test-resident \ test-rtl \ test-size-changes \ + test-transient \ test-urgency \ test-xy \ test-xy-actions \ @@ -72,6 +74,12 @@ test_rtl_LDADD = $(common_ldflags) test_persistence_SOURCES = test-persistence.c test_persistence_LDADD = $(common_ldflags) +test_resident_SOURCES = test-resident.c +test_resident_LDADD = $(common_ldflags) + +test_transient_SOURCES = test-transient.c +test_transient_LDADD = $(common_ldflags) + EXTRA_DIST = applet-critical.png -include $(top_srcdir)/git.mk diff --git a/tests/test-resident.c b/tests/test-resident.c new file mode 100644 index 0000000..bcbe6f0 --- /dev/null +++ b/tests/test-resident.c @@ -0,0 +1,102 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or(at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include + +static GMainLoop *loop; + +static void +prev_callback (NotifyNotification *n, + const char *action) +{ + g_assert (action != NULL); + g_assert (strcmp (action, "previous") == 0); + + printf ("You clicked Previous\n"); +} + +static void +pause_callback (NotifyNotification *n, + const char *action) +{ + g_assert (action != NULL); + g_assert (strcmp (action, "pause") == 0); + + printf ("You clicked Pause\n"); +} + +static void +next_callback (NotifyNotification *n, + const char *action) +{ + g_assert (action != NULL); + g_assert (strcmp (action, "next") == 0); + + printf ("You clicked Next\n"); +} + + +int +main (int argc, char **argv) +{ + NotifyNotification *n; + GVariant *hint; + + if (!notify_init ("Resident Test")) + exit (1); + + loop = g_main_loop_new (NULL, FALSE); + + n = notify_notification_new ("Music Player", + "Playing some fine song", + "audio-x-generic"); + hint = g_variant_new_boolean (TRUE); + notify_notification_set_hint (n, "resident", hint); + notify_notification_add_action (n, + "previous", + "Previous", + (NotifyActionCallback) prev_callback, + NULL, + NULL); + notify_notification_add_action (n, + "pause", + "Pause", + (NotifyActionCallback) + pause_callback, + NULL, + NULL); + notify_notification_add_action (n, + "next", + "Next", + (NotifyActionCallback) next_callback, + NULL, + NULL); + + if (!notify_notification_show (n, NULL)) { + fprintf (stderr, "failed to send notification\n"); + return 1; + } + + g_main_loop_run (loop); + + return 0; +} diff --git a/tests/test-transient.c b/tests/test-transient.c new file mode 100644 index 0000000..67913bd --- /dev/null +++ b/tests/test-transient.c @@ -0,0 +1,52 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or(at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include + +static GMainLoop *loop; + +int +main (int argc, char **argv) +{ + NotifyNotification *n; + GVariant *hint; + + if (!notify_init ("Transient Test")) + exit (1); + + loop = g_main_loop_new (NULL, FALSE); + + n = notify_notification_new ("Some transient change", + "Something happened", + "audio-volume-medium"); + hint = g_variant_new_boolean (TRUE); + notify_notification_set_hint (n, "transient", hint); + + if (!notify_notification_show (n, NULL)) { + fprintf (stderr, "failed to send notification\n"); + return 1; + } + + g_main_loop_run (loop); + + return 0; +}