2014-09-04 11:48:31 +00:00
|
|
|
<!DOCTYPE html>
|
2015-02-18 14:12:05 +00:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Battery Test: no backend implementation, charger unplugged in</title>
|
|
|
|
<meta name="flags" content="interact">
|
|
|
|
<script src="/resources/testharness.js"></script>
|
|
|
|
<script src="/resources/testharnessreport.js"></script>
|
2014-09-04 11:48:31 +00:00
|
|
|
|
2015-02-18 14:12:05 +00:00
|
|
|
<h2>Description</h2>
|
|
|
|
<p>
|
|
|
|
<strong>
|
|
|
|
This test is only useful on devices that expose the BatteryManager interface,
|
|
|
|
but lack a backend implementation.
|
|
|
|
</strong>
|
|
|
|
</p>
|
|
|
|
<p>
|
2015-03-23 08:51:34 +00:00
|
|
|
This test validates that all of the BatteryManager attributes exist and are set to their default values.
|
2015-02-18 14:12:05 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<h2>Preconditions</h2>
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
|
|
The implementation is unable to report the battery's charging state,
|
|
|
|
charging time, level or remaining time respectively.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
The device is unplugged from the charger before this test case is run.
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<div id="log"></div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
async_test(function (t) {
|
|
|
|
navigator.getBattery().then(function (battery) {
|
|
|
|
t.step(function () {
|
|
|
|
assert_true(battery.charging, 'charging must be set to true');
|
|
|
|
assert_equals(battery.chargingTime, 0, 'chargingTime must be set to 0');
|
|
|
|
assert_equals(battery.dischargingTime, Infinity, 'dischargingTime must be set to Infinity');
|
|
|
|
assert_equals(battery.level, 1.0, 'level must be set to 1.0');
|
|
|
|
});
|
|
|
|
t.done();
|
|
|
|
}, function (error) {
|
|
|
|
t.step(function () {
|
|
|
|
assert_unreached(error.message);
|
|
|
|
});
|
|
|
|
t.done();
|
|
|
|
});
|
|
|
|
}, 'When a BatteryManager object is created, charging must be set to true, ' +
|
|
|
|
'chargingTime to 0, level to 1.0 and dischargingTime to the value positive ' +
|
|
|
|
'Infinity, if the implementation is unable to report the battery\'s charging ' +
|
|
|
|
'state, charging time, level or remaining time respectively.');
|
|
|
|
|
|
|
|
</script>
|