[CB-1517] [CB-1518] Add spec test for gzip-encoded resources
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/da89eaac Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/da89eaac Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/da89eaac Branch: refs/heads/2.6.x Commit: da89eaacfdc9625b94a96a3b22a5a50ed309b87e Parents: 46e478f Author: Ian Clelland <[email protected]> Authored: Wed Mar 20 11:03:28 2013 -0400 Committer: Andrew Grieve <[email protected]> Committed: Wed Mar 27 16:40:28 2013 -0400 ---------------------------------------------------------------------- autotest/tests/filetransfer.tests.js | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/da89eaac/autotest/tests/filetransfer.tests.js ---------------------------------------------------------------------- diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js index a766879..df1aebd 100644 --- a/autotest/tests/filetransfer.tests.js +++ b/autotest/tests/filetransfer.tests.js @@ -391,6 +391,30 @@ describe('FileTransfer', function() { waitsForAny(downloadWin, downloadFail); }); + it("progress should work with gzip encoding", function() { + var downloadFail = createDoNotCallSpy('downloadFail'); + var remoteFile = "http://www.apache.org/"; + var localFileName = "index.html"; + var lastProgressEvent = null; + + var downloadWin = jasmine.createSpy().andCallFake(function(entry) { + expect(entry.name).toBe(localFileName); + expect(lastProgressEvent.loaded).toBeGreaterThan(1, 'loaded'); + expect(lastProgressEvent.lengthComputable).toBe(true, 'lengthComputable'); + }); + + this.after(function() { + deleteFile(localFileName); + }); + runs(function() { + var ft = new FileTransfer(); + ft.onprogress = function(e) { + lastProgressEvent = e; + }; + ft.download(remoteFile, root.fullPath + "/" + localFileName, downloadWin, downloadFail); + }); + waitsForAny(downloadWin, downloadFail); + }); }); describe('upload method', function() { it("should be able to upload a file", function() {
