diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-05-27 08:35:52 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-05-27 08:35:52 -0500 |
commit | 675cc7955e0e8834a3ea4bb46fb347bb744f24a7 (patch) | |
tree | 17944958d08392202b1f54eefd340e11f7757ed0 | |
parent | 2f1281d4faa6bed2a0be484bd722504df290880c (diff) | |
download | ayatana-indicator-power-675cc7955e0e8834a3ea4bb46fb347bb744f24a7.tar.gz ayatana-indicator-power-675cc7955e0e8834a3ea4bb46fb347bb744f24a7.tar.bz2 ayatana-indicator-power-675cc7955e0e8834a3ea4bb46fb347bb744f24a7.zip |
Add skeleton test for IndicatorPowerDbusListener
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rw-r--r-- | tests/test-dbus-listener.cc | 73 |
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); +} + |