Skip to content

Commit 9b0d4da

Browse files
committed
2 parents f357d81 + 94029fb commit 9b0d4da

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tests/tests.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
*
33
* Licensed to the Apache Software Foundation (ASF) under one
44
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +18,8 @@
1818
*
1919
*/
2020
exports.defineAutoTests = function () {
21+
var isWindows = (cordova.platformId == "windows") || (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1);
22+
2123
describe('File API', function () {
2224
// Adding a Jasmine helper matcher, to report errors when comparing to FileError better.
2325
var fileErrorMap = {
@@ -2692,7 +2694,7 @@ exports.defineAutoTests = function () {
26922694
}, function (fileEntry) {
26932695
expect(fileEntry).toBeDefined();
26942696
expect(fileEntry.name).toBe(fileName);
2695-
expect(fileEntry.fullPath).toCanonicallyMatch('/' + fileName);
2697+
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath +'/' + fileName);
26962698
// cleanup
26972699
deleteEntry(fileName);
26982700
done();
@@ -2740,14 +2742,19 @@ exports.defineAutoTests = function () {
27402742
var pathExpect = cordova.platformId === 'windowsphone' ? "//nativ" : "file://";
27412743
it("file.spec.114 fileEntry should have a toNativeURL method", function (done) {
27422744
var fileName = "native.file.uri";
2745+
if (isWindows) {
2746+
var rootPath = root.fullPath;
2747+
pathExpect = rootPath.substr(0, rootPath.indexOf(":"));
2748+
}
27432749
// create a new file entry
27442750
createFile(fileName, function (entry) {
27452751
expect(entry.toNativeURL).toBeDefined();
27462752
expect(entry.name).toCanonicallyMatch(fileName);
27472753
expect(typeof entry.toNativeURL).toBe('function');
27482754
var nativeURL = entry.toNativeURL();
2755+
var indexOfRoot = isWindows ? rootPath.indexOf(":") : 7;
27492756
expect(typeof nativeURL).toBe("string");
2750-
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
2757+
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
27512758
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
27522759
// cleanup
27532760
deleteEntry(fileName);
@@ -2764,8 +2771,9 @@ exports.defineAutoTests = function () {
27642771
expect(entries[0].toNativeURL).toBeDefined();
27652772
expect(typeof entries[0].toNativeURL).toBe('function');
27662773
var nativeURL = entries[0].toNativeURL();
2774+
var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7;
27672775
expect(typeof nativeURL).toBe("string");
2768-
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
2776+
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
27692777
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
27702778
// cleanup
27712779
directory.removeRecursively(null, null);
@@ -2792,8 +2800,9 @@ exports.defineAutoTests = function () {
27922800
expect(entry.name).toCanonicallyMatch(fileName);
27932801
expect(typeof entry.toNativeURL).toBe('function');
27942802
var nativeURL = entry.toNativeURL();
2803+
var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7;
27952804
expect(typeof nativeURL).toBe("string");
2796-
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
2805+
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
27972806
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
27982807
// cleanup
27992808
deleteEntry(fileName);
@@ -2839,7 +2848,7 @@ exports.defineAutoTests = function () {
28392848
// create a new file entry
28402849
createFile(fileName, function (entry) {
28412850
resolveLocalFileSystemURL(entry.toNativeURL(), function (fileEntry) {
2842-
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
2851+
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
28432852
// cleanup
28442853
deleteEntry(fileName);
28452854
done();
@@ -2853,7 +2862,7 @@ exports.defineAutoTests = function () {
28532862
var url = entry.toNativeURL();
28542863
url = url.replace("///", "//localhost/");
28552864
resolveLocalFileSystemURL(url, function (fileEntry) {
2856-
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
2865+
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
28572866
// cleanup
28582867
deleteEntry(fileName);
28592868
done();
@@ -2867,7 +2876,7 @@ exports.defineAutoTests = function () {
28672876
var url = entry.toNativeURL();
28682877
url = url + "?test/test";
28692878
resolveLocalFileSystemURL(url, function (fileEntry) {
2870-
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
2879+
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
28712880
// cleanup
28722881
deleteEntry(fileName);
28732882
done();
@@ -2881,7 +2890,7 @@ exports.defineAutoTests = function () {
28812890
var url = entry.toNativeURL();
28822891
url = url.replace("///", "//localhost/") + "?test/test";
28832892
resolveLocalFileSystemURL(url, function (fileEntry) {
2884-
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
2893+
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
28852894
// cleanup
28862895
deleteEntry(fileName);
28872896
done();

0 commit comments

Comments
 (0)