diff options
| -rw-r--r-- | src/print_battery_info.c | 8 | ||||
| -rw-r--r-- | testcases/018-battery-capacity/1/uevent | 2 | ||||
| -rw-r--r-- | testcases/018-battery-capacity/expected_output.txt | 1 | ||||
| -rw-r--r-- | testcases/018-battery-capacity/i3status.conf | 10 | ||||
| -rw-r--r-- | testcases/019-battery-capacity/1/uevent | 2 | ||||
| -rw-r--r-- | testcases/019-battery-capacity/expected_output.txt | 1 | ||||
| -rw-r--r-- | testcases/019-battery-capacity/i3status.conf | 11 | 
7 files changed, 31 insertions, 4 deletions
| diff --git a/src/print_battery_info.c b/src/print_battery_info.c index e22ca3e..7a462f7 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -513,13 +513,13 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char      // We prefer the design capacity, but use the last capacity if we don't have it,      // or if we are asked to (last_full_capacity == true); but similarly we use      // the design capacity if we don't have the last capacity. -    // If we don't have either then both full_design and full_last < 0, -    // which implies full < 0, which bails out on the following line. +    // If we don't have either then both full_design and full_last <= 0, +    // which implies full <= 0, which bails out on the following line.      int full = batt_info.full_design; -    if (full < 0 || (last_full_capacity && batt_info.full_last >= 0)) { +    if (full <= 0 || (last_full_capacity && batt_info.full_last > 0)) {          full = batt_info.full_last;      } -    if (full < 0 && batt_info.remaining < 0 && batt_info.percentage_remaining < 0) { +    if (full <= 0 && batt_info.remaining < 0 && batt_info.percentage_remaining < 0) {          /* We have no physical measurements and no estimates. Nothing           * much we can report, then. */          OUTPUT_FULL_TEXT(format_down); diff --git a/testcases/018-battery-capacity/1/uevent b/testcases/018-battery-capacity/1/uevent new file mode 100644 index 0000000..00b1148 --- /dev/null +++ b/testcases/018-battery-capacity/1/uevent @@ -0,0 +1,2 @@ +POWER_SUPPLY_CHARGE_FULL=100 +POWER_SUPPLY_CHARGE_NOW=50 diff --git a/testcases/018-battery-capacity/expected_output.txt b/testcases/018-battery-capacity/expected_output.txt new file mode 100644 index 0000000..ab07d0a --- /dev/null +++ b/testcases/018-battery-capacity/expected_output.txt @@ -0,0 +1 @@ +50.00% diff --git a/testcases/018-battery-capacity/i3status.conf b/testcases/018-battery-capacity/i3status.conf new file mode 100644 index 0000000..7a3443c --- /dev/null +++ b/testcases/018-battery-capacity/i3status.conf @@ -0,0 +1,10 @@ +general { +        output_format = "none" +} + +order += "battery all" + +battery all { +        format = "%percentage" +        path = "testcases/018-battery-capacity/%d/uevent" +} diff --git a/testcases/019-battery-capacity/1/uevent b/testcases/019-battery-capacity/1/uevent new file mode 100644 index 0000000..d004bf1 --- /dev/null +++ b/testcases/019-battery-capacity/1/uevent @@ -0,0 +1,2 @@ +POWER_SUPPLY_CHARGE_FULL_DESIGN=100 +POWER_SUPPLY_CHARGE_NOW=50 diff --git a/testcases/019-battery-capacity/expected_output.txt b/testcases/019-battery-capacity/expected_output.txt new file mode 100644 index 0000000..ab07d0a --- /dev/null +++ b/testcases/019-battery-capacity/expected_output.txt @@ -0,0 +1 @@ +50.00% diff --git a/testcases/019-battery-capacity/i3status.conf b/testcases/019-battery-capacity/i3status.conf new file mode 100644 index 0000000..8152d44 --- /dev/null +++ b/testcases/019-battery-capacity/i3status.conf @@ -0,0 +1,11 @@ +general { +        output_format = "none" +} + +order += "battery all" + +battery all { +        format = "%percentage" +        path = "testcases/019-battery-capacity/%d/uevent" +        last_full_capacity = true +} | 
