aboutsummaryrefslogtreecommitdiff
path: root/tests/name-watch-test.cc
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2013-11-15 22:11:57 -0600
committerTed Gould <ted@gould.cx>2013-11-15 22:11:57 -0600
commit30e3f1f9d404c77ee32d2e004c2c9327192f5872 (patch)
tree485aab0f1d667ec87e21b59d2a079f235e25e60e /tests/name-watch-test.cc
parent436a5a3a347b7c0946e5e53f721f0f7d2fd53062 (diff)
downloadayatana-indicator-sound-30e3f1f9d404c77ee32d2e004c2c9327192f5872.tar.gz
ayatana-indicator-sound-30e3f1f9d404c77ee32d2e004c2c9327192f5872.tar.bz2
ayatana-indicator-sound-30e3f1f9d404c77ee32d2e004c2c9327192f5872.zip
Okay, no we're testing something!
Diffstat (limited to 'tests/name-watch-test.cc')
-rw-r--r--tests/name-watch-test.cc44
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/name-watch-test.cc b/tests/name-watch-test.cc
index b5a1db3..64f681d 100644
--- a/tests/name-watch-test.cc
+++ b/tests/name-watch-test.cc
@@ -2,20 +2,58 @@
#include <gio/gio.h>
#include <gtest/gtest.h>
+extern "C" {
+#include "bus-watch-namespace.h"
+}
+
class NameWatchTest : public ::testing::Test
{
+ private:
+ GTestDBus * testbus = NULL;
+
protected:
virtual void SetUp() {
-
+ testbus = g_test_dbus_new(G_TEST_DBUS_NONE);
+ g_test_dbus_up(testbus);
}
virtual void TearDown() {
-
+ g_test_dbus_down(testbus);
+ g_clear_object(&testbus);
}
};
-TEST_F(NameWatchTest, DummyTest)
+typedef struct {
+ guint appeared;
+ guint vanished;
+} callback_count_t;
+
+static void
+appeared_simple_cb (GDBusConnection * bus, const gchar * name, const gchar * owner, gpointer user_data)
+{
+ callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
+ callback_count->appeared++;
+}
+
+static void
+vanished_simple_cb (GDBusConnection * bus, const gchar * name, gpointer user_data)
{
+ callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
+ callback_count->vanished++;
+}
+
+
+TEST_F(NameWatchTest, BaseWatch)
+{
+ 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);
+ bus_unwatch_namespace(ns_watch);
}