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/19 03:34:57 UTC

[2/2] git commit: Merge renamed test dir

Merge renamed test dir


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

Branch: refs/heads/master
Commit: 24c2665b8b7f820161c8cc9123ccc19f7cf4ee87
Parents: 80a7dae 423ee17
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Wed Aug 13 13:03:43 2014 -0400
Committer: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Committed: Wed Aug 13 13:03:43 2014 -0400

----------------------------------------------------------------------
 RELEASENOTES.md               |   9 ++
 plugin.xml                    |   2 +-
 src/firefoxos/notification.js |   2 +-
 src/ubuntu/notification.cpp   |  38 ++++----
 src/ubuntu/notification.h     |   7 +-
 src/ubuntu/notification.qml   |  10 +-
 test/tests.js                 | 189 -------------------------------------
 tests/plugin.xml              |  29 ++++++
 tests/tests.js                | 189 +++++++++++++++++++++++++++++++++++++
 9 files changed, 259 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/24c2665b/tests/tests.js
----------------------------------------------------------------------
diff --cc tests/tests.js
index 0000000,99ddf6e..6e61b00
mode 000000,100644..100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@@ -1,0 -1,170 +1,189 @@@
+ /*
+  *
+  * 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('Notification (navigator.notification)', function () {
+         it("should exist", function () {
+             expect(navigator.notification).toBeDefined();
+         });
+ 
+         it("should contain a beep function", function () {
+             expect(typeof navigator.notification.beep).toBeDefined();
+             expect(typeof navigator.notification.beep).toBe("function");
+         });
+ 
+         it("should contain an alert function", function () {
+             expect(typeof navigator.notification.alert).toBeDefined();
+             expect(typeof navigator.notification.alert).toBe("function");
+         });
+ 
+         it("should contain a confirm function", function () {
+             expect(typeof navigator.notification.confirm).toBeDefined();
+             expect(typeof navigator.notification.confirm).toBe("function");
+         });
+ 
+         it("should contain a prompt function", function () {
+             expect(typeof navigator.notification.prompt).toBeDefined();
+             expect(typeof navigator.notification.prompt).toBe("function");
+         });
+     });
+ };
+ 
+ /******************************************************************************/
+ /******************************************************************************/
+ /******************************************************************************/
+ 
+ exports.defineManualTests = function (contentEl, createActionButton) {
+     var logMessage = function (message) {
+         var log = document.getElementById('info');
+         var logLine = document.createElement('div');
+         logLine.innerHTML = message;
+         log.appendChild(logLine);
+     }
+ 
+     var clearLog = function () {
+         var log = document.getElementById('info');
+         log.innerHTML = '';
+     }
+ 
+     var beep = function () {
+         console.log("beep()");
+         navigator.notification.beep(3);
+     };
+ 
+     var alertDialog = function (message, title, button) {
+         console.log("alertDialog()");
+         navigator.notification.alert(message,
+             function () {
+                 console.log("Alert dismissed.");
+             },
+             title, button);
+         console.log("After alert");
+     };
+ 
+     var confirmDialogA = function (message, title, buttons) {
+         clearLog();
+         navigator.notification.confirm(message,
+             function (r) {
+                 if (r === 0) {
+                     logMessage("Dismissed dialog without making a selection.");
+                     console.log("Dismissed dialog without making a selection.");
+                 } else {
+                     console.log("You selected " + r);
+                     logMessage("You selected " + (buttons.split(","))[r - 1]);
+                 }
+             },
+             title,
+             buttons);
+     };
+ 
+     var confirmDialogB = function (message, title, buttons) {
+         clearLog();
+         navigator.notification.confirm(message,
+             function (r) {
+                 if (r === 0) {
+                     logMessage("Dismissed dialog without making a selection.");
+                     console.log("Dismissed dialog without making a selection.");
+                 } else {
+                     console.log("You selected " + r);
+                     logMessage("You selected " + buttons[r - 1]);
+                 }
+             },
+             title,
+             buttons);
+     };
+ 
+     var promptDialog = function (message, title, buttons) {
+         clearLog();
+         navigator.notification.prompt(message,
+             function (r) {
+                 if (r && r.buttonIndex === 0) {
+                     var msg = "Dismissed dialog";
+                     if (r.input1) {
+                         msg += " with input: " + r.input1
+                     }
+                     logMessage(msg);
+                     console.log(msg);
+                 } else {
+                     console.log("You selected " + r.buttonIndex + " and entered: " + r.input1);
+                     logMessage("You selected " + buttons[r.buttonIndex - 1] + " and entered: " + r.input1);
+                 }
+             },
+             title,
+             buttons);
+     };
+ 
+     /******************************************************************************/
+ 
++    var dialogs_tests = '<div id="beep"></div>' +
++        'Expected result: Device will beep (unless device is on silent). Nothing will get updated in status box.' +
++        '<h2>Dialog Tests</h2>' +
++        '<h3>Dialog boxes will pop up for each of the following tests</h3>' +
++        '<p/> <div id="alert"></div>' +
++        'Expected result: Dialog will say "You pressed alert". Press continue to close dialog. Nothing will get updated in status box.' +
++        '<p/> <div id="confirm_deprecated"></div>' +
++        'Expected result: Dialog will say "You pressed confirm". Press Yes, No, or Maybe to close dialog. Status box will tell you what option you selected.' +
++        '<p/> <div id="confirm"></div>' +
++        'Expected result: Dialog will say "You pressed confirm". Press Yes, No, or Maybe, Not Sure to close dialog. Status box will tell you what option you selected.' +
++        '<p/> <div id="prompt"></div>' +
++        'Expected result: Dialog will say "You pressed prompt". Enter any message and press Yes, No, or Maybe, Not Sure to close dialog. Status box will tell you what option you selected and message you entered.' +
++        '<p/> <div id="built_in_alert"></div>' +
++        'Expected result: Dialog will have title "index.html" and say "You pressed alert" Press OK to close dialog. Nothing will get updated in status box.' +
++        '<p/> <div id="built_in_confirm"></div>' +
++        'Expected result: Dialog will have title "index.html" and say "You selected confirm". Press Cancel or OK to close dialog. Nothing will get updated in status box.' +
++        '<p/> <div id="built_in_prompt"></div>' +
++        'Expected result: Dialog will have title "index.html" and say "This is a prompt". "Default value" will be in text box. Press Cancel or OK to close dialog. Nothing will get updated in status box.';
++
+     contentEl.innerHTML = '<div id="info"></div>' +
 -        '<div id="actions"></div>';
++        dialogs_tests;
+ 
+     createActionButton('Beep', function () {
+         beep();
 -    }, 'actions');
++    }, 'beep');
+ 
+     createActionButton('Alert Dialog', function () {
+         alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');
 -    }, 'actions');
++    }, 'alert');
+ 
+     createActionButton('Confirm Dialog - Deprecated', function () {
+         confirmDialogA('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');
 -    }, 'actions');
++    }, 'confirm_deprecated');
+ 
+     createActionButton('Confirm Dialog', function () {
+         confirmDialogB('You pressed confirm.', 'Confirm Dialog', ['Yes', 'No', 'Maybe, Not Sure']);
 -    }, 'actions');
++    }, 'confirm');
+ 
+     createActionButton('Prompt Dialog', function () {
+         promptDialog('You pressed prompt.', 'Prompt Dialog', ['Yes', 'No', 'Maybe, Not Sure']);
 -    }, 'actions');
++    }, 'prompt');
+ 
+     createActionButton('Built-in Alert Dialog', function () {
+         alert('You pressed alert');
 -    }, 'actions');
++    }, 'built_in_alert');
+ 
+     createActionButton('Built-in Confirm Dialog', function () {
+         confirm('You selected confirm');
 -    }, 'actions');
++    }, 'built_in_confirm');
+ 
+     createActionButton('Built-in Prompt Dialog', function () {
+         prompt('This is a prompt', 'Default value');
 -    }, 'actions');
++    }, 'built_in_prompt');
+ };