4 <script src=
"../resources/js-test.js"></script>
6 description("Test to ensure level is reported with restricted precision.");
8 if (!window
.testRunner
)
9 debug('This test cannot be run without the TestRunner');
11 // Clean-up any unused battery manager objects from previous tests.
14 testRunner
.waitUntilDone();
16 var levelFullPrecision
= 0.556789;
17 var levelRounded
= 0.56;
19 function setAndFireMockBatteryInfo(charging
, chargingTime
, dischargingTime
, level
) {
20 testRunner
.didChangeBatteryStatus(charging
, chargingTime
, dischargingTime
, level
);
24 function batteryStatusSuccess(batteryManager
) {
25 debug('batteryStatusSuccess invoked');
26 battery
= batteryManager
;
27 shouldBe('battery.level', 'levelRounded');
28 setTimeout(finishJSTest
, 0);
31 function batteryStatusFailure() {
32 testFailed('failed to successfully resolve the promise');
33 setTimeout(finishJSTest
, 0);
36 navigator
.getBattery().then(batteryStatusSuccess
, batteryStatusFailure
);
37 setAndFireMockBatteryInfo(false, 10, 20, levelFullPrecision
);