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:28 UTC

[01/11] git commit: CB-6963, ported vibration automated & manual tests

Repository: cordova-plugin-vibration
Updated Branches:
  refs/heads/master ad24d2a0b -> 6c87e6d75


CB-6963, ported vibration automated & manual tests

Ported tests from mobilespec.

Jasmine version: ported from v1.3 to v2.0


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

Branch: refs/heads/master
Commit: 53760ccbf19964d20e9a6693cb1f52050f2c5391
Parents: f283db2
Author: Martin Gonzalez <ma...@gmail.com>
Authored: Tue Jul 15 15:33:20 2014 -0500
Committer: Martin Gonzalez <ma...@gmail.com>
Committed: Tue Jul 15 15:33:20 2014 -0500

----------------------------------------------------------------------
 test/tests.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/53760ccb/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
new file mode 100644
index 0000000..cab932b
--- /dev/null
+++ b/test/tests.js
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+exports.defineAutoTests = function () {
+
+    describe('Vibration (navigator.notification.vibrate)', function () {
+        it("navigator.notification should exist", function () {
+            expect(navigator.notification).toBeDefined();
+        });
+
+        it("should contain a vibrate function", function () {
+            expect(typeof navigator.notification.vibrate).toBeDefined();
+            expect(typeof navigator.notification.vibrate).toBe("function");
+        });
+    });
+};
+
+exports.defineManualTests = function (contentEl, createActionButton) {
+//-------------------------------------------------------------------------
+// Vibrations
+//-------------------------------------------------------------------------
+
+var vibrate = function(){
+  navigator.notification.vibrate(2500);
+};
+    createActionButton('Vibrate', function () {
+        vibrate();
+        console.log("navigator.notification.vibrate(2500)");
+    });
+};


[06/11] git commit: on/off button for cancel tests, add results box and msgs

Posted by pu...@apache.org.
on/off button for cancel tests, add results box and msgs


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

