diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-10-26 18:03:46 +0200 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-10-26 18:03:46 +0200 |
commit | cd8e633cc850d0c9f1bc16533d5962cdfda16856 (patch) | |
tree | 59bc14cc255fa5ac7b0bc8b93fc97c060dcc9d2b | |
parent | 6d19670d7d438f2c58c9d819e87b72060af16bc5 (diff) | |
download | ayatana-indicator-power-cd8e633cc850d0c9f1bc16533d5962cdfda16856.tar.gz ayatana-indicator-power-cd8e633cc850d0c9f1bc16533d5962cdfda16856.tar.bz2 ayatana-indicator-power-cd8e633cc850d0c9f1bc16533d5962cdfda16856.zip |
add test (currently failing) to detect the logic error reported in bug #1071757
-rw-r--r-- | tests/test-device.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test-device.cc b/tests/test-device.cc index 88c43fc..b5fa466 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -602,6 +602,22 @@ TEST_F(DeviceTest, ChoosePrimary) set_device_charge_state (b, UP_DEVICE_STATE_CHARGING, 50, 49.0); ASSERT_EQ (b, indicator_power_choose_primary_device(devices)); + /* discharging always comes before charging */ + set_device_charge_state (a, UP_DEVICE_STATE_DISCHARGING, 50, 50.0); + set_device_charge_state (b, UP_DEVICE_STATE_CHARGING, 50, 50.0); + ASSERT_EQ (a, indicator_power_choose_primary_device(devices)); + set_device_charge_state (a, UP_DEVICE_STATE_CHARGING, 50, 50.0); + set_device_charge_state (b, UP_DEVICE_STATE_DISCHARGING, 50, 50.0); + ASSERT_EQ (b, indicator_power_choose_primary_device(devices)); + + /* charging always comes before charged */ + set_device_charge_state (a, UP_DEVICE_STATE_CHARGING, 50, 50.0); + set_device_charge_state (b, UP_DEVICE_STATE_FULLY_CHARGED, 50, 50.0); + ASSERT_EQ (a, indicator_power_choose_primary_device(devices)); + set_device_charge_state (a, UP_DEVICE_STATE_FULLY_CHARGED, 50, 50.0); + set_device_charge_state (b, UP_DEVICE_STATE_CHARGING, 50, 50.0); + ASSERT_EQ (b, indicator_power_choose_primary_device(devices)); + // cleanup g_slist_free_full (devices, g_object_unref); } |