From 62a83e183ee9c74f17439e730a02f7c1929fbbc7 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sat, 15 Dec 2018 20:22:18 +0100 Subject: [PATCH] Test urgency hints in DBus --- test/dbus.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/dbus.c b/test/dbus.c index 2e9b9b1..31b5628 100644 --- a/test/dbus.c +++ b/test/dbus.c @@ -454,6 +454,51 @@ TEST test_hint_category(void) PASS(); } +TEST test_hint_urgency(void) +{ + static char msg[50]; + struct notification *n; + struct dbus_notification *n_dbus; + + gsize len = queues_length_waiting(); + + n_dbus = dbus_notification_new(); + n_dbus->app_name = "dunstteststack"; + n_dbus->app_icon = "NONE"; + n_dbus->summary = "test_hint_urgency"; + n_dbus->body = "Summary of it"; + + enum urgency values[] = { URG_MAX, URG_LOW, URG_NORM, URG_CRIT }; + GVariant *variants[] = { + g_variant_new_byte(10), + g_variant_new_byte(0), + g_variant_new_byte(1), + g_variant_new_byte(2), + }; + for (size_t i = 0; i < G_N_ELEMENTS(variants); i++) { + g_hash_table_insert(n_dbus->hints, + g_strdup("urgency"), + g_variant_ref_sink(variants[i])); + + guint id; + ASSERT(dbus_notification_fire(n_dbus, &id)); + ASSERT(id != 0); + + ASSERT_EQ(queues_length_waiting(), len+1); + + n = queues_debug_find_notification_by_id(id); + + snprintf(msg, sizeof(msg), "In round %ld", i); + ASSERT_EQm(msg, values[i], n->urgency); + + queues_notification_close_id(id, REASON_UNDEF); + } + + dbus_notification_free(n_dbus); + + PASS(); +} + TEST test_server_caps(enum markup_mode markup) { GVariant *reply; @@ -572,6 +617,7 @@ gpointer run_threaded_tests(gpointer data) RUN_TEST(test_hint_progress); RUN_TEST(test_hint_icons); RUN_TEST(test_hint_category); + RUN_TEST(test_hint_urgency); RUN_TEST(test_dbus_notify_colors); RUN_TESTp(test_server_caps, MARKUP_FULL); RUN_TESTp(test_server_caps, MARKUP_STRIP);