aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/name-watch-test.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/name-watch-test.cc b/tests/name-watch-test.cc
index 66daadc..737915e 100644
--- a/tests/name-watch-test.cc
+++ b/tests/name-watch-test.cc
@@ -84,3 +84,45 @@ TEST_F(NameWatchTest, BaseWatch)
bus_unwatch_namespace(ns_watch);
}
+
+TEST_F(NameWatchTest, NonMatches)
+{
+ callback_count_t callback_count = {0};
+
+ guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
+ "com.foo",
+ appeared_simple_cb,
+ vanished_simple_cb,
+ &callback_count,
+ NULL);
+
+ guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foobar.bar",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
+ guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.bar.com.foo",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
+
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+
+
+ ASSERT_EQ(callback_count.appeared, 0);
+
+ g_bus_unown_name(name1);
+ g_bus_unown_name(name2);
+
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+
+ ASSERT_EQ(callback_count.vanished, 0);
+
+ bus_unwatch_namespace(ns_watch);
+}