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/test-dbus-listener.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/test-dbus-listener.cc (limited to 'tests/test-dbus-listener.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