From 675cc7955e0e8834a3ea4bb46fb347bb744f24a7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 27 May 2012 08:35:52 -0500 Subject: Add skeleton test for IndicatorPowerDbusListener --- tests/Makefile.am | 6 ++++ tests/test-dbus-listener.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/test-dbus-listener.cc (limited to 'tests') 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 + +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 . +*/ + +#include + +#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); +} + -- cgit v1.2.3