Branch: refs/heads/master
Commit: 90c6335c59775fb5ee94ccf8aa027e5bfc98e9fd
Parents: e0723e2
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Fri Jul 18 15:02:34 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Fri Jul 18 15:02:34 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 235 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 156 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/90c6335c/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index d152818..86fa7b9 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -34,106 +34,183 @@ exports.defineAutoTests = function () {
 };
 
 exports.defineManualTests = function (contentEl, createActionButton) {
-//-------------------------------------------------------------------------
-// Vibrations
-//-------------------------------------------------------------------------
-
-//old vibrate call
-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 vibrateWithInt = function() {
-    navigator.vibrate(3000);
-};
-
-//new standard vibrate call that aligns to w3c spec with param array
-var vibrateWithArray = 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);
-};
-
-//check whether there is an ongoing vibration
-var vibrateOn = false;
+    var logMessage = function (message, color) {
+        var log = document.getElementById('info');
+        var logLine = document.createElement('div');
+        if (color) {
+            logLine.style.color = color;
+        }
+        logLine.innerHTML = message;
+        log.appendChild(logLine);
+    }
+
+    var clearLog = function () {
+        var log = document.getElementById('info');
+        log.innerHTML = '';
+    }
+
+    //-------------------------------------------------------------------------
+    // Vibrations
+    //-------------------------------------------------------------------------
+
+    //old vibrate call
+    var vibrateOld = function(){
+        clearLog();
+        navigator.notification.vibrate(2500);
+        logMessage("navigator.notification.vibrate(2500)", "green");
+    };
+
+    //old vibrate with pattern call
+    var vibrateWithPatternOld = function(){
+        clearLog();
+        navigator.notification.vibrateWithPattern([100, 200, 300]);
+        logMessage("navigator.notification.vibrateWithPattern([100, 200, 300])", "green");
+    };
+
+    //old cancel vibrate call
+    var cancelOld = function(){
+        clearLog();
+        navigator.notification.cancelVibration();
+        logMessage("navigator.notification.cancelVibration()", "green");
+    };
+
+    //new standard vibrate call that aligns to w3c spec with param long
+    var vibrateWithInt = function() {
+        clearLog();
+        navigator.vibrate(3000);
+        logMessage("navigator.vibrate(3000)", "green");
+    };
+
+    //new standard vibrate call that aligns to w3c spec with param array
+    var vibrateWithArray = function() {
+        clearLog();
+        navigator.vibrate([3000]);
+        logMessage("navigator.vibrate([3000])", "green");
+    };
+
+    //vibrate with a pattern using w3c spec
+    var vibrateWithPattern = function() {
+        clearLog();
+        navigator.vibrate([100, 200, 300]);
+        logMessage("navigator.vibrate([100, 200, 300])", "green");
+    };
+
+    //cancel existing vibration using w3c spec navigator.vibrate(0)
+    var cancelWithZero = function() {
+        clearLog();
+        navigator.vibrate(0);
+        logMessage("navigator.vibrate(0)", "green");
+    };
+
+    //cancel existing vibration using w3c spec navigator.vibrate([])
+    var cancelWithEmpty = function() {
+        clearLog();
+        navigator.vibrate([]);
+        logMessage("navigator.vibrate([])", "green");
+    };
+
+    //special long vibrate used to test cancel
+    var longVibrate = function() {
+        clearLog();
+        navigator.vibrate(60000);
+        logMessage("navigator.vibrate(60000)", "green");
+    };
+
+    //check whether there is an ongoing vibration
+    var vibrateOn = false;
+
+
+
+
+    var vibrate_tests = '<h1>Vibrate Tests</h1>' +
+        '<h3>Starred tests only work for Android. </h3>' +
+        '<div id="vibrate_old"></div>' +
+        'Expected result: Vibrate once for 2.5 seconds.' +
+        '<p/> <div id="vibrateWithPattern_old"></div>' +
+        'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
+        '<p/> <div id="cancelVibrate_old"></div>' +
+        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.' +
+        '<p/> <div id="vibrate_int"></div>' +
+        'Expected result: Vibrate once for 3 seconds.' +
+        '<p/> <div id="vibrate_array"></div>' +
+        'Expected result: Vibrate once for 3 seconds.' +
+        '<p/> <div id="vibrate_with_pattern"></div>' +
+        'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
+        '<p/> <div id="cancel_zero"></div>' +
+        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.' +
+        '<p/><div id="cancel_array"></div>' +
+        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.';
+
+
+    contentEl.innerHTML = '<div id="info"></div>' + vibrate_tests;
 
     //standard vibrate with old call
     createActionButton('Vibrate (Old)', function () {
         vibrateOld();
-        console.log("navigator.notification.vibrate(2500)");
-    });
+    }, 'vibrate_old');
 
     //vibrate with pattern with old call
-    createActionButton('Vibrate with a pattern (Old - Android only)', function () {
+    createActionButton('* Vibrate with a pattern (Old)', function () {
         vibrateWithPatternOld();
-        console.log("navigator.notification.vibrate([100, 200, 300]): should vibrate for 100ms, pause for 200ms, then vibrate for 300ms");
-    });
+    }, 'vibrateWithPattern_old');
 
     //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);
-    });
+    createActionButton('* Cancel vibration (Old)', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrate();
+            vibrateOn = true;
+        }
+        else
+        {
+            cancelOld();
+            vibrateOn = false;
+        }
+    }, 'cancelVibrate_old');
 
     //standard vibrate with new call param int
     createActionButton('Vibrate with int', function() {
-        console.log("navigator.vibrate(3000): should vibrate once for 3 seconds");
         vibrateWithInt();
-    });
+    }, 'vibrate_int');
 
     //standard vibrate with new call param array
-    createActionButton('Vibrate with array', function() {
-        console.log("navigator.vibrate([3000]): should vibrate once for 3 seconds");
+    createActionButton('* Vibrate with array', function() {
         vibrateWithArray();
-    });
+    }, 'vibrate_array');
 
     //vibrate with a pattern
-    createActionButton('Vibrate with a pattern (Android only)', function() {
-        console.log("navigator.vibrate([100, 200, 300]): should vibrate for 100ms, pause for 200ms, then vibrate for 300ms");
+    createActionButton('* Vibrate with a pattern', function() {
         vibrateWithPattern();
-    });
+    }, 'vibrate_with_pattern');
 
     //cancel any existing vibrations with param 0
