Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master f357d81d2 -> 82f803ea0


CB-7917 Made tests file.spec.114 - 116 pass for windows platform


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

Branch: refs/heads/master
Commit: 94029fb7a2409d28d399c65ad50afe0c97aba30a
Parents: 8ef744d
Author: maria.bukharina <[email protected]>
Authored: Fri Oct 31 15:54:56 2014 +0300
Committer: maria.bukharina <[email protected]>
Committed: Fri Oct 31 15:54:56 2014 +0300

----------------------------------------------------------------------
 tests/tests.js | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/94029fb7/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 6d625b9..99fd46e 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();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to