Skip to content
Permalink
Browse files
[CB-4264] Fixed a DirectoryReader test.
The test now creates a file before testing the correctness of readEntries (and removes it afterwards).
  • Loading branch information
mwoghiren committed Jul 16, 2013
1 parent aba5de4 commit 3296c314f4366247d8ec3a65cf3eb94db1ba79db
Showing 1 changed file with 16 additions and 11 deletions.
@@ -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() {

0 comments on commit 3296c31

Please sign in to comment.