-    createActionButton('Cancel vibration with 0 (Android only)', function() {
-        console.log("navigator.vibrate(0): should try to vibrate for 60 seconds but will be canceled after 5");
-        longVibrate();
-        setTimeout(cancelWithZero(), 5000);
-    });
+    createActionButton('* Cancel vibration with 0', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrate();
+            vibrateOn = true;
+        }
+        else
+        {
+            cancelWithZero();
+            vibrateOn = false;
+        }
+    }, 'cancel_zero');
 
     //cancel any existing vibrations with param []
-    createActionButton('Cancel vibration with [] (Android only)', function() {
-        console.log("navigator.vibrate([]): should should try to vibrate for 60 seconds but will be canceled after 5");
-        longVibrate();
-        setTimeout(cancelWithEmpty(), 5000);
-    });
+    createActionButton('* Cancel vibration with []', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrate();
+            vibrateOn = true;
+        }
+        else
+        {
+            cancelWithEmpty();
+            vibrateOn = false;
+        }
+    }, 'cancel_array');
 };


[07/11] git commit: add setTimeout function to update vibrateOn var if user doesn't cancel vibrate, add note about iOS

Posted by pu...@apache.org.
add setTimeout function to update vibrateOn var if user doesn't cancel vibrate, add note about iOS


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

Branch: refs/heads/master
Commit: 5ce57fc08d513e798052f4aeb992e2752980ba03
Parents: 90c6335
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Mon Jul 21 08:57:14 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Mon Jul 21 08:57:14 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/5ce57fc0/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 86fa7b9..689f0f1 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -114,6 +114,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         clearLog();
         navigator.vibrate(60000);
         logMessage("navigator.vibrate(60000)", "green");
+        setTimeout(function() {
+            vibrateOn = false;
+        }, 60000);
     };
 
     //check whether there is an ongoing vibration
@@ -124,12 +127,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
 
     var vibrate_tests = '<h1>Vibrate Tests</h1>' +
         '<h3>Starred tests only work for Android. </h3>' +
+        '<h3>iOS ignores the time given for a vibrate </h3>' +
         '<div id="vibrate_old"></div>' +
         'Expected result: Vibrate once for 2.5 seconds.' +
         '<p/> <div id="vibrateWithPattern_old"></div>' +
         'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
         '<p/> <div id="cancelVibrate_old"></div>' +
-        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.' +
+        'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
         '<p/> <div id="vibrate_int"></div>' +
         'Expected result: Vibrate once for 3 seconds.' +
         '<p/> <div id="vibrate_array"></div>' +
@@ -137,9 +141,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         '<p/> <div id="vibrate_with_pattern"></div>' +
         'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
         '<p/> <div id="cancel_zero"></div>' +
-        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.' +
+        'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
         '<p/><div id="cancel_array"></div>' +
-        'Expected result: First press will begin vibration for 60 seconds. Pressing again will cancel immediately.';
+        'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.';
 
 
     contentEl.innerHTML = '<div id="info"></div>' + vibrate_tests;


[08/11] git commit: clear settimeout when user cancels vibration

Posted by pu...@apache.org.
clear settimeout when user cancels vibration


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

Branch: refs/heads/master
Commit: 4b01432cf26ffbce13feba58bf5b10d16d45ffaf
Parents: 5ce57fc
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Mon Jul 21 09:42:51 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Mon Jul 21 09:42:51 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/4b01432c/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 689f0f1..78b0e99 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -109,16 +109,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         logMessage("navigator.vibrate([])", "green");
     };
 
+    //reference to the timeout variable
+    var timeout;
+
     //special long vibrate used to test cancel
     var longVibrate = function() {
         clearLog();
         navigator.vibrate(60000);
         logMessage("navigator.vibrate(60000)", "green");
-        setTimeout(function() {
-            vibrateOn = false;
-        }, 60000);
+        timeout = setTimeout(resetVibrateOn, 60000); //if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds
     };
 
+    function resetVibrateOn() {
+        vibrateOn = false;
+    }
+
     //check whether there is an ongoing vibration
     var vibrateOn = false;
 
