From 676aef0608d08a7d2086742e0dbd6b05e2d548bd Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 26 May 2012 14:16:26 -0500 Subject: first draft of adding tests for a discharging battery --- tests/test-indicator.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/test-indicator.cc') diff --git a/tests/test-indicator.cc b/tests/test-indicator.cc index c3f502a..4b39579 100644 --- a/tests/test-indicator.cc +++ b/tests/test-indicator.cc @@ -98,3 +98,38 @@ TEST_F(IndicatorTest, SetDevices) g_object_unref (power); } + +TEST_F(IndicatorTest, DischargingStrings) +{ + IndicatorPower * power = INDICATOR_POWER(g_object_new (INDICATOR_POWER_TYPE, NULL)); + + // give the indicator a discharging battery with 1 hour of life left + g_object_set (battery_device, + INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING, + INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, + INDICATOR_POWER_DEVICE_TIME, guint64(60*60), + NULL); + indicator_power_set_devices (power, &battery_device, 1); + + GList * entries = indicator_object_get_entries (INDICATOR_OBJECT(power)); + ASSERT_EQ (g_list_length(entries), 1); + IndicatorObjectEntry * entry = static_cast(entries->data); + ASSERT_STREQ(entry->accessible_desc, "Battery (1 hour left (50%))"); + ASSERT_STREQ(entry->name_hint, "indicator-power"); + g_list_free (entries); + + // give the indicator a discharging battery with over 12 hours of life left + g_object_set (battery_device, + INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING, + INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, + INDICATOR_POWER_DEVICE_TIME, guint64(60*60*12 + 1), + NULL); + indicator_power_set_devices (power, &battery_device, 1); + entries = indicator_object_get_entries (INDICATOR_OBJECT(power)); + ASSERT_EQ (g_list_length(entries), 1); + entry = static_cast(entries->data); + g_list_free (entries); + + // cleanup + g_object_unref (power); +} -- cgit v1.2.3