aboutsummaryrefslogtreecommitdiff
path: root/tests/test-indicator.cc
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-05-26 14:16:26 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-05-26 14:16:26 -0500
commit676aef0608d08a7d2086742e0dbd6b05e2d548bd (patch)
tree488e5d9db02da0a0d4aff67bed8bce0c1a485620 /tests/test-indicator.cc
parent7ac2b78246e26f354453935301ed322eb6870c3a (diff)
downloadayatana-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
Diffstat (limited to 'tests/test-indicator.cc')
-rw-r--r--tests/test-indicator.cc35
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);
+}