You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2013/07/16 18:48:41 UTC

spec commit: [CB-4264] Fixed a DirectoryReader test.

Updated Branches:
  refs/heads/master aba5de441 -> 3296c314f


[CB-4264] Fixed a DirectoryReader test.

The test now creates a file before testing the correctness of readEntries (and removes it afterwards).


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/3296c314
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/3296c314
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/3296c314

Branch: refs/heads/master
Commit: 3296c314f4366247d8ec3a65cf3eb94db1ba79db
Parents: aba5de4
Author: Max Woghiren <ma...@gmail.com>
Authored: Tue Jul 16 12:47:28 2013 -0400
Committer: Max Woghiren <ma...@gmail.com>
Committed: Tue Jul 16 12:47:44 2013 -0400

----------------------------------------------------------------------
 autotest/tests/file.tests.js | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/3296c314/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index d742e13..023cb2b 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -1015,33 +1015,38 @@ describe('File API', function() {
             });
             it("file.spec.109 should return an empty entry list on the second call", function() {
                 var reader,
-                    initialWin = jasmine.createSpy().andCallFake(function(entries) {
+                    firstWin = jasmine.createSpy().andCallFake(function(entries) {
                         expect(entries).toBeDefined();
                         expect(entries instanceof Array).toBe(true);
                         expect(entries.length).not.toBe(0);
-                        // Run it again!
-                        reader.readEntries(finalWin, fail);
+                        reader.readEntries(secondWin, fail);
                     }),
-                    finalWin = jasmine.createSpy().andCallFake(function(entries) {
+                    secondWin = jasmine.createSpy().andCallFake(function(entries) {
                         expect(entries).toBeDefined();
                         expect(entries instanceof Array).toBe(true);
                         expect(entries.length).toBe(0);
                     }),
                     fail = createFail('DirectoryReader');
 
-                // create reader for root directory
-                reader = root.createReader();
-                // read entries
                 runs(function() {
-                    reader.readEntries(initialWin, fail);
+                    // Add a file to ensure the root directory is non-empty and then read the contents of the directory.
+                    root.getFile('test109.txt', { create: true }, function() {
+                        reader = root.createReader();
+                        reader.readEntries(firstWin, fail);
+                    }, fail);
                 });
 
-                waitsFor(function() { return finalWin.wasCalled; }, "finalWin never called", Tests.TEST_TIMEOUT);
+                waitsFor(function() { return secondWin.wasCalled; }, "secondWin never called", Tests.TEST_TIMEOUT);
 
                 runs(function() {
-                    expect(initialWin).toHaveBeenCalled();
-                    expect(finalWin).toHaveBeenCalled();
+                    expect(firstWin).toHaveBeenCalled();
+                    expect(secondWin).toHaveBeenCalled();
                     expect(fail).not.toHaveBeenCalled();
+
+                    // Remove the test file.
+                    root.getFile('test109.txt', { create: false }, function(fileEntry) {
+                        fileEntry.remove();
+                    }, fail);
                 });
             });
             it("file.spec.38 should read contents of directory that has been removed", function() {