aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2013-11-15 22:31:55 -0600
committerTed Gould <ted@gould.cx>2013-11-15 22:31:55 -0600
commit6b8b48fe7e5749cb3142e57f2ea544046703bff6 (patch)
tree4adfbf85ad7b4e849d623bb8661ecb50f32dfd7f
parent7a5f01039d308695e4f5faf347912c443d5ca26c (diff)
downloadayatana-indicator-sound-6b8b48fe7e5749cb3142e57f2ea544046703bff6.tar.gz
ayatana-indicator-sound-6b8b48fe7e5749cb3142e57f2ea544046703bff6.tar.bz2
ayatana-indicator-sound-6b8b48fe7e5749cb3142e57f2ea544046703bff6.zip
Adding a test to make sure we get names if they existed before we did
-rw-r--r--tests/name-watch-test.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/name-watch-test.cc b/tests/name-watch-test.cc
index 737915e..c9737ec 100644
--- a/tests/name-watch-test.cc
+++ b/tests/name-watch-test.cc
@@ -126,3 +126,47 @@ TEST_F(NameWatchTest, NonMatches)
bus_unwatch_namespace(ns_watch);
}
+
+TEST_F(NameWatchTest, StartupNames)
+{
+ guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foo.bar",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
+
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+
+ 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);
+
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+ 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, 1);
+
+ g_bus_unown_name(name1);
+
+ g_usleep(100000);
+ while (g_main_pending())
+ g_main_iteration(TRUE);
+
+ ASSERT_EQ(callback_count.vanished, 1);
+
+ bus_unwatch_namespace(ns_watch);
+}
+