You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/05/28 02:53:26 UTC
spec commit: CB-6721 - fix battery.spec.5 failure
Repository: cordova-mobile-spec
Updated Branches:
refs/heads/master 2ef51edfd -> 139011c4b
CB-6721 - fix battery.spec.5 failure
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/139011c4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/139011c4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/139011c4
Branch: refs/heads/master
Commit: 139011c4b33a6fdc8d461197ae99088f1e5a821e
Parents: 2ef51ed
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 27 17:53:19 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 27 17:53:19 2014 -0700
----------------------------------------------------------------------
autotest/tests/battery.tests.js | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/139011c4/autotest/tests/battery.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/battery.tests.js b/autotest/tests/battery.tests.js
index dc9f77e..11c159b 100644
--- a/autotest/tests/battery.tests.js
+++ b/autotest/tests/battery.tests.js
@@ -124,20 +124,31 @@ describe('Battery (navigator.battery)', function () {
});
it("battery.spec.5 should NOT fire events when charging or level is increasing", function () {
- // batterycritical should not fire when level increases to 5 ( CB-4519 )
- var onEvent;
- runs(function () {
+ var onEvent;
+ // setup: batterycritical should fire when level decreases (100->4) ( CB-4519 )
+ runs(function () {
+ onEvent = jasmine.createSpy("onbatterycritical");
+ navigator.battery._status({ level: 100, isPlugged: false });
+ window.addEventListener("batterycritical", onEvent, false);
+ navigator.battery._status({ level: 4, isPlugged: false });
+ });
+ waits(100);
+ runs(function () {
+ expect(onEvent).toHaveBeenCalled();
+ });
+
+ // batterycritical should not fire when level increases (4->5)( CB-4519 )
+ runs(function () {
onEvent = jasmine.createSpy("onbatterycritical");
navigator.battery._status({ level: 4, isPlugged: false });
window.addEventListener("batterycritical", onEvent, false);
navigator.battery._status({ level: 5, isPlugged: false });
- });
- waits(100);
- runs(function () {
+ });
+ waits(100);
+ runs(function () {
expect(onEvent).not.toHaveBeenCalled();
- });
-
- // batterylow should not fire when level increases to 5 ( CB-4519 )
+ });
+ // batterylow should not fire when level increases (5->20) ( CB-4519 )
runs(function () {
onEvent = jasmine.createSpy("onbatterylow");
window.addEventListener("batterylow", onEvent, false);