From 94029fb7a2409d28d399c65ad50afe0c97aba30a Mon Sep 17 00:00:00 2001 From: "maria.bukharina" Date: Fri, 31 Oct 2014 15:54:56 +0300 Subject: [PATCH] CB-7917 Made tests file.spec.114 - 116 pass for windows platform --- tests/tests.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/tests.js b/tests/tests.js index 6d625b9d8..99fd46ebb 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -1,4 +1,4 @@ -/* +/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +18,8 @@ * */ exports.defineAutoTests = function () { + var isWindows = (cordova.platformId == "windows") || (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1); + describe('File API', function () { // Adding a Jasmine helper matcher, to report errors when comparing to FileError better. var fileErrorMap = { @@ -2674,7 +2676,7 @@ exports.defineAutoTests = function () { }, function (fileEntry) { expect(fileEntry).toBeDefined(); expect(fileEntry.name).toBe(fileName); - expect(fileEntry.fullPath).toCanonicallyMatch('/' + fileName); + expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath +'/' + fileName); // cleanup deleteEntry(fileName); done(); @@ -2722,14 +2724,19 @@ exports.defineAutoTests = function () { var pathExpect = cordova.platformId === 'windowsphone' ? "//nativ" : "file://"; it("file.spec.114 fileEntry should have a toNativeURL method", function (done) { var fileName = "native.file.uri"; + if (isWindows) { + var rootPath = root.fullPath; + pathExpect = rootPath.substr(0, rootPath.indexOf(":")); + } // create a new file entry createFile(fileName, function (entry) { expect(entry.toNativeURL).toBeDefined(); expect(entry.name).toCanonicallyMatch(fileName); expect(typeof entry.toNativeURL).toBe('function'); var nativeURL = entry.toNativeURL(); + var indexOfRoot = isWindows ? rootPath.indexOf(":") : 7; expect(typeof nativeURL).toBe("string"); - expect(nativeURL.substring(0, 7)).toEqual(pathExpect); + expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect); expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName); // cleanup deleteEntry(fileName); @@ -2746,8 +2753,9 @@ exports.defineAutoTests = function () { expect(entries[0].toNativeURL).toBeDefined(); expect(typeof entries[0].toNativeURL).toBe('function'); var nativeURL = entries[0].toNativeURL(); + var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7; expect(typeof nativeURL).toBe("string"); - expect(nativeURL.substring(0, 7)).toEqual(pathExpect); + expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect); expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName); // cleanup directory.removeRecursively(null, null); @@ -2774,8 +2782,9 @@ exports.defineAutoTests = function () { expect(entry.name).toCanonicallyMatch(fileName); expect(typeof entry.toNativeURL).toBe('function'); var nativeURL = entry.toNativeURL(); + var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7; expect(typeof nativeURL).toBe("string"); - expect(nativeURL.substring(0, 7)).toEqual(pathExpect); + expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect); expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName); // cleanup deleteEntry(fileName); @@ -2821,7 +2830,7 @@ exports.defineAutoTests = function () { // create a new file entry createFile(fileName, function (entry) { resolveLocalFileSystemURL(entry.toNativeURL(), function (fileEntry) { - expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName); + expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName); // cleanup deleteEntry(fileName); done(); @@ -2835,7 +2844,7 @@ exports.defineAutoTests = function () { var url = entry.toNativeURL(); url = url.replace("///", "//localhost/"); resolveLocalFileSystemURL(url, function (fileEntry) { - expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName); + expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName); // cleanup deleteEntry(fileName); done(); @@ -2849,7 +2858,7 @@ exports.defineAutoTests = function () { var url = entry.toNativeURL(); url = url + "?test/test"; resolveLocalFileSystemURL(url, function (fileEntry) { - expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName); + expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName); // cleanup deleteEntry(fileName); done(); @@ -2863,7 +2872,7 @@ exports.defineAutoTests = function () { var url = entry.toNativeURL(); url = url.replace("///", "//localhost/") + "?test/test"; resolveLocalFileSystemURL(url, function (fileEntry) { - expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName); + expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName); // cleanup deleteEntry(fileName); done();