You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/08/07 22:48:30 UTC

[03/11] git commit: added tests to ensure compliance with w3c spec

added tests to ensure compliance with w3c spec


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/c1a88b20
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/c1a88b20
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/c1a88b20

Branch: refs/heads/master
Commit: c1a88b20c06ffbde802b488609412da366d4fe2a
Parents: d677a1e
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Wed Jul 16 16:12:29 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Wed Jul 16 16:12:29 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/c1a88b20/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index cab932b..2597cc5 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -38,11 +38,76 @@ exports.defineManualTests = function (contentEl, createActionButton) {
 // Vibrations
 //-------------------------------------------------------------------------
 
+//old vibrate call
 var vibrate = function(){
   navigator.notification.vibrate(2500);
 };
-    createActionButton('Vibrate', function () {
+
+//new standard vibrate call that aligns to w3c spec with param long
+var _vibrate1 = function() {
+    navigator.vibrate(3000);
+};
+
+//new standard vibrate call that aligns to w3c spec with param array
+var _vibrate2 = function() {
+    navigator.vibrate([3000]);
+};
+
+//vibrate with a pattern using w3c spec
+var vibrateWithPattern = function() {
+    navigator.vibrate([100, 200, 300]);
+};
+
+//cancel existing vibration using w3c spec navigator.vibrate(0)
+var cancelWithZero = function() {
+    navigator.vibrate(0);
+};
+
+//cancel existing vibration using w3c spec navigator.vibrate([])
+var cancelWithEmpty = function() {
+    navigator.vibrate([]);
+};
+
+//special long vibrate used to test cancel
+var longVibrate = function() {
+    navigator.vibrate(60000);
+};
+
+    //standard vibrate with old call
+    createActionButton('Vibrate_Old', function () {
         vibrate();
         console.log("navigator.notification.vibrate(2500)");
     });
+
+    //standard vibrate with new call param long
+    createActionButton('Vibrate_New with long', function() {
+        _vibrate1();
+        console.log("navigator.vibrate(3000): should vibrate once for 3 seconds");
+    });
+
+    //standard vibrate with new call param array
+    createActionButton('Vibrate_New with array', function() {
+        _vibrate2();
+        console.log("navigator.vibrate([3000]): should vibrate once for 3 seconds");
+    });
+
+    //vibrate with a pattern
+    createActionButton('Vibrate with a pattern', function() {
+        vibrateWithPattern();
+        console.log("navigator.vibrate([100, 200, 300]): should vibrate for 100ms, pause for 200ms, then vibrate for 300ms");
+    });
+
+    //cancel any existing vibrations with param 0
+    createActionButton('Cancel vibration with 0', function() {
+        console.log("navigator.vibrate(0): should try to vibrate for 60 seconds but will be canceled after 5");
+        longVibrate();
+        setTimeout(cancelWithZero(), 5000);
+    });
+
+    //cancel any existing vibrations with param []
+    createActionButton('Cancel vibration with []', function() {
+        console.log("navigator.vibrate([]): should should try to vibrate for 60 seconds but will be canceled after 5");
+        longVibrate();
+        setTimeout(cancelWithEmpty(), 5000);
+    });
 };