You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/02/19 23:42:34 UTC
cordova-plugin-file-transfer git commit: CB-8495 Fixed wp8 and wp81
test failures
Repository: cordova-plugin-file-transfer
Updated Branches:
refs/heads/master 49c21f951 -> c772257a8
CB-8495 Fixed wp8 and wp81 test failures
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/c772257a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/c772257a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/c772257a
Branch: refs/heads/master
Commit: c772257a8534e6198c9e808af4a5689bda8b4428
Parents: 49c21f9
Author: alsorokin <al...@akvelon.com>
Authored: Wed Feb 18 17:02:40 2015 +0300
Committer: alsorokin <al...@akvelon.com>
Committed: Wed Feb 18 17:02:40 2015 +0300
----------------------------------------------------------------------
tests/tests.js | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/c772257a/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index ffbed50..682ccc9 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -40,9 +40,8 @@ exports.defineAutoTests = function () {
var SERVER_WITH_CREDENTIALS = "http://cordova_user:cordova_password@cordova-filetransfer.jitsu.com";
// flags
- var isWindows = function() {
- return (cordova.platformId === "windows") || (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1);
- };
+ var isWindows = cordova.platformId === 'windows8' || cordova.platformId === 'windows';
+ var isWP8 = cordova.platformId === 'windowsphone';
var isBrowser = cordova.platformId === 'browser';
var isIE = isBrowser && navigator.userAgent.indexOf('Trident') >= 0;
@@ -162,6 +161,10 @@ exports.defineAutoTests = function () {
);
};
+ // according to documentation, wp8 does not support onProgress:
+ // https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md#supported-platforms
+ var wp8OnProgressHandler = function () {};
+
var defaultOnProgressHandler = function (event) {
if (event.lengthComputable) {
expect(event.loaded).toBeGreaterThan(1);
@@ -285,8 +288,8 @@ exports.defineAutoTests = function () {
transfer = new FileTransfer();
- // assign a default onprogress handler
- transfer.onprogress = defaultOnProgressHandler;
+ // assign onprogress handler
+ transfer.onprogress = isWP8 ? wp8OnProgressHandler : defaultOnProgressHandler;
// spy on the onprogress handler, but still call through to it
spyOn(transfer, 'onprogress').and.callThrough();
@@ -371,7 +374,7 @@ exports.defineAutoTests = function () {
it("filetransfer.spec.7 should download a file using file:// (when hosted from file://)", function (done) {
// for Windows platform it's ms-appdata:/// by default, not file://
- if (isWindows()) {
+ if (isWindows) {
pending();
return;
}
@@ -528,20 +531,33 @@ exports.defineAutoTests = function () {
transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail);
});
- it("filetransfer.spec.15 should handle unknown host", function (done) {
+ describe('unknown host:', function () {
+ var originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
- var fileURL = UNKNOWN_HOST;
+ beforeEach(function() {
+ jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
+ });
- var downloadFail = function (error) {
- expect(error.code).toBe(FileTransferError.CONNECTION_ERR);
- done();
- };
+ afterEach(function() {
+ jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
+ });
- // turn off the onprogress handler
- transfer.onprogress = function () {};
+ it("filetransfer.spec.15 should handle unknown host", function (done) {
- transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail);
+ var fileURL = UNKNOWN_HOST;
+
+ var downloadFail = function (error) {
+ expect(error.code).toBe(FileTransferError.CONNECTION_ERR);
+ done();
+ };
+
+ // turn off the onprogress handler
+ transfer.onprogress = function () {};
+
+ transfer.download(fileURL, localFilePath, unexpectedCallbacks.httpWin, downloadFail);
+ });
});
+
it("filetransfer.spec.16 should handle bad file path", function (done) {
var fileURL = SERVER;
@@ -585,8 +601,10 @@ exports.defineAutoTests = function () {
expect(nativeURL).toBeTruthy();
expect(nativeURL).toEqual(jasmine.any(String));
- if (isWindows()) {
+ if (isWindows) {
expect(nativeURL.substring(0, 14)).toBe('ms-appdata:///');
+ } else if (isWP8) {
+ expect(nativeURL.substring(0, 1)).toBe('/');
} else {
expect(nativeURL.substring(0, 7)).toBe('file://');
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org