You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2014/08/15 22:00:41 UTC

[1/3] git commit: CB-6466 created mobile-spec test

Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/master e89989dc3 -> b5d1dffc2


CB-6466 created mobile-spec test

Added a test to check that filetransfer.download() automatically creates
any nonexistent directories.

Also removed some unused code


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/0b257f53
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/0b257f53
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/0b257f53

Branch: refs/heads/master
Commit: 0b257f534c96c6c1584ebc4657ecdd0be9a6ccff
Parents: e89989d
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Tue Aug 12 13:06:36 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Tue Aug 12 13:06:36 2014 -0400

----------------------------------------------------------------------
 tests/tests.js | 60 +++++++++++++++++++++--------------------------------
 1 file changed, 24 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/0b257f53/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 2eedd95..213913c 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -868,36 +868,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         results.innerHTML = '';
     }
 
-    function downloadImgCDV(ev) {
-        ev.preventDefault();
-        ev.stopPropagation();
-        downloadImg(imageURL, function (entry) { return entry.toURL(); }, new Image());
-    }
-
-    function downloadImgNative(ev) {
-        ev.preventDefault();
-        ev.stopPropagation();
-        downloadImg(imageURL, function (entry) { return entry.toNativeURL(); }, new Image);
-    }
-
-    function downloadVideoCDV(ev) {
-        ev.preventDefault();
-        ev.stopPropagation();
-        var videoElement = document.createElement('video');
-        videoElement.controls = "controls";
-        downloadImg(videoURL, function (entry) { return entry.toURL(); }, videoElement);
-    }
-
-    function downloadVideoNative(ev) {
-        ev.preventDefault();
-        ev.stopPropagation();
-        var videoElement = document.createElement('video');
-        videoElement.controls = "controls";
-        downloadImg(videoURL, function (entry) { return entry.toNativeURL(); }, videoElement);
-    }
-
-    function downloadImg(source, urlFn, element) {
+    function downloadImg(source, urlFn, element, directory) {
         var filename = source.substring(source.lastIndexOf("/") + 1);
+        filename = directory + filename || filename;
         function download(fileSystem) {
             var ft = new FileTransfer();
             console.log("Starting download");
@@ -913,14 +886,25 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         clearResults();
         requestFileSystem(TEMPORARY, 0, function (fileSystem) {
             console.log("Checking for existing file");
-            fileSystem.root.getFile(filename, { create: false }, function (entry) {
-                console.log("Removing existing file");
-                entry.remove(function () {
+            if (directory != undefined) {
+                console.log("Checking for existing directory.");
+                fileSystem.root.getDirectory(directory, {}, function (dirEntry) {
+                    dirEntry.removeRecursively(function () {
+                        download(fileSystem);
+                    }, function (e) { console.log("ERROR: dirEntry.removeRecursively") });
+                }, function () {
                     download(fileSystem);
-                }, function (e) { console.log("ERROR: entry.remove"); });
-            }, function () {
-                download(fileSystem);
-            });
+                });
+            } else {
+                fileSystem.root.getFile(filename, { create: false }, function (entry) {
+                    console.log("Removing existing file");
+                    entry.remove(function () {
+                        download(fileSystem);
+                    }, function (e) { console.log("ERROR: entry.remove"); });
+                }, function () {
+                    download(fileSystem);
+                });
+            }
         }, function (e) { console.log("ERROR: requestFileSystem"); });
     }
 
@@ -937,6 +921,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         downloadImg(imageURL, function (entry) { return entry.toNativeURL(); }, new Image);
     }, 'actions');
 
+    createActionButton('Download to a non-existent dir (should work)', function () {
+        downloadImg(imageURL, function (entry) { return entry.toURL(); }, new Image, '/nonExistentDirTest/');
+    }, 'actions');
+
     createActionButton('Download and play video (cdvfile)', function () {
         var videoElement = document.createElement('video');
         videoElement.controls = "controls";


[2/3] git commit: Merge branch 'CB-6466' of https://github.com/stacic/cordova-plugin-file-transfer

Posted by mm...@apache.org.
Merge branch 'CB-6466' of https://github.com/stacic/cordova-plugin-file-transfer


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/974bbaaa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/974bbaaa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/974bbaaa

Branch: refs/heads/master
Commit: 974bbaaa2ee5e5f5f551a7f332f0e5117962e900
Parents: e89989d 0b257f5
Author: Michal Mocny <mm...@gmail.com>
Authored: Fri Aug 15 14:19:59 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Fri Aug 15 14:19:59 2014 -0400

----------------------------------------------------------------------
 tests/tests.js | 60 +++++++++++++++++++++--------------------------------
 1 file changed, 24 insertions(+), 36 deletions(-)
----------------------------------------------------------------------



[3/3] git commit: CB-6466 Fix failing test due to recent url change

Posted by mm...@apache.org.
CB-6466 Fix failing test due to recent url change


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/b5d1dffc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/b5d1dffc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/b5d1dffc

Branch: refs/heads/master
Commit: b5d1dffc2f6b8c37fbca4df966cb0d0f74c86ca2
Parents: 974bbaa
Author: Michal Mocny <mm...@gmail.com>
Authored: Fri Aug 15 14:58:07 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Fri Aug 15 15:00:34 2014 -0400

----------------------------------------------------------------------
 tests/tests.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/b5d1dffc/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 213913c..7a795db 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -240,7 +240,7 @@ exports.defineAutoTests = function () {
             });
             it("filetransfer.spec.7 should be able to download a file using file:// (when hosted from file://)", function (done) {
                 var downloadFail = createFail(done, "Download error callback should not have been called");
-                var remoteFile = window.location.href.replace(/\?.*/, '').replace(/ /g, '%20');
+                var remoteFile = window.location.protocol + '//' + window.location.pathname.replace(/ /g, '%20');
                 localFileName = remoteFile.substring(remoteFile.lastIndexOf('/') + 1);
                 var lastProgressEvent = null;