You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/02/12 16:57:36 UTC
spec commit: [CB-2095] Add test for incomplete file when
FileTransfer.download is aborted.
Updated Branches:
refs/heads/master 94d1c00e1 -> 3e3d0752a
[CB-2095] Add test for incomplete file when FileTransfer.download is aborted.
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/3e3d0752
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/3e3d0752
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/3e3d0752
Branch: refs/heads/master
Commit: 3e3d0752a7b4aefdc503c4c0a3a60ee034f941ec
Parents: 94d1c00
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Feb 12 10:56:54 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Feb 12 10:56:54 2013 -0500
----------------------------------------------------------------------
autotest/tests/filetransfer.tests.js | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/3e3d0752/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js
index eaef54f..d6b4356 100644
--- a/autotest/tests/filetransfer.tests.js
+++ b/autotest/tests/filetransfer.tests.js
@@ -186,6 +186,32 @@ describe('FileTransfer', function() {
waitsForAny(fileWin, downloadFail, fileFail);
});
+ it("should not leave partial file due to abort", function() {
+ var downloadWin = createDoNotCallSpy('downloadWin');
+ var remoteFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3';
+ var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
+ var startTime = +new Date();
+
+ var downloadFail = jasmine.createSpy().andCallFake(function(e) {
+ expect(e.code).toBe(FileTransferError.ABORT_ERR);
+ var didNotExistSpy = jasmine.createSpy();
+ var existedSpy = createDoNotCallSpy('file existed after abort');
+ root.getFile(localFileName, null, existedSpy, didNotExistSpy);
+ waitsForAny(didNotExistSpy, existedSpy);
+ });
+
+ runs(function() {
+ var ft = new FileTransfer();
+ ft.onprogress = function(e) {
+ if (e.loaded > 0) {
+ ft.abort();
+ }
+ };
+ ft.download(remoteFile, root.fullPath + "/" + localFileName, downloadWin, downloadFail);
+ });
+
+ waitsForAny(downloadWin, downloadFail);
+ });
it("should be stopped by abort() right away", function() {
var downloadWin = createDoNotCallSpy('downloadWin');
var remoteFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3';