aboutsummaryrefslogtreecommitdiff
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
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!
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/name-watch-test.cc44
2 files changed, 44 insertions, 5 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1e5448d..8e79fd0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,7 +15,8 @@ target_link_libraries(gtest ${GTEST_LIBS})
# Name Watch Test
###########################
-add_executable (name-watch-test name-watch-test.cc)
-target_link_libraries (name-watch-test gtest ${GIO2_LIBRARIES})
+include_directories(${CMAKE_SOURCE_DIR}/src)
+add_executable (name-watch-test name-watch-test.cc ${CMAKE_SOURCE_DIR}/src/bus-watch-namespace.c)
+target_link_libraries (name-watch-test gtest ${SOUNDSERVICE_LIBRARIES})
add_test(name-watch-test name-watch-test)
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);
}