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 Date: Tue, 6 Nov 2012 14:54:57 -0600 Subject: in TestDevice.ChoosePrimary, add another test (currently failing) to confirm that when indicator-datetime is choosing from devices that are neither charging nor discharging, batteries are more interesting than other devices, and other devices are more interesting than UP_DEVICE_KIND_LINE_POWER --- tests/test-device.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test-device.cc b/tests/test-device.cc index 16194c9..27cbf35 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -601,6 +601,7 @@ TEST_F(DeviceTest, ChoosePrimary) { 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_KEYBOARD, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 }, { UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 } }; -- cgit v1.2.3 From a499914c45cf4bf2208c857f54783cfcd48c1427 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 7 Nov 2012 11:25:41 -0600 Subject: modify DeviceTest.Labels s.t. it fails (currently failing) if the 'short' string for an AC Adapter is nonempty. --- tests/test-device.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-device.cc b/tests/test-device.cc index 27cbf35..021404f 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -555,7 +555,7 @@ TEST_F(DeviceTest, Labels) INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0, INDICATOR_POWER_DEVICE_TIME, guint64(0), NULL); - check_strings (device, "AC Adapter", "AC Adapter", "AC Adapter"); + check_strings (device, "", "AC Adapter", "AC Adapter"); // cleanup g_object_unref(o); -- cgit v1.2.3