aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/test-dbus-listener.cc73
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b61bbe0..b6b543b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,12 @@ test_device_SOURCES = test-device.cc
test_device_LDADD = $(TEST_LIBS)
test_device_CPPFLAGS = $(TEST_CPPFLAGS)
+TESTS += test-dbus-listener
+check_PROGRAMS += test-dbus-listener
+test_dbus_listener_SOURCES = test-dbus-listener.cc
+test_dbus_listener_LDADD = $(TEST_LIBS)
+test_dbus_listener_CPPFLAGS = $(TEST_CPPFLAGS)
+
TESTS += test-indicator
check_PROGRAMS += test-indicator
test_indicator_SOURCES = test-indicator.cc
diff --git a/tests/test-dbus-listener.cc b/tests/test-dbus-listener.cc
new file mode 100644
index 0000000..869d08a
--- /dev/null
+++ b/tests/test-dbus-listener.cc
@@ -0,0 +1,73 @@
+/*
+Copyright 2012 Canonical Ltd.
+
+Authors:
+ Charles Kerr <charles.kerr@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <gtest/gtest.h>
+
+#include "dbus-listener.h"
+#include "device.h"
+
+/***
+****
+***/
+
+namespace
+{
+ void ensure_glib_initialized ()
+ {
+ static bool initialized = false;
+
+ if (G_UNLIKELY(!initialized))
+ {
+ initialized = true;
+ g_type_init();
+ }
+ }
+}
+
+/***
+****
+***/
+
+class DbusListenerTest : public ::testing::Test
+{
+ protected:
+
+ virtual void SetUp()
+ {
+ ensure_glib_initialized ();
+ }
+
+ virtual void TearDown()
+ {
+ }
+};
+
+/***
+****
+***/
+
+TEST_F(DbusListenerTest, GObjectNew)
+{
+ GObject * o = G_OBJECT (g_object_new (INDICATOR_POWER_DBUS_LISTENER_TYPE, NULL));
+ ASSERT_TRUE (o != NULL);
+ ASSERT_TRUE (INDICATOR_IS_POWER_DBUS_LISTENER(o));
+ g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls
+ g_object_unref (o);
+}
+