cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [05/11] git commit: added tests for old vibrateWithPattern and cancelVibration calls
Date Thu, 07 Aug 2014 20:48:32 GMT
added tests for old vibrateWithPattern and cancelVibration calls


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/commit/e0723e29
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/e0723e29
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/e0723e29

Branch: refs/heads/master
Commit: e0723e2973866289357ec75f473ca4f0c467bb6d
Parents: c226b6d
Author: Edna Morales <ednamorales@ednas-mbp-2.raleigh.ibm.com>
Authored: Fri Jul 18 09:46:24 2014 -0400
Committer: Edna Morales <ednamorales@ednas-mbp-2.raleigh.ibm.com>
Committed: Fri Jul 18 09:46:24 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/e0723e29/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index ccce9df..d152818 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -39,17 +39,27 @@ exports.defineManualTests = function (contentEl, createActionButton) {
 //-------------------------------------------------------------------------
 
 //old vibrate call
-var vibrate = function(){
+var vibrateOld = function(){
   navigator.notification.vibrate(2500);
 };
 
+//old vibrate with pattern call
+var vibrateWithPatternOld = function(){
+  navigator.notification.vibrateWithPattern([100, 200, 300]);
+};
+
+//old cancel vibrate call
+var cancelOld = function(){
+    navigator.notification.cancelVibration();
+};
+
 //new standard vibrate call that aligns to w3c spec with param long
-var _vibrate1 = function() {
+var vibrateWithInt = function() {
     navigator.vibrate(3000);
 };
 
 //new standard vibrate call that aligns to w3c spec with param array
-var _vibrate2 = function() {
+var vibrateWithArray = function() {
     navigator.vibrate([3000]);
 };
 
@@ -73,22 +83,38 @@ var longVibrate = function() {
     navigator.vibrate(60000);
 };
 
+//check whether there is an ongoing vibration
+var vibrateOn = false;
+
     //standard vibrate with old call
-    createActionButton('Vibrate_Old', function () {
-        vibrate();
+    createActionButton('Vibrate (Old)', function () {
+        vibrateOld();
         console.log("navigator.notification.vibrate(2500)");
     });
 
-    //standard vibrate with new call param long
-    createActionButton('Vibrate_New with long', function() {
+    //vibrate with pattern with old call
+    createActionButton('Vibrate with a pattern (Old - Android only)', function () {
+        vibrateWithPatternOld();
+        console.log("navigator.notification.vibrate([100, 200, 300]): should vibrate for
100ms, pause for 200ms, then vibrate for 300ms");
+    });
+
+    //cancel vibrate with old call
+    createActionButton('Cancel vibration (Old - Android only)', function() {
+        console.log("navigator.notification.cancelVibration(): should should try to vibrate
for 60 seconds but will be canceled after 5");
+        longVibrate();
+        setTimeout(cancelOld(), 5000);
+    });
+
+    //standard vibrate with new call param int
+    createActionButton('Vibrate with int', function() {
         console.log("navigator.vibrate(3000): should vibrate once for 3 seconds");
-        _vibrate1();
+        vibrateWithInt();
     });
 
     //standard vibrate with new call param array
-    createActionButton('Vibrate_New with array', function() {
+    createActionButton('Vibrate with array', function() {
         console.log("navigator.vibrate([3000]): should vibrate once for 3 seconds");
-        _vibrate2();
+        vibrateWithArray();
     });
 
     //vibrate with a pattern


Mime
View raw message