[Xfce4-commits] [apps/xfce4-notifyd] 01/01: Add tests for notifications with icons
noreply at xfce.org
noreply at xfce.org
Sun Oct 2 13:54:49 CEST 2016
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-notifyd.
commit 57f63fe78fc867031b7962480ad8a10efaad5b7a
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sun Oct 2 13:54:24 2016 +0200
Add tests for notifications with icons
---
Makefile.am | 16 +++++-
tests/test-icons.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 99dc7c9..a5dc43c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -294,7 +294,8 @@ dist-hook: ChangeLog
noinst_PROGRAMS = \
tests/test-text \
tests/test-positioning \
- tests/test-actions
+ tests/test-actions \
+ tests/test-icons
tests_cflags = \
-I$(top_srcdir) \
@@ -303,6 +304,15 @@ tests_cflags = \
tests_ldadd = \
$(LIBNOTIFY_LIBS)
+icon_tests_cflags = \
+ -I$(builddir) \
+ $(GTK3_CFLAGS) \
+ $(tests_cflags)
+
+icon_tests_ldadd = \
+ $(GTK3_LIBS) \
+ $(tests_ldadd)
+
tests_test_actions_SOURCES = tests/test-actions.c
tests_test_actions_CFLAGS = $(tests_cflags)
tests_test_actions_LDADD = $(tests_ldadd)
@@ -314,3 +324,7 @@ tests_test_positioning_LDADD = $(tests_ldadd)
tests_test_text_SOURCES = tests/test-text.c
tests_test_text_CFLAGS = $(tests_cflags)
tests_test_text_LDADD = $(tests_ldadd)
+
+tests_test_icons_SOURCES = tests/test-icons.c
+tests_test_icons_CFLAGS = $(icon_tests_cflags)
+tests_test_icons_LDADD = $(icon_tests_ldadd)
diff --git a/tests/test-icons.c b/tests/test-icons.c
new file mode 100644
index 0000000..cb93acc
--- /dev/null
+++ b/tests/test-icons.c
@@ -0,0 +1,139 @@
+/*
+ * xfce4-notifyd
+ *
+ * Copyright (c) 2016 Simon Steinbeiß <ochosi at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+ /* The following tests will try to determine if the notification server acts in
+ conformance with the following wording of the freedesktop.org specification:
+ "An implementation which only displays one image or icon must choose which
+ one to display using the following order:"
+ "image-data"
+ "image-path"
+ app_icon parameter
+ for compatibility reason, "icon_data" */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <stdlib.h>
+#include <libnotify/notify.h>
+#include <gtk/gtk.h>
+
+static gboolean
+show_notification (NotifyNotification *notification) {
+ if (!notify_notification_show (notification, NULL))
+ {
+ g_error ("Failed");
+ g_object_unref (notification);
+
+ return EXIT_FAILURE;
+ }
+ g_object_unref (notification);
+ return EXIT_SUCCESS;
+}
+
+int main (int argc, char **argv)
+{
+ NotifyNotification *notification;
+ GdkPixbuf *image_data;
+
+ if (!notify_init ("Notification with icon tests"))
+ {
+ g_error ("Failed to initialize libnotify.");
+
+ return EXIT_FAILURE;
+ }
+
+ gtk_init(&argc, &argv);
+
+ image_data = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ "xfce4-notifyd", 48,
+ GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
+
+ g_print ("%s", "Testing notification with app_icon parameter\n");
+ notification = notify_notification_new ("Test app_icon support",
+ "Does it work?",
+ "xfce4-notifyd");
+ show_notification (notification);
+
+ g_print ("%s", "Testing notification with the image-path hint\n");
+ notification = notify_notification_new ("Test 'image-path' hint support",
+ "Does it work?",
+ NULL);
+ notify_notification_set_hint_string (notification,
+ "image-path",
+ "xfce4-notifyd");
+ show_notification (notification);
+
+ g_print ("%s", "Testing notification with the image-data hint\n");
+ notification = notify_notification_new ("Test 'image-data' and 'image_data' hint support",
+ "Does it work?",
+ NULL);
+ notify_notification_set_image_from_pixbuf (notification, image_data);
+ show_notification (notification);
+
+ /* The priority tests are stll dummies. Need to decide whether to ship our own
+ icons for testing or whether to use standard named icons and hope that they're
+ installed or available in the currently selected theme and its fallbacks. */
+ g_print ("%s", "Testing priorities with app_icon versus image-path\n");
+ notification = notify_notification_new ("Test priorities: app_icon vs. image-path",
+ "image-path should be shown.",
+ "xfce4-notifyd");
+ notify_notification_set_hint_string (notification,
+ "image-path",
+ "xfce4-notifyd");
+ show_notification (notification);
+
+ g_print ("%s", "Testing priorities with app_icon versus image-data\n");
+ notification = notify_notification_new ("Test priorities: app_icon vs. image-data",
+ "image-data should be shown.",
+ "xfce4-notifyd");
+ notify_notification_set_image_from_pixbuf (notification, image_data);
+ show_notification (notification);
+
+ g_print ("%s", "Testing priorities with image-path versus image-data\n");
+ notification = notify_notification_new ("Test priorities: image-path vs. image-data",
+ "image-data should be shown.",
+ NULL);
+ notify_notification_set_hint_string (notification,
+ "image-path",
+ "xfce4-notifyd");
+ notify_notification_set_image_from_pixbuf (notification, image_data);
+ show_notification (notification);
+
+ g_print ("%s", "Testing priorities with app_icon vs. image-path vs. image-data\n");
+ notification = notify_notification_new ("Test priorities: app_icon vs. image-path vs. image-data",
+ "image-data should be shown.",
+ "xfce4-notifyd");
+ notify_notification_set_hint_string (notification,
+ "image-path",
+ "xfce4-notifyd");
+ notify_notification_set_image_from_pixbuf (notification, image_data);
+ show_notification (notification);
+
+ g_print ("%s", "Testing support for symbolic icons (partly depends on currently selected theme)\n");
+ notification = notify_notification_new ("Test support for symbolic icons",
+ "Is it correctly colored?",
+ "xfce4-notifyd-symbolic");
+ show_notification (notification);
+
+ g_object_unref (image_data);
+
+ return EXIT_SUCCESS;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list