michael@0: /* michael@0: * michael@0: * Licensed to the Apache Software Foundation (ASF) under one michael@0: * or more contributor license agreements. See the NOTICE file michael@0: * distributed with this work for additional information michael@0: * regarding copyright ownership. The ASF licenses this file michael@0: * to you under the Apache License, Version 2.0 (the michael@0: * "License"); you may not use this file except in compliance michael@0: * with the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, michael@0: * software distributed under the License is distributed on an michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY michael@0: * KIND, either express or implied. See the License for the michael@0: * specific language governing permissions and limitations michael@0: * under the License. michael@0: * michael@0: */ michael@0: michael@0: exports.defineAutoTests = function () { michael@0: describe('Notification (navigator.notification)', function () { michael@0: it("should exist", function () { michael@0: expect(navigator.notification).toBeDefined(); michael@0: }); michael@0: michael@0: it("should contain a beep function", function () { michael@0: expect(typeof navigator.notification.beep).toBeDefined(); michael@0: expect(typeof navigator.notification.beep).toBe("function"); michael@0: }); michael@0: michael@0: it("should contain an alert function", function () { michael@0: expect(typeof navigator.notification.alert).toBeDefined(); michael@0: expect(typeof navigator.notification.alert).toBe("function"); michael@0: }); michael@0: michael@0: it("should contain a confirm function", function () { michael@0: expect(typeof navigator.notification.confirm).toBeDefined(); michael@0: expect(typeof navigator.notification.confirm).toBe("function"); michael@0: }); michael@0: michael@0: it("should contain a prompt function", function () { michael@0: expect(typeof navigator.notification.prompt).toBeDefined(); michael@0: expect(typeof navigator.notification.prompt).toBe("function"); michael@0: }); michael@0: }); michael@0: }; michael@0: michael@0: /******************************************************************************/ michael@0: /******************************************************************************/ michael@0: /******************************************************************************/ michael@0: michael@0: exports.defineManualTests = function (contentEl, createActionButton) { michael@0: var logMessage = function (message) { michael@0: var log = document.getElementById('info'); michael@0: var logLine = document.createElement('div'); michael@0: logLine.innerHTML = message; michael@0: log.appendChild(logLine); michael@0: } michael@0: michael@0: var clearLog = function () { michael@0: var log = document.getElementById('info'); michael@0: log.innerHTML = ''; michael@0: } michael@0: michael@0: var beep = function () { michael@0: console.log("beep()"); michael@0: navigator.notification.beep(3); michael@0: }; michael@0: michael@0: var alertDialog = function (message, title, button) { michael@0: console.log("alertDialog()"); michael@0: navigator.notification.alert(message, michael@0: function () { michael@0: console.log("Alert dismissed."); michael@0: }, michael@0: title, button); michael@0: console.log("After alert"); michael@0: }; michael@0: michael@0: var confirmDialogA = function (message, title, buttons) { michael@0: clearLog(); michael@0: navigator.notification.confirm(message, michael@0: function (r) { michael@0: if (r === 0) { michael@0: logMessage("Dismissed dialog without making a selection."); michael@0: console.log("Dismissed dialog without making a selection."); michael@0: } else { michael@0: console.log("You selected " + r); michael@0: logMessage("You selected " + (buttons.split(","))[r - 1]); michael@0: } michael@0: }, michael@0: title, michael@0: buttons); michael@0: }; michael@0: michael@0: var confirmDialogB = function (message, title, buttons) { michael@0: clearLog(); michael@0: navigator.notification.confirm(message, michael@0: function (r) { michael@0: if (r === 0) { michael@0: logMessage("Dismissed dialog without making a selection."); michael@0: console.log("Dismissed dialog without making a selection."); michael@0: } else { michael@0: console.log("You selected " + r); michael@0: logMessage("You selected " + buttons[r - 1]); michael@0: } michael@0: }, michael@0: title, michael@0: buttons); michael@0: }; michael@0: michael@0: var promptDialog = function (message, title, buttons) { michael@0: clearLog(); michael@0: navigator.notification.prompt(message, michael@0: function (r) { michael@0: if (r && r.buttonIndex === 0) { michael@0: var msg = "Dismissed dialog"; michael@0: if (r.input1) { michael@0: msg += " with input: " + r.input1 michael@0: } michael@0: logMessage(msg); michael@0: console.log(msg); michael@0: } else { michael@0: console.log("You selected " + r.buttonIndex + " and entered: " + r.input1); michael@0: logMessage("You selected " + buttons[r.buttonIndex - 1] + " and entered: " + r.input1); michael@0: } michael@0: }, michael@0: title, michael@0: buttons); michael@0: }; michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: var dialogs_tests = '
' + michael@0: 'Expected result: Device will beep (unless device is on silent). Nothing will get updated in status box.' + michael@0: '