Skip to content

Commit 52d3548

Browse files
committed
fix merge conflict
2 parents 5ed06ef + 85b5370 commit 52d3548

File tree

2 files changed

+101
-7
lines changed

2 files changed

+101
-7
lines changed

tests/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
xmlns:android="http://schemas.android.com/apk/res/android"
2424
id="org.apache.cordova.file.tests"
2525
version="1.2.1-dev">
26+
2627
<name>Cordova File Plugin Tests</name>
2728
<license>Apache 2.0</license>
2829

tests/tests.js

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ exports.defineAutoTests = function () {
998998
// create a new directory entry
999999
createDirectory(dirName, function (entry) {
10001000
entry.getParent(function (parent) {
1001-
//alert("parent: "+JSON.stringify(parent));
10021001
expect(parent).toBeDefined();
10031002
expect(parent.fullPath).toCanonicallyMatch(rootPath);
10041003
// cleanup
@@ -3049,11 +3048,105 @@ exports.defineAutoTests = function () {
30493048
//File API describe
30503049

30513050
};
3052-
/*
3051+
//******************************************************************************************
3052+
//***************************************Manual Tests***************************************
3053+
//******************************************************************************************
3054+
30533055
exports.defineManualTests = function (contentEl, createActionButton) {
3054-
createActionButton('Dump device', function () {
3055-
console.log(JSON.stringify(window.device, null, '\t'));
3056-
});
3056+
3057+
function resolveFs(fsname) {
3058+
var fsURL = "cdvfile://localhost/" + fsname + "/";
3059+
logMessage("Resolving URL: " + fsURL);
3060+
resolveLocalFileSystemURL(fsURL, function (entry) {
3061+
logMessage("Success", 'green');
3062+
logMessage(entry.toURL(), 'blue');
3063+
logMessage(entry.toInternalURL(), 'blue');
3064+
logMessage("Resolving URL: " + entry.toURL());
3065+
resolveLocalFileSystemURL(entry.toURL(), function (entry2) {
3066+
logMessage("Success", 'green');
3067+
logMessage(entry2.toURL(), 'blue');
3068+
logMessage(entry2.toInternalURL(), 'blue');
3069+
}, logError("resolveLocalFileSystemURL"));
3070+
}, logError("resolveLocalFileSystemURL"));
3071+
}
3072+
3073+
function testPrivateURL() {
3074+
requestFileSystem(TEMPORARY, 0, function (fileSystem) {
3075+
logMessage("Temporary root is at " + fileSystem.root.toNativeURL());
3076+
fileSystem.root.getFile("testfile", {
3077+
create : true
3078+
}, function (entry) {
3079+
logMessage("Temporary file is at " + entry.toNativeURL());
3080+
if (entry.toNativeURL().substring(0, 12) == "file:///var/") {
3081+
logMessage("File starts with /var/, trying /private/var");
3082+
var newURL = "file://localhost/private/var/" + entry.toNativeURL().substring(12) + "?and=another_thing";
3083+
//var newURL = entry.toNativeURL();
3084+
logMessage(newURL, 'blue');
3085+
resolveLocalFileSystemURL(newURL, function (newEntry) {
3086+
logMessage("Successfully resolved.", 'green');
3087+
logMessage(newEntry.toURL(), 'blue');
3088+
logMessage(newEntry.toNativeURL(), 'blue');
3089+
}, logError("resolveLocalFileSystemURL"));
3090+
}
3091+
}, logError("getFile"));
3092+
}, logError("requestFileSystem"));
3093+
}
3094+
3095+
function clearLog() {
3096+
var log = document.getElementById("info");
3097+
log.innerHTML = "";
3098+
}
3099+
3100+
function logMessage(message, color) {
3101+
var log = document.getElementById("info");
3102+
var logLine = document.createElement('div');
3103+
if (color) {
3104+
logLine.style.color = color;
3105+
}
3106+
logLine.innerHTML = message;
3107+
log.appendChild(logLine);
3108+
}
3109+
3110+
function logError(serviceName) {
3111+
return function (err) {
3112+
logMessage("ERROR: " + serviceName + " " + JSON.stringify(err), "red");
3113+
};
3114+
}
3115+
3116+
var fsRoots = {
3117+
"ios" : "library,library-nosync,documents,documents-nosync,cache,bundle,root,private",
3118+
"android" : "files,files-external,documents,sdcard,cache,cache-external,root"
3119+
};
3120+
3121+
//Add title and align to content
3122+
var div = document.createElement('h2');
3123+
div.appendChild(document.createTextNode('File Systems'));
3124+
div.setAttribute("align", "center");
3125+
contentEl.appendChild(div);
3126+
3127+
div = document.createElement('div');
3128+
div.setAttribute("id", "button");
3129+
div.setAttribute("align", "center");
3130+
contentEl.appendChild(div);
3131+
if (fsRoots.hasOwnProperty(cordova.platformId)) {
3132+
(fsRoots[cordova.platformId].split(',')).forEach(function (fs) {
3133+
if (cordova.platformId === 'ios' && fs === 'private') {
3134+
createActionButton("Test private URL (iOS)", function () {
3135+
clearLog();
3136+
testPrivateURL();
3137+
}, 'button');
3138+
} else {
3139+
createActionButton(fs, function () {
3140+
clearLog();
3141+
resolveFs(fs);
3142+
}, 'button');
3143+
}
3144+
});
3145+
}
3146+
3147+
3148+
div = document.createElement('div');
3149+
div.setAttribute("id", "info");
3150+
div.setAttribute("align", "center");
3151+
contentEl.appendChild(div);
30573152
};
3058-
});
3059-
*/

0 commit comments

Comments
 (0)