@@ -169,7 +174,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         else
         {
             cancelOld();
-            vibrateOn = false;
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
         }
     }, 'cancelVibrate_old');
 
@@ -199,7 +205,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         else
         {
             cancelWithZero();
-            vibrateOn = false;
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
         }
     }, 'cancel_zero');
 
@@ -214,7 +221,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         else
         {
             cancelWithEmpty();
-            vibrateOn = false;
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
         }
     }, 'cancel_array');
 };


[09/11] git commit: added more test cases, changed vibrate with pattern durations, changed where vibrateOn is set to true

Posted by pu...@apache.org.
added more test cases, changed vibrate with pattern durations, changed where vibrateOn is set to true


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

Branch: refs/heads/master
Commit: d93aafc7708822345ab469fc87b5c0b247074189
Parents: 4b01432
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Mon Jul 21 12:28:46 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Mon Jul 21 12:28:46 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/d93aafc7/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 78b0e99..6fd993f 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -63,8 +63,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     //old vibrate with pattern call
     var vibrateWithPatternOld = function(){
         clearLog();
-        navigator.notification.vibrateWithPattern([100, 200, 300]);
-        logMessage("navigator.notification.vibrateWithPattern([100, 200, 300])", "green");
+        navigator.notification.vibrateWithPattern([1000, 2000, 3000]);
+        logMessage("navigator.notification.vibrateWithPattern([1000, 2000, 3000])", "green");
     };
 
     //old cancel vibrate call
@@ -91,8 +91,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     //vibrate with a pattern using w3c spec
     var vibrateWithPattern = function() {
         clearLog();
-        navigator.vibrate([100, 200, 300]);
-        logMessage("navigator.vibrate([100, 200, 300])", "green");
+        navigator.vibrate([1000, 2000, 3000]);
+        logMessage("navigator.vibrate([1000, 2000, 3000])", "green");
     };
 
     //cancel existing vibration using w3c spec navigator.vibrate(0)
@@ -116,10 +116,30 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     var longVibrate = function() {
         clearLog();
         navigator.vibrate(60000);
+        vibrateOn = true;
         logMessage("navigator.vibrate(60000)", "green");
         timeout = setTimeout(resetVibrateOn, 60000); //if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds
     };
 
+    //special long vibrate with pattern used to test cancel
+    var longVibrateWithPattern = function() {
+        clearLog();
+        navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]);
+        vibrateOn = true;
+        logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]);", "green");
+        timeout = setTimeout(resetVibrateOn, 45000); //if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds
+    };
+
+    //initiate two vibrations to test cancel
+    var multipleVibrations = function() {
+        clearLog();
+        navigator.vibrate(20000);
+        navigator.vibrate(45000);
+        vibrateOn = true;
+        logMessage("navigator.vibrate(15000)\nnavigator.vibrate(45000)", "green");
+        timeout = setTimeout(resetVibrateOn, 45000); //if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds
+    }
+
     function resetVibrateOn() {
         vibrateOn = false;
     }
@@ -136,19 +156,27 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         '<div id="vibrate_old"></div>' +
         'Expected result: Vibrate once for 2.5 seconds.' +
         '<p/> <div id="vibrateWithPattern_old"></div>' +
-        'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
+        'Expected result: Vibrate for 1s, pause for 2s, then vibrate for 3s.' +
         '<p/> <div id="cancelVibrate_old"></div>' +
         'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
+        '<p/> <div id="cancelVibrateWithPattern_old"></div>' +
+        'Expected result: Press once to initiate vibrate with pattern for 45s. Press again to cancel vibrate immediately.' +
         '<p/> <div id="vibrate_int"></div>' +
         'Expected result: Vibrate once for 3 seconds.' +
         '<p/> <div id="vibrate_array"></div>' +
         'Expected result: Vibrate once for 3 seconds.' +
         '<p/> <div id="vibrate_with_pattern"></div>' +
-        'Expected result: Vibrate for 100ms, pause for 200ms, then vibrate for 300ms.' +
+        'Expected result: Vibrate for 1s, pause for 2s, then vibrate for 3s.' +
         '<p/> <div id="cancel_zero"></div>' +
         'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
         '<p/><div id="cancel_array"></div>' +
