summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-11-28 13:54:17 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-11-28 16:01:23 -0500
commit00ab7790ce6057390c9c5eb25380051c15610637 (patch)
tree6ab1ee92c70ca678d80bd2d5109e271a68b7ae40
parentec393a3009f89439373486c480a8592595b7c06c (diff)
downloadglib-00ab7790ce6057390c9c5eb25380051c15610637.tar.gz
Improve GNotification test coverage
-rw-r--r--gio/tests/gnotification.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/gio/tests/gnotification.c b/gio/tests/gnotification.c
index 2db78e347..b224661f0 100644
--- a/gio/tests/gnotification.c
+++ b/gio/tests/gnotification.c
@@ -153,11 +153,74 @@ basic (void)
session_bus_stop ();
}
+struct _GNotification
+{
+ GObject parent;
+
+ gchar *title;
+ gchar *body;
+ GIcon *icon;
+ gboolean urgent;
+ GPtrArray *buttons;
+ gchar *default_action;
+ GVariant *default_action_target;
+};
+
+typedef struct
+{
+ gchar *label;
+ gchar *action_name;
+ GVariant *target;
+} Button;
+
+static void
+test_properties (void)
+{
+ GNotification *n;
+ struct _GNotification *rn;
+ GIcon *icon;
+ const gchar * const *names;
+ Button *b;
+
+ n = g_notification_new ("Test");
+
+ g_notification_set_title (n, "title");
+ g_notification_set_body (n, "body");
+ icon = g_themed_icon_new ("i-c-o-n");
+ g_notification_set_icon (n, icon);
+ g_object_unref (icon);
+ g_notification_set_urgent (n, TRUE);
+ g_notification_add_button (n, "label1", "app.action1::target1");
+ g_notification_set_default_action (n, "app.action2::target2");
+
+ rn = (struct _GNotification *)n;
+
+ g_assert_cmpstr (rn->title, ==, "title");
+ g_assert_cmpstr (rn->body, ==, "body");
+ g_assert (G_IS_THEMED_ICON (rn->icon));
+ names = g_themed_icon_get_names (G_THEMED_ICON (rn->icon));
+ g_assert_cmpstr (names[0], ==, "i-c-o-n");
+ g_assert (names[1] == NULL);
+ g_assert (rn->urgent);
+
+ g_assert_cmpint (rn->buttons->len, ==, 1);
+ b = (Button*)rn->buttons->pdata[0];
+ g_assert_cmpstr (b->label, ==, "label1");
+ g_assert_cmpstr (b->action_name, ==, "app.action1");
+ g_assert_cmpstr (g_variant_get_string (b->target, NULL), ==, "target1");
+
+ g_assert_cmpstr (rn->default_action, ==, "app.action2");
+ g_assert_cmpstr (g_variant_get_string (rn->default_action_target, NULL), ==, "target2");
+
+ g_object_unref (n);
+}
+
int main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/gnotification/basic", basic);
+ g_test_add_func ("/gnotification/properties", test_properties);
return g_test_run ();
}