You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/03/03 22:31:47 UTC

spec commit: CB-6148: Test cross-filesystem copy and move

Repository: cordova-mobile-spec
Updated Branches:
  refs/heads/master f6c9c2cc0 -> 8de4aecea


CB-6148: Test cross-filesystem copy and move


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/8de4aece
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/8de4aece
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/8de4aece

Branch: refs/heads/master
Commit: 8de4aeceaba2aa4cb28e69b0e588a8555b07b7a4
Parents: f6c9c2c
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Mar 3 16:30:18 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon Mar 3 16:30:21 2014 -0500

----------------------------------------------------------------------
 autotest/tests/file.tests.js | 161 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/8de4aece/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index f6d517e..4ca47f0 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -4310,6 +4310,167 @@ describe('File API', function() {
 
             waitsFor(function() { return checkEntry.wasCalled; }, "checkEntry callback never called", Tests.TEST_TIMEOUT);
         });
+    });
+    describe('cross-file-system copy and move', function() {
+        /* These specs verify that Entry.copyTo and Entry.moveTo work correctly
+         * when crossing filesystem boundaries.
+         */
+        it("file.spec.125 copyTo: temporary -> persistent", function() {
+            var file1 = "entry.copy.file1a",
+                file2 = "entry.copy.file2a",
+                sourceEntry,
+                fullPath = joinURL(root.fullPath, file2),
+                fail = createFail('Entry'),
+                validateFile = jasmine.createSpy().andCallFake(function(entry) {
+                    // a bit redundant since copy returned this entry already
+                    expect(entry).toBeDefined();
+                    expect(entry.isFile).toBe(true);
+                    expect(entry.isDirectory).toBe(false);
+                    expect(entry.name).toCanonicallyMatch(file2);
+                    expect(entry.fullPath).toCanonicallyMatch(fullPath);
+                    expect(entry.filesystem).toBeDefined();
+                    expect(entry.filesystem.name).toEqual("persistent");
+
+                    // cleanup
+                    entry.remove();
+                    sourceEntry.remove();
+                }),
+                createSourceAndTransfer = function() {
+                    temp_root.getFile(file1, {create: true}, function(entry) {
+                        expect(entry.filesystem).toBeDefined();
+                        expect(entry.filesystem.name).toEqual("temporary");
+                        sourceEntry = entry; // Save for later cleanup
+                        entry.copyTo(persistent_root, file2, validateFile, fail);
+                    }, fail);
+                };
+            // Delete any existing file to start things off
+            runs(function() {
+                persistent_root.getFile(file2, {}, function(entry) {
+                    entry.remove(createSourceAndTransfer, fail);
+                }, createSourceAndTransfer);
+            });
+
+            waitsFor(function() { return validateFile.wasCalled || fail.wasCalled; }, "entryCallback never called", Tests.TEST_TIMEOUT);
+        });
+        it("file.spec.126 copyTo: persistent -> temporary", function() {
+            var file1 = "entry.copy.file1b",
+                file2 = "entry.copy.file2b",
+                sourceEntry,
+                fullPath = joinURL(root.fullPath, file2),
+                fail = createFail('Entry'),
+                validateFile = jasmine.createSpy().andCallFake(function(entry) {
+                    expect(entry).toBeDefined();
+                    expect(entry.isFile).toBe(true);
+                    expect(entry.isDirectory).toBe(false);
+                    expect(entry.name).toCanonicallyMatch(file2);
+                    expect(entry.fullPath).toCanonicallyMatch(fullPath);
+                    expect(entry.filesystem.name).toEqual("temporary");
+
+                    // cleanup
+                    entry.remove();
+                    sourceEntry.remove();
+                }),
+                createSourceAndTransfer = function() {
+                    persistent_root.getFile(file1, {create: true}, function(entry) {
+                        expect(entry).toBeDefined();
+                        expect(entry.filesystem).toBeDefined();
+                        expect(entry.filesystem.name).toEqual("persistent");
+                        sourceEntry = entry; // Save for later cleanup
+                        entry.copyTo(temp_root, file2, validateFile, fail);
+                    }, fail);
+                };
+            // Delete any existing file to start things off
+            runs(function() {
+                temp_root.getFile(file2, {}, function(entry) {
+                    entry.remove(createSourceAndTransfer, fail);
+                }, createSourceAndTransfer);
+            });
+
+            waitsFor(function() { return validateFile.wasCalled || fail.wasCalled; }, "entryCallback never called", Tests.TEST_TIMEOUT);
+
+            runs(function() {
+                expect(fail).not.toHaveBeenCalled();
+                expect(validateFile).toHaveBeenCalled();
+            });
+        });
+        it("file.spec.127 moveTo: temporary -> persistent", function() {
+            var file1 = "entry.copy.file1a",
+                file2 = "entry.copy.file2a",
+                sourceEntry,
+                fullPath = joinURL(root.fullPath, file2),
+                fail = createFail('Entry'),
+                validateFile = jasmine.createSpy().andCallFake(function(entry) {
+                    // a bit redundant since copy returned this entry already
+                    expect(entry).toBeDefined();
+                    expect(entry.isFile).toBe(true);
+                    expect(entry.isDirectory).toBe(false);
+                    expect(entry.name).toCanonicallyMatch(file2);
+                    expect(entry.fullPath).toCanonicallyMatch(fullPath);
+                    expect(entry.filesystem).toBeDefined();
+                    expect(entry.filesystem.name).toEqual("persistent");
+
+                    // cleanup
+                    entry.remove();
+                    sourceEntry.remove();
+                }),
+                createSourceAndTransfer = function() {
+                    temp_root.getFile(file1, {create: true}, function(entry) {
+                        expect(entry.filesystem).toBeDefined();
+                        expect(entry.filesystem.name).toEqual("temporary");
+                        sourceEntry = entry; // Save for later cleanup
+                        entry.moveTo(persistent_root, file2, validateFile, fail);
+                    }, fail);
+                };
+            // Delete any existing file to start things off
+            runs(function() {
+                persistent_root.getFile(file2, {}, function(entry) {
+                    entry.remove(createSourceAndTransfer, fail);
+                }, createSourceAndTransfer);
+            });
+
+            waitsFor(function() { return validateFile.wasCalled || fail.wasCalled; }, "entryCallback never called", Tests.TEST_TIMEOUT);
+        });
+        it("file.spec.128 moveTo: persistent -> temporary", function() {
+            var file1 = "entry.copy.file1b",
+                file2 = "entry.copy.file2b",
+                sourceEntry,
+                fullPath = joinURL(root.fullPath, file2),
+                fail = createFail('Entry'),
+                validateFile = jasmine.createSpy().andCallFake(function(entry) {
+                    expect(entry).toBeDefined();
+                    expect(entry.isFile).toBe(true);
+                    expect(entry.isDirectory).toBe(false);
+                    expect(entry.name).toCanonicallyMatch(file2);
+                    expect(entry.fullPath).toCanonicallyMatch(fullPath);
+                    expect(entry.filesystem.name).toEqual("temporary");
+
+                    // cleanup
+                    entry.remove();
+                    sourceEntry.remove();
+                }),
+                createSourceAndTransfer = function() {
+                    persistent_root.getFile(file1, {create: true}, function(entry) {
+                        expect(entry).toBeDefined();
+                        expect(entry.filesystem).toBeDefined();
+                        expect(entry.filesystem.name).toEqual("persistent");
+                        sourceEntry = entry; // Save for later cleanup
+                        entry.moveTo(temp_root, file2, validateFile, fail);
+                    }, fail);
+                };
+            // Delete any existing file to start things off
+            runs(function() {
+                temp_root.getFile(file2, {}, function(entry) {
+                    entry.remove(createSourceAndTransfer, fail);
+                }, createSourceAndTransfer);
+            });
+
+            waitsFor(function() { return validateFile.wasCalled || fail.wasCalled; }, "entryCallback never called", Tests.TEST_TIMEOUT);
+
+            runs(function() {
+                expect(fail).not.toHaveBeenCalled();
+                expect(validateFile).toHaveBeenCalled();
+            });
+        });
 
     });
 });