Fix dom/battery test to handle running on either battery or AC power

RESOLVED FIXED in Firefox 23

Status

()

defect
P3
normal
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: cpeterson, Assigned: cpeterson)

Tracking

unspecified
mozilla23
x86
macOS
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox22 affected, firefox23 fixed)

Details

Attachments

(1 attachment)

When I run `mach mochitest-plain dom/battery` on my MacBook Pro, I get multiple test failures. The battery test assumes the navigator.battery values are all default values, not real-world values.

* When my MacBook Pro is running on battery power, I see these test failures:

3 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default battery level should be 1.0 - got 0.76, expected 1
4 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default charging value should be true - got false, expected true
5 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default dischargingTime should be Inifinity - got 14580, expected Infinity
6 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default chargingTime should be 0 - got Infinity, expected 0

* When my MacBook Pro is running on AC power, I see these test failures:

3 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default battery level should be 1.0 - got 0.77, expected 1
4 INFO TEST-PASS | /tests/dom/battery/test/test_battery_basics.html | Default charging value should be true
5 INFO TEST-PASS | /tests/dom/battery/test/test_battery_basics.html | Default dischargingTime should be Inifinity
6 ERROR TEST-UNEXPECTED-FAIL | /tests/dom/battery/test/test_battery_basics.html | Default chargingTime should be 0 - got 3780, expected 0
Attachment #732195 - Flags: review?(mounir)
Comment on attachment 732195 [details] [diff] [review]
fix-battery-test.patch

Review of attachment 732195 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/battery/test/test_battery_basics.html
@@ +23,5 @@
> +  ok(battery.chargingTime >= 0, "Battery chargingTime " + battery.chargingTime + " should be nonnegative or Infinity when charging");
> +  is(battery.dischargingTime, Infinity, "Battery dischargingTime should be Infinity when charging");
> +} else {
> +  is(battery.chargingTime, Infinity, "Battery chargingTime should be Infinity when discharging");
> +  ok(battery.dischargingTime >= 0, "Battery dischargingTime " + battery.dischargingTime + " should be nonnegative or Infinity when discharging");

> 0, dischargingTime can't be 0.
Attachment #732195 - Flags: review?(mounir) → review+
I updated the dischargingTime test to check for a positive number.

https://hg.mozilla.org/integration/mozilla-inbound/rev/7b779e6bb46c
https://hg.mozilla.org/mozilla-central/rev/7b779e6bb46c
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
You need to log in before you can comment on or make changes to this bug.