http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/camera.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/camera.tests.js b/windows8/test/autotest/tests/camera.tests.js index 3324185..ee5bacd 100644 --- a/windows8/test/autotest/tests/camera.tests.js +++ b/windows8/test/autotest/tests/camera.tests.js @@ -1,3 +1,24 @@ +/* + * + * 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('Camera (navigator.camera)', function () { it("should exist", function() { expect(navigator.camera).toBeDefined(); @@ -10,25 +31,27 @@ describe('Camera (navigator.camera)', function () { }); describe('Camera Constants (window.Camera + navigator.camera)', function () { - it("window.Camera should exist", function() { + it("camera.spec.1 window.Camera should exist", function() { expect(window.Camera).toBeDefined(); }); - it("should contain two DestinationType constants", function() { + it("camera.spec.2 should contain three DestinationType constants", function() { expect(Camera.DestinationType.DATA_URL).toBe(0); expect(Camera.DestinationType.FILE_URI).toBe(1); + expect(Camera.DestinationType.NATIVE_URI).toBe(2); expect(navigator.camera.DestinationType.DATA_URL).toBe(0); expect(navigator.camera.DestinationType.FILE_URI).toBe(1); + expect(navigator.camera.DestinationType.NATIVE_URI).toBe(2); }); - it("should contain two EncodingType constants", function() { + it("camera.spec.3 should contain two EncodingType constants", function() { expect(Camera.EncodingType.JPEG).toBe(0); expect(Camera.EncodingType.PNG).toBe(1); expect(navigator.camera.EncodingType.JPEG).toBe(0); expect(navigator.camera.EncodingType.PNG).toBe(1); }); - it("should contain three MediaType constants", function() { + it("camera.spec.4 should contain three MediaType constants", function() { expect(Camera.MediaType.PICTURE).toBe(0); expect(Camera.MediaType.VIDEO).toBe(1); expect(Camera.MediaType.ALLMEDIA).toBe(2); @@ -36,7 +59,7 @@ describe('Camera Constants (window.Camera + navigator.camera)', function () { expect(navigator.camera.MediaType.VIDEO).toBe(1); expect(navigator.camera.MediaType.ALLMEDIA).toBe(2); }); - it("should contain three PictureSourceType constants", function() { + it("camera.spec.5 should contain three PictureSourceType constants", function() { expect(Camera.PictureSourceType.PHOTOLIBRARY).toBe(0); expect(Camera.PictureSourceType.CAMERA).toBe(1); expect(Camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); @@ -44,149 +67,4 @@ describe('Camera Constants (window.Camera + navigator.camera)', function () { expect(navigator.camera.PictureSourceType.CAMERA).toBe(1); expect(navigator.camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); }); - }); - -describe('Test getPicture function', function () { - it("should retrieve a base64 data when DestinationType equals DATA_URL", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageData) { - var image = new Image(); - image.src = "data:image/jpeg;base64," + imageData; - - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - console.log(message); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.DATA_URL, saveToPhotoAlbum: true, targetHeight: 600, targetWidth: 800 }); - }); - - waitsFor(function () { return onPhotoDataSuccess.wasCalled; }, "Insert callback never called", 30000); - - runs(function () { - expect(onPhotoDataSuccess).toHaveBeenCalled(); - expect(onFail).not.toHaveBeenCalled(); - }) - }) - - it("should retrieve a URI when DestinationType equals FILE_URL", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageURI) { - var image = new Image(); - image.src = imageURI; - //console.log("src=" + image.src); - expect(String(image.src).substr(0, 3)).toBe("ms-"); - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - console.log(message); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, saveToPhotoAlbum: true, targetHeight: 600, targetWidth: 800 }); - }); - - waitsFor(function () { return onPhotoDataSuccess.wasCalled; }, "Insert callback never called", 30000); - - runs(function () { - expect(onPhotoDataSuccess).toHaveBeenCalled(); - expect(onFail).not.toHaveBeenCalled(); - }) - }) - it("should retrieve a jpg when PictureSourceType equals PHOTOLIBRARY", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageURI) { - //expect(String(imageURI).substr(0, 3)).toBe('C:\\'); - var image = new Image(); - image.src = imageURI; - console.log("src=" + image.src); - expect(String(image.src).substr(0, 3)).toBe("ms-"); - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - console.log(message); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, targetWidth: 200, targetHeight: 150 }); - }); - - waitsFor(function () { return onPhotoDataSuccess.wasCalled; }, "Insert callback never called", 30000); - - runs(function () { - expect(onPhotoDataSuccess).toHaveBeenCalled(); - expect(onFail).not.toHaveBeenCalled(); - }) - }) - - it("should retrieve a png when EncodingType equals PNG", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageURI) { - var extensionArr = String(imageURI).split("."); - expect(extensionArr[extensionArr.length - 1]).toBe('png'); - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - console.log(message); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, saveToPhotoAlbum: true, encodingType: navigator.camera.EncodingType.PNG, targetWidth: 200, targetHeight: 150 }); - }); - - waitsFor(function () { return onPhotoDataSuccess.wasCalled; }, "Insert callback never called", 30000); - - runs(function () { - expect(onPhotoDataSuccess).toHaveBeenCalled(); - expect(onFail).not.toHaveBeenCalled(); - }) - }) - - - it("should retrieve nothing when mediaType is Video from photolibrary.(You must keep your photolibrary only to contain image files) ", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageURI) { - var image = new Image(); - image.src = imageURI; - //console.log("src=" + image.src); - expect(String(image.src).substr(0, 3)).toBe("ms-"); - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - expect(message).toBe("User didn't choose a file."); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, saveToPhotoAlbum: true, encodingType: navigator.camera.EncodingType.PNG, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, mediaType: navigator.camera.MediaType.VIDEO}); - }) - - waitsFor(function () { return onFail.wasCalled; }, "Insert callback never called", 10000); - - runs(function () { - expect(onPhotoDataSuccess).not.toHaveBeenCalled(); - expect(onFail).toHaveBeenCalled(); - }) - }) - - it("should retrieve a specific pixels when targetWidth or targetHeight is given.", function () { - var onPhotoDataSuccess = jasmine.createSpy().andCallFake(function (imageURI) { - // Todo: get the real pixels of the picture instead of finding it in the directory - var image = new Image(); - image.src = imageURI; - - image.onload = function () { - console.log(image.height); - expect(image.width).toBe(1280); - } - - }) - var onFail = jasmine.createSpy().andCallFake(function (message) { - console.log(message); - }) - - runs(function () { - navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, saveToPhotoAlbum: true, targetWidth: 1280, targetHeight: 960}); - }); - - waitsFor(function () { return onPhotoDataSuccess.wasCalled; }, "Insert callback never called", 30000); - - runs(function () { - expect(onPhotoDataSuccess).toHaveBeenCalled(); - expect(onFail).not.toHaveBeenCalled(); - }) - }) - -}); \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/capture.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/capture.tests.js b/windows8/test/autotest/tests/capture.tests.js index a490d11..25483dc 100644 --- a/windows8/test/autotest/tests/capture.tests.js +++ b/windows8/test/autotest/tests/capture.tests.js @@ -1,32 +1,53 @@ +/* + * + * 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('Capture (navigator.device.capture)', function () { - it("should exist", function() { + it("capture.spec.1 should exist", function() { expect(navigator.device).toBeDefined(); expect(navigator.device.capture).toBeDefined(); }); - it("should have the correct properties ", function() { + it("capture.spec.2 should have the correct properties ", function() { expect(navigator.device.capture.supportedAudioModes).toBeDefined(); expect(navigator.device.capture.supportedImageModes).toBeDefined(); expect(navigator.device.capture.supportedVideoModes).toBeDefined(); }); - it("should contain a captureAudio function", function() { + it("capture.spec.3 should contain a captureAudio function", function() { expect(navigator.device.capture.captureAudio).toBeDefined(); expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true); }); - it("should contain a captureImage function", function() { + it("capture.spec.4 should contain a captureImage function", function() { expect(navigator.device.capture.captureImage).toBeDefined(); expect(typeof navigator.device.capture.captureImage == 'function').toBe(true); }); - it("should contain a captureVideo function", function() { + it("capture.spec.5 should contain a captureVideo function", function() { expect(navigator.device.capture.captureVideo).toBeDefined(); expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true); }); describe('CaptureAudioOptions', function () { - it("CaptureAudioOptions constructor should exist", function() { + it("capture.spec.6 CaptureAudioOptions constructor should exist", function() { var options = new CaptureAudioOptions(); expect(options).toBeDefined(); expect(options.limit).toBeDefined(); @@ -36,7 +57,7 @@ describe('Capture (navigator.device.capture)', function () { }); describe('CaptureImageOptions', function () { - it("CaptureImageOptions constructor should exist", function() { + it("capture.spec.7 CaptureImageOptions constructor should exist", function() { var options = new CaptureImageOptions(); expect(options).toBeDefined(); expect(options.limit).toBeDefined(); @@ -45,7 +66,7 @@ describe('Capture (navigator.device.capture)', function () { }); describe('CaptureVideoOptions', function () { - it("CaptureVideoOptions constructor should exist", function() { + it("capture.spec.8 CaptureVideoOptions constructor should exist", function() { var options = new CaptureVideoOptions(); expect(options).toBeDefined(); expect(options.limit).toBeDefined(); @@ -55,14 +76,14 @@ describe('Capture (navigator.device.capture)', function () { }); describe('CaptureError interface', function () { - it("CaptureError constants should be defined", function() { + it("capture.spec.9 CaptureError constants should be defined", function() { expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0); expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1); expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2); expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3); }); - it("CaptureError properties should exist", function() { + it("capture.spec.10 CaptureError properties should exist", function() { var error = new CaptureError(); expect(error).toBeDefined(); expect(error.code).toBeDefined(); @@ -70,7 +91,7 @@ describe('Capture (navigator.device.capture)', function () { }); describe('MediaFileData', function () { - it("MediaFileData constructor should exist", function() { + it("capture.spec.11 MediaFileData constructor should exist", function() { var fileData = new MediaFileData(); expect(fileData).toBeDefined(); expect(fileData.bitrate).toBeDefined(); @@ -82,7 +103,7 @@ describe('Capture (navigator.device.capture)', function () { }); describe('MediaFile', function () { - it("MediaFile constructor should exist", function() { + it("capture.spec.12 MediaFile constructor should exist", function() { var fileData = new MediaFile(); expect(fileData).toBeDefined(); expect(fileData.name).toBeDefined(); @@ -92,171 +113,4 @@ describe('Capture (navigator.device.capture)', function () { expect(fileData.size).toBeDefined(); }); }); - - describe('Test captureAudio function', function () { - it("should capture a audio when the function invoked (w/ duration).", function () { - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - expect(mediaFiles[0].fullPath.substr(0, 3)).toBe("C:\\"); - // TODO: Check the recording result by yourself. - //console.log(mediaFiles.fullPath); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureAudio(captureSuccess , captureError , {duration:10}); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 30000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - }); - - describe('Test captureVideo function', function () { - it("should capture a video when the function invoked (w/ duration).", function () { - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - expect(mediaFiles[0].fullPath.substr(0, 3)).toBe("C:\\"); - // TODO: Check the video by yourself. - //console.log(mediaFiles.fullPath); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureVideo(captureSuccess, captureError, { duration: 10 }); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 70000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - }); - - describe('Test captureImage function', function () { - it("should capture a image when the function invoked.", function () { - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - expect(mediaFiles[0].fullPath.substr(0, 3)).toBe("C:\\"); - // TODO: Check the video by yourself. - //console.log(mediaFiles.fullPath); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureImage(captureSuccess, captureError); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 70000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - }); - - describe('Test getFormatData function', function () { - it("should get format data about image.", function () { - var success = jasmine.createSpy().andCallFake(function (mediaFileData) { - console.dir(mediaFileData); - expect(mediaFileData.codecs).toBeDefined(); - expect(mediaFileData.bitrate).toBe(0); - expect(mediaFileData.height).toBeDefined(); - expect(mediaFileData.width).toBeDefined(); - expect(mediaFileData.duration).toBe(0); - }) - var fail = jasmine.createSpy().andCallFake(function (error) {}) - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - runs(function () { - - mediaFiles.getFormatData(success, fail); - }); - waitsFor(function () { return success.wasCalled; }, "success callback never called", 7500); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureImage(captureSuccess, captureError); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 70000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - - it("should get format data about video.", function () { - var success = jasmine.createSpy().andCallFake(function (mediaFileData) { - console.dir(mediaFileData); - expect(mediaFileData.codecs).toBeDefined(); - expect(mediaFileData.bitrate).toBeDefined(); - expect(mediaFileData.height).toBeDefined(); - expect(mediaFileData.width).toBeDefined(); - expect(mediaFileData.duration).toBeDefined(); - }) - var fail = jasmine.createSpy().andCallFake(function (error) { }) - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - runs(function () { - - mediaFiles.getFormatData(success, fail); - }); - waitsFor(function () { return success.wasCalled; }, "success callback never called", 7500); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureVideo(captureSuccess, captureError, { duration: 10 }); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 70000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - - it("should get format data about audio.", function () { - var success = jasmine.createSpy().andCallFake(function (mediaFileData) { - console.dir(mediaFileData); - expect(mediaFileData.codecs).toBeDefined(); - expect(mediaFileData.bitrate).toBeDefined(); - expect(mediaFileData.height).toBe(0); - expect(mediaFileData.width).toBe(0); - expect(mediaFileData.duration).toBeDefined(); - }) - var fail = jasmine.createSpy().andCallFake(function (error) { }) - var captureSuccess = jasmine.createSpy().andCallFake(function (mediaFiles) { - runs(function () { - - mediaFiles.getFormatData(success, fail); - }); - waitsFor(function () { return success.wasCalled; }, "success callback never called", 7500); - }) - var captureError = jasmine.createSpy().andCallFake(function (error) { - console.log("code:" + error.code); - }) - runs(function () { - navigator.device.capture.captureAudio(captureSuccess, captureError, { duration: 10 }); - }); - - waitsFor(function () { return captureSuccess.wasCalled; }, "captureSuccess callback never called", 70000); - - runs(function () { - expect(captureSuccess).toHaveBeenCalled(); - expect(captureError).not.toHaveBeenCalled(); - }) - }); - }); }); http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/compass.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/compass.tests.js b/windows8/test/autotest/tests/compass.tests.js index d635e44..edaced2 100644 --- a/windows8/test/autotest/tests/compass.tests.js +++ b/windows8/test/autotest/tests/compass.tests.js @@ -1,24 +1,45 @@ +/* + * + * 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('Compass (navigator.compass)', function () { - it("should exist", function () { + it("compass.spec.1 should exist", function() { expect(navigator.compass).toBeDefined(); }); - it("should contain a getCurrentHeading function", function () { + it("compass.spec.2 should contain a getCurrentHeading function", function() { expect(navigator.compass.getCurrentHeading).toBeDefined(); - expect(typeof navigator.compass.getCurrentHeading == 'function').toBe(true); - }); + expect(typeof navigator.compass.getCurrentHeading == 'function').toBe(true); + }); - it("getCurrentHeading success callback should be called with a Heading object", function () { - var win = jasmine.createSpy().andCallFake(function (a) { - expect(a instanceof CompassHeading).toBe(true); - expect(a.magneticHeading).toBeDefined(); - expect(typeof a.magneticHeading == 'number').toBe(true); - expect(a.trueHeading).not.toBe(undefined); - expect(typeof a.trueHeading == 'number' || a.trueHeading === null).toBe(true); - expect(a.headingAccuracy).not.toBe(undefined); - expect(typeof a.headingAccuracy == 'number' || a.headingAccuracy === null).toBe(true); - expect(typeof a.timestamp == 'number').toBe(true); - }), + it("compass.spec.3 getCurrentHeading success callback should be called with a Heading object", function() { + var win = jasmine.createSpy().andCallFake(function(a) { + expect(a instanceof CompassHeading).toBe(true); + expect(a.magneticHeading).toBeDefined(); + expect(typeof a.magneticHeading == 'number').toBe(true); + expect(a.trueHeading).not.toBe(undefined); + expect(typeof a.trueHeading == 'number' || a.trueHeading === null).toBe(true); + expect(a.headingAccuracy).not.toBe(undefined); + expect(typeof a.headingAccuracy == 'number' || a.headingAccuracy === null).toBe(true); + expect(typeof a.timestamp == 'number').toBe(true); + }), fail = jasmine.createSpy(); runs(function () { @@ -31,20 +52,20 @@ describe('Compass (navigator.compass)', function () { expect(fail).not.toHaveBeenCalled(); expect(win).toHaveBeenCalled(); }); - }); + }); - it("should contain a watchHeading function", function () { + it("compass.spec.4 should contain a watchHeading function", function() { expect(navigator.compass.watchHeading).toBeDefined(); expect(typeof navigator.compass.watchHeading == 'function').toBe(true); }); - it("should contain a clearWatch function", function () { + it("compass.spec.5 should contain a clearWatch function", function() { expect(navigator.compass.clearWatch).toBeDefined(); expect(typeof navigator.compass.clearWatch == 'function').toBe(true); }); describe('Compass Constants (window.CompassError)', function () { - it("should exist", function () { + it("compass.spec.1 should exist", function() { expect(window.CompassError).toBeDefined(); expect(window.CompassError.COMPASS_INTERNAL_ERR).toBe(0); expect(window.CompassError.COMPASS_NOT_SUPPORTED).toBe(20); @@ -52,11 +73,11 @@ describe('Compass (navigator.compass)', function () { }); describe('Compass Heading model (CompassHeading)', function () { - it("should exist", function () { + it("compass.spec.1 should exist", function() { expect(CompassHeading).toBeDefined(); }); - it("should be able to create a new CompassHeading instance with no parameters", function () { + it("compass.spec.8 should be able to create a new CompassHeading instance with no parameters", function() { var h = new CompassHeading(); expect(h.magneticHeading).toBeDefined(); expect(h.trueHeading).toBeDefined(); @@ -64,8 +85,8 @@ describe('Compass (navigator.compass)', function () { expect(typeof h.timestamp == 'number').toBe(true); }); - it("should be able to creat a new CompassHeading instance with parameters", function () { - var h = new CompassHeading(1, 2, 3, 4); + it("compass.spec.9 should be able to create a new CompassHeading instance with parameters", function() { + var h = new CompassHeading(1,2,3,4); expect(h.magneticHeading).toBe(1); expect(h.trueHeading).toBe(2); expect(h.headingAccuracy).toBe(3); http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/contacts.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/contacts.tests.js b/windows8/test/autotest/tests/contacts.tests.js index e4344bd..12520a4 100644 --- a/windows8/test/autotest/tests/contacts.tests.js +++ b/windows8/test/autotest/tests/contacts.tests.js @@ -1,3 +1,24 @@ +/* + * + * 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. + * +*/ + // global to store a contact so it doesn't have to be created or retrieved multiple times // all of the setup/teardown test methods can reference the following variables to make sure to do the right cleanup var gContactObj = null; @@ -13,17 +34,17 @@ var removeContact = function(){ }; describe("Contacts (navigator.contacts)", function () { - it("should exist", function() { + it("contacts.spec.1 should exist", function() { expect(navigator.contacts).toBeDefined(); }); - it("should contain a find function", function() { + it("contacts.spec.2 should contain a find function", function() { expect(navigator.contacts.find).toBeDefined(); expect(typeof navigator.contacts.find).toBe('function'); }); describe("find method", function() { - it("success callback should be called with an array", function() { + it("contacts.spec.3 success callback should be called with an array", function() { var win = jasmine.createSpy().andCallFake(function(result) { expect(result).toBeDefined(); expect(result instanceof Array).toBe(true); @@ -42,9 +63,9 @@ describe("Contacts (navigator.contacts)", function () { runs(function () { expect(fail).not.toHaveBeenCalled(); }); - }); + }); - it("should throw an exception if success callback is empty", function() { + it("contacts.spec.4 should throw an exception if success callback is empty", function() { var fail = function() {}; var obj = new ContactFindOptions(); obj.filter=""; @@ -53,11 +74,11 @@ describe("Contacts (navigator.contacts)", function () { expect(function () { navigator.contacts.find(["displayName", "name", "emails", "phoneNumbers"], null, fail, obj); }).toThrow(); - }); + }); - it("error callback should be called when no fields are specified", function() { + it("contacts.spec.5 error callback should be called when no fields are specified", function() { var win = jasmine.createSpy(), - fail = jasmine.createSpy(function(result) { + fail = jasmine.createSpy(function(result) { expect(result).toBeDefined(); expect(result.code).toBe(ContactError.INVALID_ARGUMENT_ERROR); }), @@ -71,7 +92,7 @@ describe("Contacts (navigator.contacts)", function () { waitsFor(function () { return fail.wasCalled; }, Tests.TEST_TIMEOUT); - runs(function () { + runs(function () { expect(win).not.toHaveBeenCalled(); expect(fail).toHaveBeenCalled(); }); @@ -81,7 +102,7 @@ describe("Contacts (navigator.contacts)", function () { afterEach(removeContact); - it("should be able to find a contact by name", function() { + it("contacts.spec.6 should be able to find a contact by name", function() { var foundName = jasmine.createSpy().andCallFake(function(result) { var bFound = false; try { @@ -93,7 +114,7 @@ describe("Contacts (navigator.contacts)", function () { } } catch(e) { return false; - } + } return bFound; }), fail = jasmine.createSpy(), @@ -142,14 +163,14 @@ describe("Contacts (navigator.contacts)", function () { describe('create method', function() { - it("should exist", function() { + it("contacts.spec.1 should exist", function() { expect(navigator.contacts.create).toBeDefined(); expect(typeof navigator.contacts.create).toBe('function'); }); - it("should return a Contact object", function() { + it("contacts.spec.8 should return a Contact object", function() { var bDay = new Date(1976, 7,4); - var obj = navigator.contacts.create({"displayName": "test name", "gender": "male", "note": "my note", "name": {"formatted": "Mr. Test Name"}, "emails": [{"value": "[email protected]"}, {"value": "[email protected]"}], "birthday": bDay}); + var obj = navigator.contacts.create({"displayName": "test name", "gender": "male", "note": "my note", "name": {"formatted": "Mr. Test Name"}, "emails": [{"value": "[email protected]"}, {"value": "[email protected]"}], "birthday": bDay}); expect(obj).toBeDefined(); expect(obj.displayName).toBe('test name'); @@ -164,8 +185,8 @@ describe("Contacts (navigator.contacts)", function () { }); describe("Contact object", function () { - it("should be able to create instance", function() { - var contact = new Contact("a", "b", new ContactName("a", "b", "c", "d", "e", "f"), "c", [], [], [], [], [], "f", "i", + it("contacts.spec.9 should be able to create instance", function() { + var contact = new Contact("a", "b", new ContactName("a", "b", "c", "d", "e", "f"), "c", [], [], [], [], [], "f", "i", [], [], []); expect(contact).toBeDefined(); expect(contact.id).toBe("a"); @@ -182,9 +203,9 @@ describe("Contacts (navigator.contacts)", function () { expect(contact.photos).toBeDefined(); expect(contact.categories).toBeDefined(); expect(contact.urls).toBeDefined(); - }); + }); - it("should be able to define a ContactName object", function() { + it("contacts.spec.10 should be able to define a ContactName object", function() { var contactName = new ContactName("Dr. First Last Jr.", "Last", "First", "Middle", "Dr.", "Jr."); expect(contactName).toBeDefined(); expect(contactName.formatted).toBe("Dr. First Last Jr."); @@ -193,23 +214,23 @@ describe("Contacts (navigator.contacts)", function () { expect(contactName.middleName).toBe("Middle"); expect(contactName.honorificPrefix).toBe("Dr."); expect(contactName.honorificSuffix).toBe("Jr."); - }); + }); - it("should be able to define a ContactField object", function() { + it("contacts.spec.11 should be able to define a ContactField object", function() { var contactField = new ContactField("home", "8005551212", true); expect(contactField).toBeDefined(); expect(contactField.type).toBe("home"); expect(contactField.value).toBe("8005551212"); expect(contactField.pref).toBe(true); - }); + }); - it("ContactField object should coerce type and value properties to strings", function() { + it("contacts.spec.12 ContactField object should coerce type and value properties to strings", function() { var contactField = new ContactField(12345678, 12345678, true); expect(contactField.type).toBe("12345678"); expect(contactField.value).toBe("12345678"); - }); + }); - it("should be able to define a ContactAddress object", function() { + it("contacts.spec.13 should be able to define a ContactAddress object", function() { var contactAddress = new ContactAddress(true, "home", "a","b","c","d","e","f"); expect(contactAddress).toBeDefined(); expect(contactAddress.pref).toBe(true); @@ -220,9 +241,9 @@ describe("Contacts (navigator.contacts)", function () { expect(contactAddress.region).toBe("d"); expect(contactAddress.postalCode).toBe("e"); expect(contactAddress.country).toBe("f"); - }); + }); - it("should be able to define a ContactOrganization object", function() { + it("contacts.spec.14 should be able to define a ContactOrganization object", function() { var contactOrg = new ContactOrganization(true, "home", "a","b","c","d","e","f","g"); expect(contactOrg).toBeDefined(); expect(contactOrg.pref).toBe(true); @@ -230,22 +251,22 @@ describe("Contacts (navigator.contacts)", function () { expect(contactOrg.name).toBe("a"); expect(contactOrg.department).toBe("b"); expect(contactOrg.title).toBe("c"); - }); + }); - it("should be able to define a ContactFindOptions object", function() { + it("contacts.spec.15 should be able to define a ContactFindOptions object", function() { var contactFindOptions = new ContactFindOptions("a", true, "b"); expect(contactFindOptions).toBeDefined(); expect(contactFindOptions.filter).toBe("a"); expect(contactFindOptions.multiple).toBe(true); - }); + }); - it("should contain a clone function", function() { + it("contacts.spec.16 should contain a clone function", function() { var contact = new Contact(); expect(contact.clone).toBeDefined(); expect(typeof contact.clone).toBe('function'); }); - it("clone function should make deep copy of Contact Object", function() { + it("contacts.spec.17 clone function should make deep copy of Contact Object", function() { var contact = new Contact(); contact.id=1; contact.displayName="Test Name"; @@ -253,9 +274,9 @@ describe("Contacts (navigator.contacts)", function () { contact.gender="male"; contact.note="note to be cloned"; contact.name = new ContactName("Mr. Test Name"); - + var clonedContact = contact.clone(); - + expect(contact.id).toBe(1); expect(clonedContact.id).toBe(null); expect(clonedContact.displayName).toBe(contact.displayName); @@ -265,14 +286,14 @@ describe("Contacts (navigator.contacts)", function () { expect(clonedContact.name.formatted).toBe(contact.name.formatted); expect(clonedContact.connected).toBe(contact.connected); }); - - it("should contain a save function", function() { + + it("contacts.spec.18 should contain a save function", function() { var contact = new Contact(); expect(contact.save).toBeDefined(); expect(typeof contact.save).toBe('function'); }); - it("should contain a remove function", function() { + it("contacts.spec.19 should contain a remove function", function() { var contact = new Contact(); expect(contact.remove).toBeDefined(); expect(typeof contact.remove).toBe('function'); @@ -280,9 +301,9 @@ describe("Contacts (navigator.contacts)", function () { }); describe('save method', function () { - it("should be able to save a contact", function() { + it("contacts.spec.20 should be able to save a contact", function() { var bDay = new Date(1976, 6,4); - gContactObj = navigator.contacts.create({"gender": "male", "note": "my note", "name": {"familyName": "Delete", "givenName": "Test"}, "emails": [{"value": "[email protected]"}, {"value": "[email protected]"}], "birthday": bDay}); + gContactObj = navigator.contacts.create({"gender": "male", "note": "my note", "name": {"familyName": "Delete", "givenName": "Test"}, "emails": [{"value": "[email protected]"}, {"value": "[email protected]"}], "birthday": bDay}); var saveSuccess = jasmine.createSpy().andCallFake(function(obj) { expect(obj).toBeDefined(); @@ -310,21 +331,21 @@ describe("Contacts (navigator.contacts)", function () { }); }); // HACK: there is a reliance between the previous and next test. This is bad form. - it("update a contact", function() { + it("contacts.spec.21 update a contact", function() { expect(gContactObj).toBeDefined(); var bDay = new Date(1975, 5,4); var noteText = "an UPDATED note"; - var win = function(obj) { + var win = jasmine.createSpy().andCallFake(function(obj) { expect(obj).toBeDefined(); expect(obj.id).toBe(gContactObj.id); expect(obj.note).toBe(noteText); expect(obj.birthday.toDateString()).toBe(bDay.toDateString()); expect(obj.emails.length).toBe(1); expect(obj.emails[0].value).toBe('[email protected]'); - removeContact(); // Clean up contact object - }, fail = jasmine.createSpy().andCallFake(removeContact); + removeContact(); // Clean up contact object + }), fail = jasmine.createSpy().andCallFake(removeContact); runs(function () { // remove an email @@ -347,7 +368,7 @@ describe("Contacts (navigator.contacts)", function () { describe('Contact.remove method', function () { afterEach(removeContact); - it("calling remove on a contact has an id of null should return ContactError.UNKNOWN_ERROR", function() { + it("contacts.spec.22 calling remove on a contact has an id of null should return ContactError.UNKNOWN_ERROR", function() { var win = jasmine.createSpy(); var fail = jasmine.createSpy().andCallFake(function(result) { expect(result.code).toBe(ContactError.UNKNOWN_ERROR); @@ -365,7 +386,7 @@ describe("Contacts (navigator.contacts)", function () { }); }); - it("calling remove on a contact that does not exist should return ContactError.UNKNOWN_ERROR", function() { + it("contacts.spec.23 calling remove on a contact that does not exist should return ContactError.UNKNOWN_ERROR", function() { var win = jasmine.createSpy(); var fail = jasmine.createSpy().andCallFake(function(result) { expect(result.code).toBe(ContactError.UNKNOWN_ERROR); @@ -389,7 +410,7 @@ describe("Contacts (navigator.contacts)", function () { describe("Round trip Contact tests (creating + save + delete + find).", function () { afterEach(removeContact); - it("Creating, saving, finding a contact should work, removing it should work, after which we should not be able to find it, and we should not be able to delete it again.", function() { + it("contacts.spec.24 Creating, saving, finding a contact should work, removing it should work, after which we should not be able to find it, and we should not be able to delete it again.", function() { var done = false; runs(function () { gContactObj = new Contact(); @@ -438,7 +459,7 @@ describe("Contacts (navigator.contacts)", function () { }); describe('ContactError interface', function () { - it("ContactError constants should be defined", function() { + it("contacts.spec.25 ContactError constants should be defined", function() { expect(ContactError.UNKNOWN_ERROR).toBe(0); expect(ContactError.INVALID_ARGUMENT_ERROR).toBe(1); expect(ContactError.TIMEOUT_ERROR).toBe(2); http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/datauri.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/datauri.tests.js b/windows8/test/autotest/tests/datauri.tests.js new file mode 100644 index 0000000..c691aab --- /dev/null +++ b/windows8/test/autotest/tests/datauri.tests.js @@ -0,0 +1,36 @@ +describe('data uris', function () { + it("datauri.spec.1 should work with iframes", function() { + var gotFoo = false, + frame = document.createElement('iframe'); + function onMessage(msg) { + gotFoo = gotFoo || msg.data == 'foo'; + }; + + this.after(function() { + document.body.removeChild(frame); + window.removeEventListener('message', onMessage, false); + }); + + window.addEventListener('message', onMessage, false); + frame.src = 'data:text/html;charset=utf-8,%3Chtml%3E%3Cscript%3Eparent.postMessage%28%27foo%27%2C%27%2A%27%29%3C%2Fscript%3E%3C%2Fhtml%3E' + document.body.appendChild(frame); + waitsFor(function() { + return gotFoo; + }, 'iframe did not load.', 1000); + runs(function() { + expect(gotFoo).toBe(true); + }); + }); + it("datauri.spec.2 should work with images", function() { + var img = new Image(); + img.onload = jasmine.createSpy('onLoad'); + img.onerror = jasmine.createSpy('onError'); + img.src = 'data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7' + waitsFor(function() { + return img.onload.wasCalled || img.onerror.wasCalled; + }, 'image did not load or error', 1000); + runs(function() { + expect(img.onload).toHaveBeenCalled(); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/199321c2/windows8/test/autotest/tests/device.tests.js ---------------------------------------------------------------------- diff --git a/windows8/test/autotest/tests/device.tests.js b/windows8/test/autotest/tests/device.tests.js index cc322d6..4750cc0 100644 --- a/windows8/test/autotest/tests/device.tests.js +++ b/windows8/test/autotest/tests/device.tests.js @@ -1,3 +1,24 @@ +/* + * + * 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('Device Information (window.device)', function () { it("should exist", function() { expect(window.device).toBeDefined();
