Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE0F59537 for ; Mon, 9 Apr 2012 22:40:31 +0000 (UTC) Received: (qmail 10688 invoked by uid 500); 9 Apr 2012 22:40:31 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 10626 invoked by uid 500); 9 Apr 2012 22:40:31 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 9869 invoked by uid 99); 9 Apr 2012 22:40:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2012 22:40:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 78647BEAB; Mon, 9 Apr 2012 22:40:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: purplecabbage@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [30/34] updated mobile spec tests for CordovaJS Message-Id: <20120409224030.78647BEAB@tyr.zones.apache.org> Date: Mon, 9 Apr 2012 22:40:30 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js index eb7758c..7890b40 100644 --- a/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js +++ b/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js @@ -21,39 +21,70 @@ Tests.prototype.GeoLocationTests = function() { }); test("getCurrentPosition success callback should be called with a Position object", function() { expect(2); - QUnit.stop(Tests.TEST_TIMEOUT); + QUnit.stop(15000); var win = function(p) { ok(p.coords != null, "Position object returned in getCurrentPosition success callback has a 'coords' property."); ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback has a 'timestamp' property."); - start(); + QUnit.start(); }; - var fail = function() { start(); }; - navigator.geolocation.getCurrentPosition(win, fail); + var fail = function() { + ok(false, "Error callback fired, test failed."); + QUnit.start(); + }; + navigator.geolocation.getCurrentPosition(win, fail, { + maximumAge:300000 // 5 minutes maximum age of cached position + }); }); + test("getCurrentPosition success callback should be called with a cached Position", function() { + expect(1); + QUnit.stop(Tests.TEST_TIMEOUT); + var win = function(p) { + ok(p.coords instanceof Position, "Position object returned is an instance of Position"); + QUnit.start(); + }; + var fail = function(e) { + ok(false, "Error callback called, test failed."); + }; + navigator.geolocation.getCurrentPosition(win, fail, { + maximumAge:300000 // 5 minutes + }); + }); + test("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge to a very small number", function() { + expect(1); + QUnit.stop(Tests.TEST_TIMEOUT); + var win = function(p) { + ok(false, "success callback called, test failed."); + QUnit.start(); + }; + var fail = function(e) { + ok(true, "error callback called"); + QUnit.start(); + }; + navigator.geolocation.getCurrentPosition(win, fail, { + maximumAge: 0, + timeout: 0 + }); + }); // TODO: Need to test error callback... how? // TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?) - // TODO: Need to test options object passed in. Members that need to be tested so far include: - // - options.frequency: this is also labelled differently on some implementations (internval on iPhone/BlackBerry currently). - - -// module('Geolocation model'); -// test("should be able to define a Position object with coords and timestamp properties", function() { -// expect(3); -// var pos = new Position({}, new Date()); -// ok(pos != null, "new Position() should not be null."); -// ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should include a 'coords' property."); -// ok(typeof pos.timestamp != 'undefined' && pos.timestamp != null, "new Position() should include a 'timestamp' property."); -// }); -// test("should be able to define a Coordinates object with latitude, longitude, accuracy, altitude, heading, speed and altitudeAccuracy properties", function() { -// expect(8); -// var coords = new Coordinates(1,2,3,4,5,6,7); -// ok(coords != null, "new Coordinates() should not be null."); -// ok(typeof coords.latitude != 'undefined' && coords.latitude != null, "new Coordinates() should include a 'latitude' property."); -// ok(typeof coords.longitude != 'undefined' && coords.longitude != null, "new Coordinates() should include a 'longitude' property."); -// ok(typeof coords.accuracy != 'undefined' && coords.accuracy != null, "new Coordinates() should include a 'accuracy' property."); -// ok(typeof coords.altitude != 'undefined' && coords.altitude != null, "new Coordinates() should include a 'altitude' property."); -// ok(typeof coords.heading != 'undefined' && coords.heading != null, "new Coordinates() should include a 'heading' property."); -// ok(typeof coords.speed != 'undefined' && coords.speed != null, "new Coordinates() should include a 'speed' property."); -// ok(typeof coords.altitudeAccuracy != 'undefined' && coords.altitudeAccuracy != null, "new Coordinates() should include a 'altitudeAccuracy' property."); -// }); -}; \ No newline at end of file + module('Geolocation model'); + test("should be able to define a Position object with coords and timestamp properties", function() { + expect(3); + var pos = new Position({}, new Date()); + ok(pos != null, "new Position() should not be null."); + ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should include a 'coords' property."); + ok(typeof pos.timestamp != 'undefined' && pos.timestamp != null, "new Position() should include a 'timestamp' property."); + }); + test("should be able to define a Coordinates object with latitude, longitude, accuracy, altitude, heading, speed and altitudeAccuracy properties", function() { + expect(8); + var coords = new Coordinates(1,2,3,4,5,6,7); + ok(coords != null, "new Coordinates() should not be null."); + ok(typeof coords.latitude != 'undefined' && coords.latitude != null, "new Coordinates() should include a 'latitude' property."); + ok(typeof coords.longitude != 'undefined' && coords.longitude != null, "new Coordinates() should include a 'longitude' property."); + ok(typeof coords.accuracy != 'undefined' && coords.accuracy != null, "new Coordinates() should include a 'accuracy' property."); + ok(typeof coords.altitude != 'undefined' && coords.altitude != null, "new Coordinates() should include a 'altitude' property."); + ok(typeof coords.heading != 'undefined' && coords.heading != null, "new Coordinates() should include a 'heading' property."); + ok(typeof coords.speed != 'undefined' && coords.speed != null, "new Coordinates() should include a 'speed' property."); + ok(typeof coords.altitudeAccuracy != 'undefined' && coords.altitudeAccuracy != null, "new Coordinates() should include a 'altitudeAccuracy' property."); + }); +}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js index dc47d19..cf6ded4 100644 --- a/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js +++ b/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js @@ -1,185 +1,152 @@ -// -// @TODO Update to Latest HTML5 Audio Element Spec -// @see http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#audio -// -Tests.prototype.MediaTests = function () { - module('Media (Audio)'); - - var srcLocalMediaFile = "test.wav"; - var srcNetworkMediaFile = "http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"; - - var srcDummyFile = "some link to media file"; - var media = new Media(srcDummyFile, null, null); - - test("should exist", function () { - expect(1); - ok(typeof Audio === "function" || typeof Audio === "object", "'Audio' should be defined as a function in global scope."); - }); - test("should define constants for Media errors", function () { - expect(9); - ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists in global scope."); - equals(MediaError.MEDIA_ERR_PLAY_MODE_SET, 1, "MediaError.MEDIA_ERR_PLAY_MODE_SET is equal to 1."); - equals(MediaError.MEDIA_ERR_ALREADY_RECORDING, 2, "MediaError.MEDIA_ERR_ALREADY_RECORDING is equal to 2."); - equals(MediaError.MEDIA_ERR_STARTING_RECORDING, 3, "MediaError.MEDIA_ERR_STARTING_RECORDING is equal to 3."); - equals(MediaError.MEDIA_ERR_RECORD_MODE_SET, 4, "MediaError.MEDIA_ERR_RECORD_MODE_SET is equal to 4."); - equals(MediaError.MEDIA_ERR_STARTING_PLAYBACK, 5, "MediaError.MEDIA_ERR_STARTING_PLAYBACK is equal to 5."); - equals(MediaError.MEDIA_ERR_RESUME_STATE, 6, "MediaError.MEDIA_ERR_DECODE is equal to 6."); - equals(MediaError.MEDIA_ERR_PAUSE_STATE, 7, "MediaError.MEDIA_ERR_PAUSE_STATE is equal to 7."); - equals(MediaError.MEDIA_ERR_STOP_STATE, 8, "MediaError.MEDIA_ERR_STOP_STATE is equal to 8."); - }); - - test("should contain 'src', 'loop' and 'error' properties", function () { - expect(7); - var audioSrc = '/test.mp3'; - var audio = new Audio(audioSrc); - ok(typeof audio == "object", "Instantiated 'Audio' object instance should be of type 'object.'"); - ok(audio.src != null && typeof audio.src != 'undefined', "Instantiated 'Audio' object's 'src' property should not be null or undefined."); - ok(audio.src.indexOf(audioSrc) >= 0, "Instantiated 'Audio' object's 'src' property should match constructor parameter."); - ok(audio.loop != null && typeof audio.loop != 'undefined', "Instantiated 'Audio' object's 'loop' property should not be null or undefined."); - ok(audio.loop == false, "Instantiated 'Audio' object's 'loop' property should initially be false."); - ok(typeof audio.error != 'undefined', "Instantiated 'Audio' object's 'error' property should not undefined."); - ok(audio.error == null, "Instantiated 'Audio' object's 'error' should initially be null."); - }); - - test("Media constructor should exist", function () { - expect(1); - ok(media != null, "media1 should not be null."); - }); - - test("should contain an play function", function () { +Tests.prototype.MediaTests = function() { + module('Media'); + test("should exist", function() { + expect(1); + ok(typeof Media === "function" || typeof Media === "object", "'Media' should be defined as a function in global scope."); + }); + test("should have the following properties", function() { + var media1 = new Media("dummy"); + expect(4); + ok(typeof media1.id != 'undefined' && media1.id != null, "'Media' should have an id property."); + ok(typeof media1.src != 'undefined', "'Media' should have an src property."); + ok(typeof media1._duration != 'undefined' && media1._duration != null, "'Media' should have an _duration property."); + ok(typeof media1._position != 'undefined' && media1._position != null, "'Media' should have an _position property."); + media1.release(); + }); + test("should define constants for Media errors", function() { + expect(6); + ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists in global scope."); + equals(MediaError.MEDIA_ERR_NONE_ACTIVE, 0, "MediaError.MEDIA_ERR_NONE_ACTIVE is equal to 0."); + equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to 1."); + equals(MediaError.MEDIA_ERR_NETWORK, 2, "MediaError.MEDIA_ERR_NETWORK is equal to 2."); + equals(MediaError.MEDIA_ERR_DECODE, 3, "MediaError.MEDIA_ERR_DECODE is equal to 3."); + equals(MediaError.MEDIA_ERR_NONE_SUPPORTED, 4, "MediaError.MEDIA_ERR_NONE_SUPPORTED is equal to 4."); + }); + test("should contain a play function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.play != 'undefined' && media.play != null, "media.play should not be null."); - ok(typeof media.play == 'function', "media.play should be a function."); + ok(typeof media1.play != 'undefined' && media1.play != null, "Media.play should not be null."); + ok(typeof media1.play == 'function', "Media.play should be a function."); + media1.release(); }); - - test("should contain an pause function", function () { + test("should contain a stop function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.pause != 'undefined' && media.pause != null, "media.pause should not be null."); - ok(typeof media.pause == 'function', "media.pause should be a function."); + ok(typeof media1.stop != 'undefined' && media1.stop != null, "Media.stop should not be null."); + ok(typeof media1.stop == 'function', "Media.stop should be a function."); + media1.release(); }); - - test("should contain an stop function", function () { + test("should contain a seekTo function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.stop != 'undefined' && media.stop != null, "media.stop should not be null."); - ok(typeof media.stop == 'function', "media.stop should be a function."); + ok(typeof media1.seekTo != 'undefined' && media1.seekTo != null, "Media.seekTo should not be null."); + ok(typeof media1.seekTo == 'function', "Media.seekTo should be a function."); + media1.release(); }); - - test("should contain an seekTo function", function () { + test("should contain a pause function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.seekTo != 'undefined' && media.seekTo != null, "media.seekTo should not be null."); - ok(typeof media.seekTo == 'function', "media.seekTo should be a function."); + ok(typeof media1.pause != 'undefined' && media1.pause != null, "Media.pause should not be null."); + ok(typeof media1.pause == 'function', "Media.pause should be a function."); + media1.release(); }); - - test("should contain an getDuration function", function () { + test("should contain a getDuration function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.getDuration != 'undefined' && media.getDuration != null, "media.getDuration should not be null."); - ok(typeof media.getDuration == 'function', "media.getDuration should be a function."); + ok(typeof media1.getDuration != 'undefined' && media1.getDuration != null, "Media.getDuration should not be null."); + ok(typeof media1.getDuration == 'function', "Media.getDuration should be a function."); + media1.release(); }); - - test("should contain an getCurrentPosition function", function () { + test("should contain a getCurrentPosition function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.getCurrentPosition != 'undefined' && media.getCurrentPosition != null, "media.getCurrentPosition should not be null."); - ok(typeof media.getCurrentPosition == 'function', "media.getCurrentPosition should be a function."); + ok(typeof media1.getCurrentPosition != 'undefined' && media1.getCurrentPosition != null, "Media.getCurrentPosition should not be null."); + ok(typeof media1.getCurrentPosition == 'function', "Media.getCurrentPosition should be a function."); + media1.release(); }); - - test("should contain an release function", function () { + test("should contain a startRecord function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.release != 'undefined' && media.release != null, "media.release should not be null."); - ok(typeof media.release == 'function', "media.release should be a function."); + ok(typeof media1.startRecord != 'undefined' && media1.startRecord != null, "Media.startRecord should not be null."); + ok(typeof media1.startRecord == 'function', "Media.startRecord should be a function."); + media1.release(); }); - - test("should contain an startRecord function", function () { + test("should contain a stopRecord function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.startRecord != 'undefined' && media.startRecord != null, "media.startRecord should not be null."); - ok(typeof media.startRecord == 'function', "media.startRecord should be a function."); + ok(typeof media1.stopRecord != 'undefined' && media1.stopRecord != null, "Media.stopRecord should not be null."); + ok(typeof media1.stopRecord == 'function', "Media.stopRecord should be a function."); + media1.release(); }); - - test("should contain an stopRecord function", function () { + test("should contain a release function", function() { + var media1 = new Media(); expect(2); - ok(typeof media.stopRecord != 'undefined' && media.stopRecord != null, "media.stopRecord should not be null."); - ok(typeof media.stopRecord == 'function', "media.stopRecord should be a function."); + ok(typeof media1.release != 'undefined' && media1.release != null, "Media.release should not be null."); + ok(typeof media1.release == 'function', "Media.release should be a function."); + media1.release(); }); - - test("should Cordova.Media.onStatus exist", function () { - expect(1); - ok(typeof Cordova.Media.onStatus === "function" || typeof Cordova.Media.onStatus === "object", "'Audio' should be defined as a function in global scope."); - }); - - test("record audio", function () { - var media2 = new Media(srcLocalMediaFile, - null, - function (err) { - QUnit.start(); - }, - function (status) { - ok(status !== null, "status should not be null."); - - if (typeof (media2.statusFlag) == 'undefined') { - equal(status, 2, "Should receive status MEDIA_RUNNING"); - media2.statusFlag = true; - - var recInterval = setInterval(function () { - clearInterval(recInterval); - media2.stopRecord(); - }, 1000); - - } - else { - equal(status, 4, "Should receive status MEDIA_STOPPED"); - QUnit.start(); - } - }); - - QUnit.stop(Tests.TEST_TIMEOUT); - expect(4); - media2.startRecord(); - - }); - - test("play file that doesn't exist", function () { - - var src = "wrongSrc"; - - var media3 = new Media(src, - null, - function (err) { - ok(err !== null, "error should not be null."); - equal(err, MediaError.MEDIA_ERR_STARTING_PLAYBACK, "Should receive error code MEDIA_ERR_STARTING_PLAYBACK"); - QUnit.start(); - }); - - QUnit.stop(Tests.TEST_TIMEOUT); + test("should contain a setVolume function", function() { + var media1 = new Media(); expect(2); - media3.play(); - }); - - test("play internet audio", function () { - var media2a = new Media(srcNetworkMediaFile, - null, - function (err) { - console.log("playAudio():Audio Error: " + err); + ok(typeof media1.setVolume != 'undefined' && media1.setVolume != null, "Media.setVolume should not be null."); + ok(typeof media1.setVolume == 'function', "Media.setVolume should be a function."); + media1.release(); + }); + test("should return MediaError for bad filename", function() { + expect(2); + QUnit.stop(10000); + var badMedia = null; + var releaseMedia = function() { + badMedia.release(); + }; + var win = function() { + ok(0, "should NOT succeed with bad media file name"); + releaseMedia(); + QUnit.start(); + }; + var fail = function(result){ + ok(typeof result == 'object', "Object returned in media.play failure callback is of type 'object' (actually MediaError)."); + ok(result.code == MediaError.MEDIA_ERR_ABORTED, "Object returned in media.find failure callback has a code property which equal to MediaError.MEDIA_ERR_ABORTED"); + releaseMedia(); + QUnit.start(); + }; + badMedia = new Media("invalid.file.name", win,fail); + badMedia.play(); + }); + test("position should be set properly", function() { + var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"); + media1.play(); + expect(1); + QUnit.stop(15000); + setTimeout( + function() { + media1.getCurrentPosition( + function(position) { + console.log("position = " + position); + ok(position >= 0.0, "position should not be -1"); + QUnit.start(); + media1.stop() + media1.release(); + }, + function(e) { + QUnit.start(); + } + ); + } + , 5000); + }); + test("duration should be set properly", function() { + var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"); + media1.play(); + expect(1); + QUnit.stop(15000); + setTimeout( + function() { + ok(media1.getDuration() >= 0.0, "duration should not be -1"); QUnit.start(); - }, - function (status) { - ok(status !== null, "status should not be null."); - - if (typeof (media2a.statusFlag) == 'undefined') { - equal(status, 1, "Should receive status MEDIA_STARTING"); - media2a.statusFlag = 1; - - } else if (media2a.statusFlag === 1) { - equal(status, 2, "Should receive status MEDIA_RUNNING"); - media2a.statusFlag = 2; - media2a.stop(); - } else { - equal(status, 4, "Should receive status MEDIA_STOPPED"); - QUnit.start(); - } - }); - - QUnit.stop(10000); - expect(6); - media2a.play(); - + media1.stop() + media1.release(); + } + , 5000); }); }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js new file mode 100644 index 0000000..67fb28c --- /dev/null +++ b/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js @@ -0,0 +1,37 @@ +Tests.prototype.PlatformTests = function() { + module('Platform (cordova)'); + test("should exist", function() { + expect(1); + ok(typeof cordova != 'undefined' && cordova != null, "cordova should not be null."); + }); + module('Platform (Cordova)'); + test("should not exist", function() { + expect(1); + ok(typeof Cordova == 'undefined', "Cordova should be null."); + }); + module('Platform (PhoneGap)'); + test("should exist", function() { + expect(1); + ok(typeof PhoneGap != 'undefined' && PhoneGap != null, "PhoneGap should not be null."); + }); + test("exec method should exist", function() { + expect(2); + ok(typeof PhoneGap.exec != 'undefined' && PhoneGap.exec != null, "PhoneGap.exec should not be null."); + ok(typeof PhoneGap.exec == 'function', "PhoneGap.exec should be a function."); + }); + test("addPlugin method should exist", function() { + expect(2); + ok(typeof PhoneGap.addPlugin != 'undefined' && PhoneGap.addPlugin != null, "PhoneGap.addPlugin should not be null."); + ok(typeof PhoneGap.addPlugin == 'function', "PhoneGap.addPlugin should be a function."); + }); + test("addConstructor method should exist", function() { + expect(2); + ok(typeof PhoneGap.addConstructor != 'undefined' && PhoneGap.addConstructor != null, "PhoneGap.addConstructor should not be null."); + ok(typeof PhoneGap.addConstructor == 'function', "PhoneGap.addConstructor should be a function."); + }); + module('Platform (window.plugins)'); + test("should exist", function() { + expect(1); + ok(typeof window.plugins != 'undefined' && window.plugins != null, "window.plugins should not be null."); + }); +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js index e5dd028..41476d8 100644 --- a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js +++ b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js @@ -1,7 +1,6 @@ Tests.prototype.StorageTests = function() { module("Session Storage"); - test("should exist", function() { expect(7); ok(window.sessionStorage != null, "sessionStorage is defined"); @@ -12,7 +11,6 @@ Tests.prototype.StorageTests = function() ok(typeof(window.sessionStorage.removeItem) == "function", "sessionStorage.removeItem is defined"); ok(typeof(window.sessionStorage.clear) == "function", "sessionStorage.clear is defined"); }); - test("check length", function() { expect(3); ok(window.sessionStorage.length == 0, "length should be 0"); @@ -21,9 +19,6 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("key"); ok(window.sessionStorage.length == 0, "length should be 0"); }); - - - test("check key", function() { expect(3); ok(window.sessionStorage.key(0) == null, "key should be null"); @@ -32,7 +27,6 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("test"); ok(window.sessionStorage.key(0) == null, "key should be null"); }); - test("check getItem", function() { expect(3); ok(window.sessionStorage.getItem("item") == null, "item should be null"); @@ -41,7 +35,6 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("item"); ok(window.sessionStorage.getItem("item") == null, "item should be null"); }); - test("check setItem", function() { expect(4); ok(window.sessionStorage.getItem("item") == null, "item should be null"); @@ -52,7 +45,6 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("item"); ok(window.sessionStorage.getItem("item") == null, "item should be null"); }); - test("check removeItem", function() { expect(3); ok(window.sessionStorage.getItem("item") == null, "item should be null"); @@ -61,7 +53,6 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("item"); ok(window.sessionStorage.getItem("item") == null, "item should be null"); }); - test("check clear", function() { expect(11); ok(window.sessionStorage.getItem("item1") == null, "item1 should be null"); @@ -80,7 +71,6 @@ Tests.prototype.StorageTests = function() ok(window.sessionStorage.getItem("item2") == null, "item2 should be null"); ok(window.sessionStorage.getItem("item3") == null, "item3 should be null"); }); - test("check dot notation", function() { expect(3); ok(window.sessionStorage.item == null, "item should be null"); @@ -89,9 +79,7 @@ Tests.prototype.StorageTests = function() window.sessionStorage.removeItem("item"); ok(window.sessionStorage.item == null, "item should be null"); }); - module("Local Storage"); - test("should exist", function() { expect(7); ok(window.localStorage != null, "localStorage is defined"); @@ -102,7 +90,6 @@ Tests.prototype.StorageTests = function() ok(typeof(window.localStorage.removeItem) == "function", "localStorage.removeItem is defined"); ok(typeof(window.localStorage.clear) == "function", "localStorage.clear is defined"); }); - test("check length", function() { expect(3); ok(window.localStorage.length == 0, "length should be 0"); @@ -111,7 +98,6 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("key"); ok(window.localStorage.length == 0, "length should be 0"); }); - test("check key", function() { expect(3); ok(window.localStorage.key(0) == null, "key should be null"); @@ -120,7 +106,6 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("test"); ok(window.localStorage.key(0) == null, "key should be null"); }); - test("check getItem", function() { expect(3); ok(window.localStorage.getItem("item") == null, "item should be null"); @@ -129,7 +114,6 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("item"); ok(window.localStorage.getItem("item") == null, "item should be null"); }); - test("check setItem", function() { expect(4); ok(window.localStorage.getItem("item") == null, "item should be null"); @@ -140,7 +124,6 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("item"); ok(window.localStorage.getItem("item") == null, "item should be null"); }); - test("check removeItem", function() { expect(3); ok(window.localStorage.getItem("item") == null, "item should be null"); @@ -149,7 +132,6 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("item"); ok(window.localStorage.getItem("item") == null, "item should be null"); }); - test("check clear", function() { expect(11); ok(window.localStorage.getItem("item1") == null, "item1 should be null"); @@ -168,7 +150,6 @@ Tests.prototype.StorageTests = function() ok(window.localStorage.getItem("item2") == null, "item2 should be null"); ok(window.localStorage.getItem("item3") == null, "item3 should be null"); }); - test("check dot notation", function() { expect(3); ok(window.localStorage.item == null, "item should be null"); @@ -177,12 +158,7 @@ Tests.prototype.StorageTests = function() window.localStorage.removeItem("item"); ok(window.localStorage.item == null, "item should be null"); }); - - - - /* module("HTML 5 Storage"); - test("should exist", function() { expect(1); ok(typeof(window.openDatabase) == "function", "Database is defined"); @@ -191,5 +167,4 @@ Tests.prototype.StorageTests = function() var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000); ok(db != null, "Database should be opened"); }); - */ } http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/battery/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/battery/index.html b/tests/MobileSpecUnitTests/www/battery/index.html new file mode 100644 index 0000000..593104a --- /dev/null +++ b/tests/MobileSpecUnitTests/www/battery/index.html @@ -0,0 +1,96 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Battery

+
+ Status:
+ Level:
+ Plugged:
+ Low:
+ Critical:
+
+

Action

+
Add "batterystatus" listener
+
Remove "batterystatus" listener
+
Add "batterylow" listener
+
Remove "batterylow" listener
+
Add "batterycritical" listener
+
Remove "batterycritical" listener
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/camera/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/camera/index.html b/tests/MobileSpecUnitTests/www/camera/index.html new file mode 100644 index 0000000..2e27da5 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/camera/index.html @@ -0,0 +1,96 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Camera

+
+ Status:
+ +
+

Action

+
Take Picture
+
Select Image from Library
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/compass/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/compass/index.html b/tests/MobileSpecUnitTests/www/compass/index.html new file mode 100644 index 0000000..3bc4d9b --- /dev/null +++ b/tests/MobileSpecUnitTests/www/compass/index.html @@ -0,0 +1,128 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Compass

+
+ Status: Stopped + + +
Heading:
+
+

Action

+
Get Compass
+
Start Watching Compass
+
Stop Watching Compass
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/contacts/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/contacts/index.html b/tests/MobileSpecUnitTests/www/contacts/index.html new file mode 100644 index 0000000..c646db1 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/contacts/index.html @@ -0,0 +1,112 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Contacts

+
+ Results:
+ +
+

Action

+
Get phone's contacts
+
Add a new contact 'Dooney Evans'
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/events/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/events/index.html b/tests/MobileSpecUnitTests/www/events/index.html new file mode 100644 index 0000000..6ce3ae6 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/events/index.html @@ -0,0 +1,72 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Events

+
+ Results:
+ +
+ +

Action

+
Intercept backbutton
+
Stop intercept of backbutton
+
Intercept menubutton
+
Stop intercept of menubutton
+
Intercept searchbutton
+
Stop intercept of searchbutton
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/index.html b/tests/MobileSpecUnitTests/www/index.html index 22b4230..9bc5b52 100644 --- a/tests/MobileSpecUnitTests/www/index.html +++ b/tests/MobileSpecUnitTests/www/index.html @@ -1,73 +1,36 @@ - + - - - - Cordova Tests - - - - - - - + + + Cordova Mobile Spec + + + - +

PhoneGap Tests

-

Platform:

-

Version:

-

UUID:

-

Name:

-

Width: - , Height: - , Color Depth: -

-

CordovaVersion:

+

Platform:

+

Version:

+

UUID:

+

Name:

+

Width: , Height: + , Color Depth:

- - Automatic Test + Accelerometer + Audio Play/Record + Battery + Camera + Compass + Contacts + Events + Location + Misc Content + Notification + Web SQL + Local Storage http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/location/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/location/index.html b/tests/MobileSpecUnitTests/www/location/index.html new file mode 100644 index 0000000..438bfbb --- /dev/null +++ b/tests/MobileSpecUnitTests/www/location/index.html @@ -0,0 +1,123 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Location

+
+ Status: Stopped + + + +
Latitude:
Longitude:
+
+

Action

+
Get Location
+
Start Watching Location
+
Stop Watching Location
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/main.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/main.js b/tests/MobileSpecUnitTests/www/main.js new file mode 100644 index 0000000..ae447aa --- /dev/null +++ b/tests/MobileSpecUnitTests/www/main.js @@ -0,0 +1,140 @@ +var deviceInfo = function() { + document.getElementById("platform").innerHTML = device.platform; + document.getElementById("version").innerHTML = device.version; + document.getElementById("uuid").innerHTML = device.uuid; + document.getElementById("name").innerHTML = device.name; + document.getElementById("width").innerHTML = screen.width; + document.getElementById("height").innerHTML = screen.height; + document.getElementById("colorDepth").innerHTML = screen.colorDepth; +}; + +var getLocation = function() { + var suc = function(p) { + alert(p.coords.latitude + " " + p.coords.longitude); + }; + var locFail = function() { + }; + navigator.geolocation.getCurrentPosition(suc, locFail); +}; + +var beep = function() { + navigator.notification.beep(2); +}; + +var vibrate = function() { + navigator.notification.vibrate(0); +}; + +function roundNumber(num) { + var dec = 3; + var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); + return result; +} + +var accelerationWatch = null; + +function updateAcceleration(a) { + document.getElementById('x').innerHTML = roundNumber(a.x); + document.getElementById('y').innerHTML = roundNumber(a.y); + document.getElementById('z').innerHTML = roundNumber(a.z); +} + +var toggleAccel = function() { + if (accelerationWatch !== null) { + navigator.accelerometer.clearWatch(accelerationWatch); + updateAcceleration({ + x : "", + y : "", + z : "" + }); + accelerationWatch = null; + } else { + var options = {}; + options.frequency = 1000; + accelerationWatch = navigator.accelerometer.watchAcceleration( + updateAcceleration, function(ex) { + alert("accel fail (" + ex.name + ": " + ex.message + ")"); + }, options); + } +}; + +var preventBehavior = function(e) { + e.preventDefault(); +}; + +function dump_pic(data) { + var viewport = document.getElementById('viewport'); + console.log(data); + viewport.style.display = ""; + viewport.style.position = "absolute"; + viewport.style.top = "10px"; + viewport.style.left = "10px"; + document.getElementById("test_img").src = "data:image/jpeg;base64," + data; +} + +function fail(msg) { + alert(msg); +} + +function show_pic() { + navigator.camera.getPicture(dump_pic, fail, { + quality : 50 + }); +} + +function close() { + var viewport = document.getElementById('viewport'); + viewport.style.position = "relative"; + viewport.style.display = "none"; +} + +// This is just to do this. +function readFile() { + navigator.file.read('/sdcard/phonegap.txt', fail, fail); +} + +function writeFile() { + navigator.file.write('foo.txt', "This is a test of writing to a file", + fail, fail); +} + +function contacts_success(contacts) { + alert(contacts.length + + ' contacts returned.' + + (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted) + : '')); +} + +function get_contacts() { + var obj = new ContactFindOptions(); + obj.filter = ""; + obj.multiple = true; + obj.limit = 5; + navigator.service.contacts.find( + [ "displayName", "name" ], contacts_success, + fail, obj); +} + +var networkReachableCallback = function(reachability) { + // There is no consistency on the format of reachability + var networkState = reachability.code || reachability; + + var currentState = {}; + currentState[NetworkStatus.NOT_REACHABLE] = 'No network connection'; + currentState[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection'; + currentState[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection'; + + confirm("Connection type:\n" + currentState[networkState]); +}; + +function check_network() { + navigator.network.isReachable("www.mobiledevelopersolutions.com", + networkReachableCallback, {}); +} + +function init() { + // the next line makes it impossible to see Contacts on the HTC Evo since it + // doesn't have a scroll button + // document.addEventListener("touchmove", preventBehavior, false); + document.addEventListener("deviceready", deviceInfo, true); +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/master.css ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/master.css b/tests/MobileSpecUnitTests/www/master.css index f3f3717..2d427f3 100644 --- a/tests/MobileSpecUnitTests/www/master.css +++ b/tests/MobileSpecUnitTests/www/master.css @@ -1,12 +1,11 @@ - body { - background:#222 none repeat scroll 0 0; - color:#FFC312; - font-family:Helvetica, Verdana, Geneva, sans-serif; - font-size:72%; - line-height:1.5em; - margin:0; - border-top:1px solid #393939; + background:#222 none repeat scroll 0 0; + color:#666; + font-family:Helvetica; + font-size:72%; + line-height:1.5em; + margin:0; + border-top:1px solid #393939; } #info{ @@ -18,7 +17,6 @@ margin:15px 6px 0; width:295px; padding:4px 0px 2px 10px; - color:#666; } #info > h4{ @@ -91,10 +89,12 @@ padding:1.2em 0; margin:3px 0px 3px 5px; } - #stage.theme .btn.large{ + + #stage.theme .large{ width:308px; padding:1.2em 0; } + #stage.theme .backBtn{ border: 1px solid #555; -webkit-border-radius: 5px; http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/misc/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/misc/index.html b/tests/MobileSpecUnitTests/www/misc/index.html new file mode 100644 index 0000000..023678d --- /dev/null +++ b/tests/MobileSpecUnitTests/www/misc/index.html @@ -0,0 +1,59 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Display Other Content

+
+
+

Action

+
Call 411
+ Send Mail + Send SMS + Load Web Site + + + Load another PhoneGap page +

Android Only

+ Map IBM + Search Android market + View image app + +

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/misc/page2.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/misc/page2.html b/tests/MobileSpecUnitTests/www/misc/page2.html new file mode 100644 index 0000000..ee6c398 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/misc/page2.html @@ -0,0 +1,25 @@ + + + + + + Cordova Mobile Spec + + + + + + +

Page2 App

+

This is page 2 of a PhoneGap app

+
+

Platform:

+

Version:

+

UUID:

+

Name:

+

Width: , Height: + , Color Depth:

+
+
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/notification/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/notification/index.html b/tests/MobileSpecUnitTests/www/notification/index.html new file mode 100644 index 0000000..ac8be10 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/notification/index.html @@ -0,0 +1,81 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Notifications and Dialogs

+
+
+ +

Action

+
Beep
+
Vibrate
+
Alert Dialog
+
Confirm Dialog
+
Built-in Alert Dialog
+
Built-in Confirm Dialog
+
Built-in Prompt Dialog
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/phonegap.js ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/phonegap.js b/tests/MobileSpecUnitTests/www/phonegap.js new file mode 100644 index 0000000..044a06b --- /dev/null +++ b/tests/MobileSpecUnitTests/www/phonegap.js @@ -0,0 +1,13 @@ +document.write(''); +document.write(''); +document.write(''); + +function backHome() { + + if (window.device && device.platform && device.platform.toLowerCase() == 'android') { + navigator.app.backHistory(); + } + else { + window.history.go(-1); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/sql/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/sql/index.html b/tests/MobileSpecUnitTests/www/sql/index.html new file mode 100644 index 0000000..cae19ce --- /dev/null +++ b/tests/MobileSpecUnitTests/www/sql/index.html @@ -0,0 +1,132 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

HTML5 Database

+
+ Results:
+ +
+

Action

+
Create, Add, Read Database
+
Read Database
+

Back
+ + http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5bca3c1a/tests/MobileSpecUnitTests/www/storage/index.html ---------------------------------------------------------------------- diff --git a/tests/MobileSpecUnitTests/www/storage/index.html b/tests/MobileSpecUnitTests/www/storage/index.html new file mode 100644 index 0000000..d638a29 --- /dev/null +++ b/tests/MobileSpecUnitTests/www/storage/index.html @@ -0,0 +1,50 @@ + + + + + + Cordova Mobile Spec + + + + + + + + + +

Local Storage

+
+ You have run this app an untold number of time(s). +
+ + + +

Back
+ +