Updated Branches:
  refs/heads/3.0.x 03139118a -> 406b53791

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

Branch: refs/heads/3.0.x
Commit: 406b53791e7f1df946f61b554086414e6464492a
Parents: 0313911
Author: Max Woghiren <[email protected]>
Authored: Tue Jul 16 12:47:28 2013 -0400
Committer: Shazron Abdullah <[email protected]>
Committed: Tue Jul 16 12:50:43 2013 -0700

----------------------------------------------------------------------
 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/406b5379/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() {

Reply via email to