-        'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.';
+        'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
+        '<p/> <div id="cancelWithPattern_zero"></div>' +
+        'Expected result: Press once to initiate vibrate with pattern for 45s. Press again to cancel vibrate immediately.' +
+        '<p/> <div id="cancelWithPattern_array"></div>' +
+        'Expected result: Press once to initiate vibrate with pattern for 45s. Press again to cancel vibrate immediately.' +
+        '<p/> <div id="cancelMultipleVibrations"></div>' +
+        'Expected result: Press once to initiate two vibrations simultaneously (one for 20s the other for 45s so total of 45s). Press again to cancel both vibrations immediately.';
 
 
     contentEl.innerHTML = '<div id="info"></div>' + vibrate_tests;
@@ -169,7 +197,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         if (!vibrateOn)
         {
             longVibrate();
-            vibrateOn = true;
         }
         else
         {
@@ -179,6 +206,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         }
     }, 'cancelVibrate_old');
 
+    //cancel vibrate with pattern with old call
+    createActionButton('* Cancel vibration with pattern (Old)', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrateWithPattern();
+        }
+        else
+        {
+            cancelOld();
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
+        }
+    }, 'cancelVibrateWithPattern_old');
+
     //standard vibrate with new call param int
     createActionButton('Vibrate with int', function() {
         vibrateWithInt();
@@ -200,7 +242,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         if (!vibrateOn)
         {
             longVibrate();
-            vibrateOn = true;
         }
         else
         {
@@ -216,7 +257,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         if (!vibrateOn)
         {
             longVibrate();
-            vibrateOn = true;
         }
         else
         {
@@ -225,4 +265,49 @@ exports.defineManualTests = function (contentEl, createActionButton) {
             clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
         }
     }, 'cancel_array');
+
+    //cancel vibration with pattern with param 0
+    createActionButton('* Cancel vibration with pattern with 0', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrateWithPattern();
+        }
+        else
+        {
+            cancelWithZero();
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
+        }
+    }, 'cancelWithPattern_zero');
+
+    //cancel vibration with pattern with param []
+    createActionButton('* Cancel vibration with pattern with []', function() {
+
+        if (!vibrateOn)
+        {
+            longVibrateWithPattern();
+        }
+        else
+        {
+            cancelWithEmpty();
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
+        }
+    }, 'cancelWithPattern_array');
+
+    //cancel multiple vibrations
+    createActionButton('* Cancel multiple vibrations', function() {
+
+        if (!vibrateOn)
+        {
+            multipleVibrations();
+        }
+        else
+        {
+            cancelWithZero();
+            resetVibrateOn();
+            clearTimeout(timeout); //clear the timeout since user has canceled the vibrate
+        }
+    }, 'cancelMultipleVibrations');
 };


[05/11] git commit: added tests for old vibrateWithPattern and cancelVibration calls

Posted by pu...@apache.org.
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 <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Fri Jul 18 09:46:24 2014 -0400
Committer: Edna Morales <ed...@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


[10/11] git commit: add longer pattern sequence for testing, change expected result for old vibrate with pattern test

Posted by pu...@apache.org.
add longer pattern sequence for testing, change expected result for old vibrate with pattern test


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

Branch: refs/heads/master
Commit: ab0c239e9c34f19e2c1e2f7d6fdc2df0679490d9
Parents: d93aafc
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Mon Jul 21 15:41:51 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Mon Jul 21 15:41:51 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/ab0c239e/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 6fd993f..7ac48d9 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -63,8 +63,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     //old vibrate with pattern call
     var vibrateWithPatternOld = function(){
         clearLog();
-        navigator.notification.vibrateWithPattern([1000, 2000, 3000]);
-        logMessage("navigator.notification.vibrateWithPattern([1000, 2000, 3000])", "green");
+        navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000]);
+        logMessage("navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000])", "green");
     };
 
     //old cancel vibrate call
@@ -91,8 +91,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     //vibrate with a pattern using w3c spec
     var vibrateWithPattern = function() {
         clearLog();
-        navigator.vibrate([1000, 2000, 3000]);
-        logMessage("navigator.vibrate([1000, 2000, 3000])", "green");
+        navigator.vibrate([1000, 2000, 3000, 2000, 5000]);
+        logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000])", "green");
     };
 
     //cancel existing vibration using w3c spec navigator.vibrate(0)
