incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject spec commit: Add test for upload progress events to FileTransfer.
Date Mon, 24 Sep 2012 18:03:53 GMT
Updated Branches:
  refs/heads/master e134e02e5 -> 9c0548a9f


Add test for upload progress events to FileTransfer.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/9c0548a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/9c0548a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/9c0548a9

Branch: refs/heads/master
Commit: 9c0548a9fae018ac32d950f406e911af7ff54fff
Parents: e134e02
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Sep 24 11:56:08 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Sep 24 11:56:08 2012 -0400

----------------------------------------------------------------------
 autotest/tests/filetransfer.tests.js |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/9c0548a9/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js
index 2ea20b7..fcafce7 100644
--- a/autotest/tests/filetransfer.tests.js
+++ b/autotest/tests/filetransfer.tests.js
@@ -288,9 +288,11 @@ describe('FileTransfer', function() {
         it("should be able to upload a file", function() {
             var remoteFile = server + "/upload";
             var localFileName = "upload.txt";
+            var fileContents = 'This file should upload';
 
             var fileFail = createDoNotCallSpy('fileFail');
             var uploadFail = createDoNotCallSpy('uploadFail', "Ensure " + remoteFile + "
is in the white list");
+            var lastProgressEvent = null;
 
             var uploadWin = jasmine.createSpy().andCallFake(function(uploadResult) {
                 expect(uploadResult.bytesSent).toBeGreaterThan(0);
@@ -311,6 +313,13 @@ describe('FileTransfer', function() {
                 params.value2 = "param";
                 options.params = params;
 
+                ft.onprogress = function(e) {
+                    expect(e.lengthComputable).toBe(true);
+                    expect(e.total).toBeGreaterThan(0);
+                    expect(e.loaded).toBeGreaterThan(0);
+                    lastProgressEvent = e;
+                };
+
                 // removing options cause Android to timeout
                 ft.upload(fileEntry.fullPath, remoteFile, uploadWin, uploadFail, options);
             };
@@ -319,10 +328,13 @@ describe('FileTransfer', function() {
                 deleteFile(localFileName);
             });
             runs(function() {
-                writeFile(localFileName, "this file should upload", fileWin, fileFail);
+                writeFile(localFileName, fileContents, fileWin, fileFail);
             });
 
             waitsForAny(uploadWin, uploadFail, fileFail);
+            runs(function() {
+                expect(lastProgressEvent).not.toBeNull('expected progress events');
+            });
         });
         it("should be stopped by abort() right away.", function() {
             var remoteFile = server + "/upload";


Mime
View raw message