aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-11-06 13:42:53 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-11-06 13:42:53 -0600
commite555496b6486982a75429af159c6ecd556944ff6 (patch)
tree1b38c11bc61dd33195f5970b95e6c5f6719b9c89
parent1e5b83de6bb681307aababbbdc1492e53885b843 (diff)
downloadayatana-indicator-power-e555496b6486982a75429af159c6ecd556944ff6.tar.gz
ayatana-indicator-power-e555496b6486982a75429af159c6ecd556944ff6.tar.bz2
ayatana-indicator-power-e555496b6486982a75429af159c6ecd556944ff6.zip
add unit test (currently failing) to test for the bug reported in LP bug #1075192
-rw-r--r--tests/test-device.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/test-device.cc b/tests/test-device.cc
index 18bdc08..16194c9 100644
--- a/tests/test-device.cc
+++ b/tests/test-device.cc
@@ -587,19 +587,21 @@ TEST_F(DeviceTest, ChoosePrimary)
sorted in order of preference wrt the spec's criteria.
So tests[i] should be picked over any test with an index greater than i */
struct {
+ int kind;
int state;
guint64 time;
double percentage;
} tests[] = {
- { UP_DEVICE_STATE_DISCHARGING, 49, 50.0 },
- { UP_DEVICE_STATE_DISCHARGING, 50, 50.0 },
- { UP_DEVICE_STATE_DISCHARGING, 50, 100.0 },
- { UP_DEVICE_STATE_DISCHARGING, 51, 50.0 },
- { UP_DEVICE_STATE_CHARGING, 50, 50.0 },
- { UP_DEVICE_STATE_CHARGING, 49, 50.0 },
- { UP_DEVICE_STATE_CHARGING, 49, 100.0 },
- { UP_DEVICE_STATE_CHARGING, 48, 50.0 },
- { UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 }
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 49, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 100.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 51, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 50, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 100.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 48, 50.0 },
+ { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 },
+ { UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 }
};
device_list = NULL;
@@ -610,11 +612,13 @@ TEST_F(DeviceTest, ChoosePrimary)
{
for (int j=i+1; j<n; j++)
{
- g_object_set (a, INDICATOR_POWER_DEVICE_STATE, tests[i].state,
+ g_object_set (a, INDICATOR_POWER_DEVICE_KIND, tests[i].kind,
+ INDICATOR_POWER_DEVICE_STATE, tests[i].state,
INDICATOR_POWER_DEVICE_TIME, guint64(tests[i].time),
INDICATOR_POWER_DEVICE_PERCENTAGE, tests[i].percentage,
NULL);
- g_object_set (b, INDICATOR_POWER_DEVICE_STATE, tests[j].state,
+ g_object_set (b, INDICATOR_POWER_DEVICE_KIND, tests[j].kind,
+ INDICATOR_POWER_DEVICE_STATE, tests[j].state,
INDICATOR_POWER_DEVICE_TIME, guint64(tests[j].time),
INDICATOR_POWER_DEVICE_PERCENTAGE, tests[j].percentage,
NULL);