You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/09/30 21:26:38 UTC

[1/3] spec commit: CB4662, CB4879 cleanup errors in file tests

Updated Branches:
  refs/heads/3.1.x d03db7266 -> ace274f6c


CB4662, CB4879 cleanup errors in file tests

(cherry picked from commit dc2f5538bdb9eeaa980273cd483a59343508478a)


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/726758b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/726758b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/726758b6

Branch: refs/heads/3.1.x
Commit: 726758b61e8ab76bd807de07a905f29dc8bdff8a
Parents: d03db72
Author: David Kemp <dr...@chromium.org>
Authored: Fri Sep 20 08:09:19 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Sep 30 15:25:15 2013 -0400

----------------------------------------------------------------------
 autotest/tests/file.tests.js | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/726758b6/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index 023cb2b..b5c2f96 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -1125,7 +1125,6 @@ describe('File API', function() {
                     expect(fileEntry).toBeDefined();
                     expect(typeof fileEntry.createWriter).toBe('function');
                     expect(typeof fileEntry.file).toBe('function');
-                    expect(fileEntry.file instanceof file).toBe(true);
 
                     // cleanup
                     fileEntry.remove(null, fail);
@@ -3066,7 +3065,7 @@ describe('File API', function() {
             });
         }
 
-        function arrayBufferEqualsString(buf, str) {
+        function arrayBufferEqualsString(ab, str) {
             var buf = new Uint8Array(ab);
             var match = buf.length == str.length;
 
@@ -3638,7 +3637,7 @@ describe('File API', function() {
                 verifier = jasmine.createSpy("verifier").andCallFake(function(outputFileWriter) {
                     expect(outputFileWriter.length).toBe(dummyFileText.length);
                     expect(outputFileWriter.position).toBe(dummyFileText.length);
-                    deleteFile(fileName);
+                    deleteFile(outputFileName);
                 }),
                 writeFile = function(fileName, fileData, win) {
                     var theWriter,
@@ -3691,7 +3690,7 @@ describe('File API', function() {
                 verifier = jasmine.createSpy("verifier").andCallFake(function(outputFileWriter) {
                     expect(outputFileWriter.length).toBe(10);
                     expect(outputFileWriter.position).toBe(10);
-                    deleteFile(fileName);
+                    deleteFile(outputFileName);
                 }),
                 writeFile = function(fileName, fileData, win) {
                     var theWriter,
@@ -3755,7 +3754,7 @@ describe('File API', function() {
                     expect(outputFileWriter.position).toBe(length);
 
                     // cleanup
-                    deleteFile(fileName);
+                    deleteFile(outputFileName);
                 }),
                 writeFile = function(fileName, fileData, win) {
                     var theWriter,


[2/3] spec commit: CB 4878 - media tests should wait for file load

Posted by ia...@apache.org.
CB 4878 - media tests should wait for file load

(cherry picked from commit 4cba23f05443607e26cf82e7746f6fe55511e329)


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/00669d34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/00669d34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/00669d34

Branch: refs/heads/3.1.x
Commit: 00669d34d420a5dae3858190d3933ce2df9db340
Parents: 726758b
Author: David Kemp <dr...@chromium.org>
Authored: Fri Sep 20 08:17:31 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Sep 30 15:25:26 2013 -0400

----------------------------------------------------------------------
 autotest/tests/media.tests.js | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/00669d34/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/media.tests.js b/autotest/tests/media.tests.js
index 6b23a47..87d860d 100644
--- a/autotest/tests/media.tests.js
+++ b/autotest/tests/media.tests.js
@@ -144,7 +144,13 @@ describe('Media', function () {
 	});
 
     it("media.spec.12 position should be set properly", function() {
-        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3"),
+        var win = jasmine.createSpy();
+        var fail = jasmine.createSpy();
+        var mediaState=Media.STOPPED;
+        var statuschange= function(statusCode){
+            mediaState=statusCode;
+        };
+        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange),
             test = jasmine.createSpy().andCallFake(function(position) {
                     console.log("position = " + position);
                     expect(position).toBeGreaterThan(0.0);
@@ -154,9 +160,11 @@ describe('Media', function () {
 
         media1.play();
 
-        waits(5000);
+        waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
 
         runs(function () {
+            expect(fail).not.toHaveBeenCalled();
+            expect(win).not.toHaveBeenCalled();
             media1.getCurrentPosition(test, function () {});
         });
 
@@ -164,11 +172,18 @@ describe('Media', function () {
     });
 
     it("media.spec.13 duration should be set properly", function() {
-        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3");
+        var win = jasmine.createSpy();
+        var fail = jasmine.createSpy();
+        var mediaState=Media.STOPPED;
+        var statuschange= function(statusCode){
+            mediaState=statusCode;
+        };
+        var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange);
         media1.play();
-        waits(5000);
+        waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
         runs(function () {
             expect(media1.getDuration()).toBeGreaterThan(0.0);
+            expect(fail).not.toHaveBeenCalled();
         });
     });
 });


[3/3] spec commit: CB-4894 handle correctly when geolocation not available

Posted by ia...@apache.org.
CB-4894 handle correctly when geolocation not available

(cherry picked from commit 32d806a11fbd460aef2dc3b7fabd2adfe4b3e6a7)


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/ace274f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/ace274f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/ace274f6

Branch: refs/heads/3.1.x
Commit: ace274f6c48edd0a8300ae8680734370bcfde0da
Parents: 00669d3
Author: David Kemp <dr...@chromium.org>
Authored: Tue Sep 24 06:56:52 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Sep 30 15:25:32 2013 -0400

----------------------------------------------------------------------
 autotest/tests/geolocation.tests.js | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/ace274f6/autotest/tests/geolocation.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/geolocation.tests.js b/autotest/tests/geolocation.tests.js
index 6837f44..1d2410c 100644
--- a/autotest/tests/geolocation.tests.js
+++ b/autotest/tests/geolocation.tests.js
@@ -63,11 +63,16 @@ describe('Geolocation (navigator.geolocation)', function () {
 
         describe('success callback', function() {
             it("geolocation.spec.6 should be called with a Position object", function() {
+                var providerAvailable=true;
                 var win = jasmine.createSpy().andCallFake(function(p) {
                           expect(p.coords).toBeDefined();
                           expect(p.timestamp).toBeDefined();
                       }),
-                      fail = jasmine.createSpy();
+                      fail = jasmine.createSpy().andCallFake(function(e) {
+                          if(e.code == 2) {
+                              providerAvailable=false;
+                          }
+                      });
 
                 runs(function () {
                     navigator.geolocation.getCurrentPosition(win, fail, {
@@ -75,10 +80,12 @@ describe('Geolocation (navigator.geolocation)', function () {
                     });
                 });
 
-                waitsFor(function () { return win.wasCalled; }, "win never called", 20000);
+                waitsFor(function () { return (win.wasCalled || fail.wasCalled); }, "win/fail never called", 20000);
 
                 runs(function () {
-                    expect(fail).not.toHaveBeenCalled();
+                    if(providerAvailable) {
+                        expect(fail).not.toHaveBeenCalled();
+                    }
                 });
             });
         });
@@ -91,7 +98,7 @@ describe('Geolocation (navigator.geolocation)', function () {
             afterEach(function() {
                 navigator.geolocation.clearWatch(errorWatch);
             });
-            it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function() {
+            it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function() {
                 var win = jasmine.createSpy(),
                     fail = jasmine.createSpy();
 
@@ -112,16 +119,21 @@ describe('Geolocation (navigator.geolocation)', function () {
 
         describe('success callback', function() {
             var successWatch = null;
-
+ 
             afterEach(function() {
                 navigator.geolocation.clearWatch(successWatch);
             });
-            it("geolocation.spec.6 should be called with a Position object", function() {
+            it("geolocation.spec.8 should be called with a Position object", function() {
+                var providerAvailable=true;
                 var win = jasmine.createSpy().andCallFake(function(p) {
                           expect(p.coords).toBeDefined();
                           expect(p.timestamp).toBeDefined();
                       }),
-                      fail = jasmine.createSpy();
+                      fail = jasmine.createSpy().andCallFake(function(e) {
+                          if(e.code ==2) {
+                              providerAvailable=false;
+                          }
+                      });
 
                 runs(function () {
                     successWatch = navigator.geolocation.watchPosition(win, fail, {
@@ -129,10 +141,12 @@ describe('Geolocation (navigator.geolocation)', function () {
                     });
                 });
 
-                waitsFor(function () { return win.wasCalled; }, "win never called", 20000);
+                waitsFor(function () { return (win.wasCalled || fail.wasCalled); }, "win/fail never called", 20000);
 
                 runs(function () {
-                    expect(fail).not.toHaveBeenCalled();
+                    if(providerAvailable) {
+                        expect(fail).not.toHaveBeenCalled();
+                    }
                 });
             });
         });