blob: f335f42326d372e5a5c65f9ea3340149898488e6 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>Battery Test: battery neither empty or full, charger unplugged in</title>
<meta name="flags" content="interact">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
This test validates that all of the BatteryManager attributes exist and are set to their correct values when battery is discharging.
The device is unplugged from the charger before this test is run.
The battery must neither be empty or full, nor reach empty or full capacity during the test.
Waiting for battery level change to fire levelchange event, maybe need a long time
setup({ explicit_timeout: true });
async_test(function (t) {
navigator.getBattery().then(function (battery) {
t.step(function () {
assert_false(battery.charging, 'charging must be set to false');
assert_equals(battery.chargingTime, Infinity, 'chargingTime must be set to Infinity');
assert_less_than(battery.dischargingTime, Infinity, 'dischargingTime must be less than Infinity');
assert_greater_than(battery.level, 0, 'level must be greater than 0');
assert_less_than(battery.level, 1.0, 'level must be less than 1.0');
var battery_level = battery.level;
battery.onlevelchange = t.step_func(function () {
assert_less_than(battery.level, battery_level, 'The value of the level attribute must decrease');
}, function (error) {
t.step(function () {
}, document.title);