You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/14 16:39:03 UTC

spec commit: [CB-1933] Added a test for confirmation dialogs.

Updated Branches:
  refs/heads/master 9d9f9196e -> 8bced4ec4


[CB-1933] Added a test for confirmation dialogs.

Notification.confirm now takes an array of button labels.  Comma-separated strings are deprecated.


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/8bced4ec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/8bced4ec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/8bced4ec

Branch: refs/heads/master
Commit: 8bced4ec45440c3d16a0bfa3b34a9e70b9f92934
Parents: 9d9f919
Author: Max Woghiren <ma...@gmail.com>
Authored: Fri Feb 15 15:23:24 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Mar 14 11:38:58 2013 -0400

----------------------------------------------------------------------
 autotest/tests/notification.tests.js |    9 +++++++--
 notification/index.html              |   17 ++++++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/8bced4ec/autotest/tests/notification.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/notification.tests.js b/autotest/tests/notification.tests.js
index 6893210..3749a89 100644
--- a/autotest/tests/notification.tests.js
+++ b/autotest/tests/notification.tests.js
@@ -21,7 +21,7 @@
 
 describe('Notification (navigator.notification)', function () {
 	it("should exist", function() {
-        expect(navigator.notification).toBeDefined();
+                expect(navigator.notification).toBeDefined();
 	});
 
 	it("should contain a vibrate function", function() {
@@ -34,8 +34,13 @@ describe('Notification (navigator.notification)', function () {
 		expect(typeof navigator.notification.beep).toBe("function");
 	});
 
-	it("should contain a alert function", 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");
+	});
 });

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/8bced4ec/notification/index.html
----------------------------------------------------------------------
diff --git a/notification/index.html b/notification/index.html
index 454e965..9940ee5 100644
--- a/notification/index.html
+++ b/notification/index.html
@@ -56,7 +56,7 @@
         console.log("After alert");
     };
 
-    var confirmDialog = function(message, title, buttons) {
+    var confirmDialogA = function(message, title, buttons) {
         navigator.notification.confirm(message,
             function(r) {
                 console.log("You selected " + r);
@@ -65,7 +65,17 @@
             title,
             buttons);
     };
-    
+
+    var confirmDialogB = function(message, title, buttons) {
+        navigator.notification.confirm(message,
+            function(r) {
+                console.log("You selected " + r);
+                alert("You selected " + buttons[r-1]);
+            },
+            title,
+            buttons);
+    };
+
     /**
      * Function called when page has finished loading.
      */
@@ -94,7 +104,8 @@
     <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="confirmDialog('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog</div>
+    <div class="btn large" onclick="confirmDialogA('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog A</div>
+    <div class="btn large" onclick="confirmDialogB('You pressed confirm.', 'Confirm Dialog', ['Yes', 'No', 'Maybe, Not Sure']);">Confirm Dialog B</div>
     <div class="btn large" onclick="alert('You pressed alert.');">Built-in Alert Dialog</div>
     <div class="btn large" onclick="confirm('You selected confirm');">Built-in Confirm Dialog</div>
     <div class="btn large" onclick="prompt('This is a prompt.', 'Default value');">Built-in Prompt Dialog</div>