You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by kn...@apache.org on 2019/03/09 10:12:28 UTC

[cordova-plugin-file] branch travis_tests updated: add timer to test create file

This is an automated email from the ASF dual-hosted git repository.

knaito pushed a commit to branch travis_tests
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-file.git


The following commit(s) were added to refs/heads/travis_tests by this push:
     new c9f1b89  add timer to test create file
c9f1b89 is described below

commit c9f1b89597e25d903350ca057cd107210526485c
Author: knaito <kn...@asial.co.jp>
AuthorDate: Sat Mar 9 19:12:08 2019 +0900

    add timer to test create file
---
 src/browser/FileProxy.js | 16 +++++++++++++---
 tests/tests.js           | 10 ++++++----
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/browser/FileProxy.js b/src/browser/FileProxy.js
index c8af393..f260634 100644
--- a/src/browser/FileProxy.js
+++ b/src/browser/FileProxy.js
@@ -103,6 +103,7 @@
 
             window.customLog('log', 'requestFileSystem step 2 ');
             idb_.open(storageName, function () {
+                // window.customLog('log', '***** ' + successCallback.toString());
                 successCallback(fs_);
             }, errorCallback);
         };
@@ -138,11 +139,14 @@
             var path = args[1];
             var options = args[2] || {};
 
+            window.customLog('log', 'getFile is called AA');
+
             // Create an absolute path if we were handed a relative one.
             path = resolveToFullPath_(fullPath, path);
 
             idb_.get(path.storagePath, function (fileEntry) {
                 if (options.create === true && options.exclusive === true && fileEntry) {
+                    window.customLog('log', 'getFile is called 1');
                     // If create and exclusive are both true, and the path already exists,
                     // getFile must fail.
 
@@ -150,6 +154,7 @@
                         errorCallback(FileError.PATH_EXISTS_ERR);
                     }
                 } else if (options.create === true && !fileEntry) {
+                    window.customLog('log', 'getFile is called 2');
                     // If create is true, the path doesn't exist, and no other error occurs,
                     // getFile must create it as a zero-length file and return a corresponding
                     // FileEntry.
@@ -164,6 +169,7 @@
 
                     idb_.put(newFileEntry, path.storagePath, successCallback, errorCallback);
                 } else if (options.create === true && fileEntry) {
+                    window.customLog('log', 'getFile is called 3');
                     if (fileEntry.isFile) {
                         // Overwrite file, delete then create new.
                         idb_['delete'](path.storagePath, function () {
@@ -184,18 +190,21 @@
                         }
                     }
                 } else if ((!options.create || options.create === false) && !fileEntry) {
+                    window.customLog('log', 'getFile is called 4');
                     // If create is not true and the path doesn't exist, getFile must fail.
                     if (errorCallback) {
                         errorCallback(FileError.NOT_FOUND_ERR);
                     }
                 } else if ((!options.create || options.create === false) && fileEntry &&
-                    fileEntry.isDirectory) {
+                fileEntry.isDirectory) {
+                    window.customLog('log', 'getFile is called 5');
                     // If create is not true and the path exists, but is a directory, getFile
                     // must fail.
                     if (errorCallback) {
                         errorCallback(FileError.TYPE_MISMATCH_ERR);
                     }
                 } else {
+                    window.customLog('log', 'getFile is called 6');
                     // Otherwise, if no other error occurs, getFile must return a FileEntry
                     // corresponding to path.
 
@@ -581,7 +590,7 @@
             }
 
             if (path.indexOf(pathsPrefix.dataDirectory) === 0) {
-                window.customLog('log', 'resolveLocalFileSystemURI is called step 4');
+                window.customLog('log', 'resolveLocalFileSystemURI is called step 4A');
                 path = path.substring(pathsPrefix.dataDirectory.length - 1);
                 path = handlePathSlashes(path);
 
@@ -599,7 +608,7 @@
                     errorCallback(err);
                 }, [LocalFileSystem.PERSISTENT]);
             } else if (path.indexOf(pathsPrefix.cacheDirectory) === 0) {
-                window.customLog('log', 'resolveLocalFileSystemURI is called step 5');
+                window.customLog('log', 'resolveLocalFileSystemURI is called step 4B');
                 path = path.substring(pathsPrefix.cacheDirectory.length - 1);
                 path = handlePathSlashes(path);
 
@@ -610,6 +619,7 @@
                     }, [pathsPrefix.cacheDirectory, path, {create: false}]);
                 }, errorCallback, [LocalFileSystem.TEMPORARY]);
             } else if (path.indexOf(pathsPrefix.applicationDirectory) === 0) {
+                window.customLog('log', 'resolveLocalFileSystemURI is called step 4C');
                 path = path.substring(pathsPrefix.applicationDirectory.length);
                 // TODO: need to cut out redundant slashes?
 
diff --git a/tests/tests.js b/tests/tests.js
index 5a78798..d227e8d 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -327,10 +327,12 @@ exports.defineAutoTests = function () {
                     createFile(fileName, function (entry) {
                         window.customLog('log', '----- entry.toURL() ----');
                         window.customLog('log', entry.toURL());
-                        window.resolveLocalFileSystemURL(entry.toURL(), win, function (err) {
-                            window.customLog('log', '********* called *******');
-                            (failed.bind(null, done, 'window.resolveLocalFileSystemURL - Error resolving file URL: ' + entry.toURL()))(err);
-                        });
+                        setTimeout(function () {
+                            window.resolveLocalFileSystemURL(entry.toURL(), win, function (err) {
+                                window.customLog('log', '********* called *******');
+                                (failed.bind(null, done, 'window.resolveLocalFileSystemURL - Error resolving file URL: ' + entry.toURL()))(err);
+                            });
+                        }, 1000);
                     }, failed.bind(null, done, 'createFile - Error creating file: ' + fileName), failed.bind(null, done, 'createFile - Error creating file: ' + fileName));
                 });
                 it('file.spec.9.1 should resolve a file even with a terminating slash', function (done) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org