From e555496b6486982a75429af159c6ecd556944ff6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 6 Nov 2012 13:42:53 -0600 Subject: add unit test (currently failing) to test for the bug reported in LP bug #1075192 --- tests/test-device.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'tests') 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