CB-3971 Break vibrations tests out from notification
- won't break existing platforms where code is not yet separated
- breaks out the vibrations from the notifications so they may be tested separately.
diff --git a/autotest/index.html b/autotest/index.html
index f75cebc..a699870 100644
--- a/autotest/index.html
+++ b/autotest/index.html
@@ -56,6 +56,7 @@
<a href="pages/splashscreen.html" class="btn large" style="width:100%;">Run Splashscreen Tests</a>
<a href="pages/whitelist.html" class="btn large" style="width:100%;">Run Whitelist Tests</a>
<a href="pages/localXHR.html" class="btn large" style="width:100%;">Run local XHR Tests</a>
+ <a href="pages/vibration.html" class="btn large" style="width:100%;">Run Vibration Tests</a>
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>
diff --git a/autotest/pages/vibration.html b/autotest/pages/vibration.html
new file mode 100644
index 0000000..b6bd03f
--- /dev/null
+++ b/autotest/pages/vibration.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<!--
+
+ 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.
+
+-->
+
+
+<html>
+
+<head>
+ <title>Cordova: Vibration API Specs</title>
+
+ <meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=1.0;" />
+ <!-- Load jasmine -->
+ <link href="../jasmine.css" rel="stylesheet"/>
+ <script type="text/javascript" src="../jasmine.js"></script>
+ <script type="text/javascript" src="../html/HtmlReporterHelpers.js"></script>
+ <script type="text/javascript" src="../html/HtmlReporter.js"></script>
+ <script type="text/javascript" src="../html/ReporterView.js"></script>
+ <script type="text/javascript" src="../html/SpecView.js"></script>
+ <script type="text/javascript" src="../html/SuiteView.js"></script>
+ <script type="text/javascript" src="../html/TrivialReporter.js"></script>
+
+ <!-- Source -->
+ <script type="text/javascript" src="../../cordova-incl.js"></script>
+
+ <!-- Load Test Runner -->
+ <script type="text/javascript" src="../test-runner.js"></script>
+
+ <!-- Tests -->
+ <script type="text/javascript" src="../tests/vibration.tests.js"></script>
+
+ <script type="text/javascript">
+ document.addEventListener('deviceready', function () {
+ var jasmineEnv = jasmine.getEnv();
+ jasmineEnv.updateInterval = 1000;
+
+ var htmlReporter = new jasmine.HtmlReporter();
+
+ jasmineEnv.addReporter(htmlReporter);
+
+ jasmineEnv.specFilter = function(spec) {
+ return htmlReporter.specFilter(spec);
+ };
+
+ jasmineEnv.execute();
+ }, false);
+ </script>
+</head>
+
+<body>
+ <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+</body>
+</html>
+
diff --git a/autotest/tests/notification.tests.js b/autotest/tests/notification.tests.js
index 6b9f242..016bcfb 100644
--- a/autotest/tests/notification.tests.js
+++ b/autotest/tests/notification.tests.js
@@ -24,11 +24,6 @@
expect(navigator.notification).toBeDefined();
});
- it("should contain a vibrate function", function() {
- expect(typeof navigator.notification.vibrate).toBeDefined();
- expect(typeof navigator.notification.vibrate).toBe("function");
- });
-
it("should contain a beep function", function() {
expect(typeof navigator.notification.beep).toBeDefined();
expect(typeof navigator.notification.beep).toBe("function");
diff --git a/autotest/tests/vibration.tests.js b/autotest/tests/vibration.tests.js
new file mode 100644
index 0000000..18e75f2
--- /dev/null
+++ b/autotest/tests/vibration.tests.js
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+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");
+ });
+});
diff --git a/index.html b/index.html
index d9f2957..199e05b 100644
--- a/index.html
+++ b/index.html
@@ -63,5 +63,6 @@
<a href="benchmarks/index.html" class="btn large">Benchmarks</a>
<a href="inappbrowser/index.html" class="btn large">In App Browser</a>
<a href="keyboard/index.html" class="btn large">Keyboard</a>
+ <a href="vibration/index.html" class="btn large">Vibration</a>
</body>
</html>
diff --git a/notification/index.html b/notification/index.html
index bacc086..16aad7d 100644
--- a/notification/index.html
+++ b/notification/index.html
@@ -42,10 +42,6 @@
navigator.notification.beep(3);
};
- var vibrate = function(){
- navigator.notification.vibrate(1000);
- };
-
var alertDialog = function(message, title, button) {
console.log("alertDialog()");
navigator.notification.alert(message,
@@ -130,7 +126,6 @@
<h2>Action</h2>
<div class="btn large" onclick="beep();">Beep</div>
- <div class="btn large" onclick="vibrate();">Vibrate</div>
<div class="btn large" onclick="alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');">Alert Dialog</div>
<div class="btn large" onclick="confirmDialogA('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog - Deprecated</div>
<div class="btn large" onclick="confirmDialogB('You pressed confirm.', 'Confirm Dialog', ['Yes', 'No', 'Maybe, Not Sure']);">Confirm Dialog</div>
diff --git a/vibration/index.html b/vibration/index.html
new file mode 100644
index 0000000..ef9b76e
--- /dev/null
+++ b/vibration/index.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<!--
+
+ 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.
+
+-->
+
+
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ //-------------------------------------------------------------------------
+ // Vibrations
+ //-------------------------------------------------------------------------
+
+ var vibrate = function(){
+ navigator.notification.vibrate(2500);
+ };
+
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: Apache Cordova did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Vibrations</h1>
+ <div id="info">
+ </div>
+
+ <h2>Action</h2>
+ <div class="btn large" onclick="vibrate();">Vibrate</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>