diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-05-26 14:16:26 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-05-26 14:16:26 -0500 |
commit | 676aef0608d08a7d2086742e0dbd6b05e2d548bd (patch) | |
tree | 488e5d9db02da0a0d4aff67bed8bce0c1a485620 | |
parent | 7ac2b78246e26f354453935301ed322eb6870c3a (diff) | |
download | ayatana-indicator-power-676aef0608d08a7d2086742e0dbd6b05e2d548bd.tar.gz ayatana-indicator-power-676aef0608d08a7d2086742e0dbd6b05e2d548bd.tar.bz2 ayatana-indicator-power-676aef0608d08a7d2086742e0dbd6b05e2d548bd.zip |
first draft of adding tests for a discharging battery
-rw-r--r-- | tests/test-indicator.cc | 35 |
1 files changed, 35 insertions, 0 deletions
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<IndicatorObjectEntry*>(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<IndicatorObjectEntry*>(entries->data); + g_list_free (entries); + + // cleanup + g_object_unref (power); +} |