@@ -126,7 +126,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         clearLog();
         navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]);
         vibrateOn = true;
-        logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]);", "green");
+        logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000])", "green");
         timeout = setTimeout(resetVibrateOn, 45000); //if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds
     };
 
@@ -156,7 +156,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         '<div id="vibrate_old"></div>' +
         'Expected result: Vibrate once for 2.5 seconds.' +
         '<p/> <div id="vibrateWithPattern_old"></div>' +
-        'Expected result: Vibrate for 1s, pause for 2s, then vibrate for 3s.' +
+        'Expected result: Pause for 1s, vibrate for 3s, pause for 2s, vibrate for 5s.' +
         '<p/> <div id="cancelVibrate_old"></div>' +
         'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
         '<p/> <div id="cancelVibrateWithPattern_old"></div>' +
@@ -166,7 +166,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         '<p/> <div id="vibrate_array"></div>' +
         'Expected result: Vibrate once for 3 seconds.' +
         '<p/> <div id="vibrate_with_pattern"></div>' +
-        'Expected result: Vibrate for 1s, pause for 2s, then vibrate for 3s.' +
+        'Expected result: Vibrate for 1s, pause for 2s, vibrate for 3s, pause for 2s, vibrate for 5s.' +
         '<p/> <div id="cancel_zero"></div>' +
         'Expected result: Press once to initiate vibrate for 60 seconds. Press again to cancel vibrate immediately.' +
         '<p/><div id="cancel_array"></div>' +


[04/11] git commit: added 'Android only' to buttons for specific tests, changed where console.log is executed for user to see earlier

Posted by pu...@apache.org.
added 'Android only' to buttons for specific tests, changed where console.log is executed for user to see earlier


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

Branch: refs/heads/master
Commit: c226b6df96ee44770586de5922ec72ae434c6ba5
Parents: c1a88b2
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Wed Jul 16 16:34:28 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Wed Jul 16 16:34:28 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/c226b6df/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 2597cc5..ccce9df 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -81,31 +81,31 @@ var longVibrate = function() {
 
     //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");
+        _vibrate1();
     });
 
     //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");
+        _vibrate2();
     });
 
     //vibrate with a pattern
-    createActionButton('Vibrate with a pattern', function() {
-        vibrateWithPattern();
+    createActionButton('Vibrate with a pattern (Android only)', function() {
         console.log("navigator.vibrate([100, 200, 300]): should vibrate for 100ms, pause for 200ms, then vibrate for 300ms");
+        vibrateWithPattern();
     });
 
     //cancel any existing vibrations with param 0
-    createActionButton('Cancel vibration with 0', function() {
+    createActionButton('Cancel vibration with 0 (Android only)', 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() {
+    createActionButton('Cancel vibration with [] (Android only)', function() {
         console.log("navigator.vibrate([]): should should try to vibrate for 60 seconds but will be canceled after 5");
         longVibrate();
         setTimeout(cancelWithEmpty(), 5000);


[02/11] git commit: Merged current tests to add new tests

Posted by pu...@apache.org.
Merged current tests to add new tests


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

Branch: refs/heads/master
Commit: d677a1e7e72c284e3a07dbe90370cc20213b0f61
Parents: 112254e 53760cc
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Tue Jul 15 16:54:51 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Tue Jul 15 16:54:51 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------



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

Posted by pu...@apache.org.
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);
+    });
 };


[11/11] git commit: Merge branch 'CB-7138' of https://github.com/eymorale/cordova-plugin-vibration

Posted by pu...@apache.org.
Merge branch 'CB-7138' of https://github.com/eymorale/cordova-plugin-vibration


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

Branch: refs/heads/master
Commit: 6c87e6d7526ec1775add6178e640d8b2f6daee0b
Parents: ad24d2a ab0c239
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Aug 7 13:48:13 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Aug 7 13:48:13 2014 -0700

----------------------------------------------------------------------
 test/tests.js | 313 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 313 insertions(+)
----------------------------------------------------------------------