From 34c756aa7a894ee9c12f3dce0b4ae6e4ac6a30a8 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 25 May 2012 14:58:56 -0500 Subject: modify IndicatorPower to use IndicatorPowerDevices internally --- tests/test-indicator.cc | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'tests/test-indicator.cc') diff --git a/tests/test-indicator.cc b/tests/test-indicator.cc index af494ee..3e9d97b 100644 --- a/tests/test-indicator.cc +++ b/tests/test-indicator.cc @@ -48,15 +48,32 @@ class IndicatorTest : public ::testing::Test { protected: + IndicatorPowerDevice * ac_device; + IndicatorPowerDevice * battery_device; + virtual void SetUp() { ensure_glib_initialized (); + g_setenv( "GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE); - g_message ("GSETTINGS_SCHEMA_DIR is %s", g_getenv("GSETTINGS_SCHEMA_DIR")); + + ac_device = indicator_power_device_new ( + "/org/freedesktop/UPower/devices/line_power_AC", + UP_DEVICE_KIND_LINE_POWER, + ". GThemedIcon ac-adapter-symbolic ac-adapter ", + 0.0, UP_DEVICE_STATE_UNKNOWN, 0); + + battery_device = indicator_power_device_new ( + "/org/freedesktop/UPower/devices/battery_BAT0", + UP_DEVICE_KIND_BATTERY, + ". GThemedIcon battery-good-symbolic gpm-battery-060 battery-good ", + 52.871712, UP_DEVICE_STATE_DISCHARGING, 8834); } virtual void TearDown() { + g_clear_object (&battery_device); + g_clear_object (&ac_device); } }; @@ -66,10 +83,18 @@ class IndicatorTest : public ::testing::Test TEST_F(IndicatorTest, GObjectNew) { - ensure_glib_initialized (); - GObject * o = G_OBJECT (g_object_new (INDICATOR_POWER_TYPE, NULL)); ASSERT_TRUE (o != NULL); ASSERT_TRUE (IS_INDICATOR_POWER(o)); g_object_unref (o); } + +TEST_F(IndicatorTest, SetDevices) +{ + IndicatorPower * power = INDICATOR_POWER(g_object_new (INDICATOR_POWER_TYPE, NULL)); + IndicatorPowerDevice * devices[] = { ac_device, battery_device }; + + indicator_power_set_devices (power, devices, G_N_ELEMENTS(devices)); + + g_object_unref (power); +} -- cgit v1.2.3