1 description("DirectoryReader.readEntries() test.");
4 var resultEntries
= [];
6 var readEntriesCount
= 0;
7 var entriesCallbackCount
= 0;
9 // path: isDirectory map.
18 var testEntriesCount
= 0;
22 removeAllInDirectory(fileSystem
.root
);
26 function errorCallback(error
)
28 debug("Error occured:" + error
.name
);
33 function verifyTestResult()
35 shouldBe('readEntriesCount', 'entriesCallbackCount');
36 shouldBe('resultEntries.length', 'testEntriesCount');
37 resultEntries
.sort(function(a
, b
) { return (a
.fullPath
> b
.fullPath
) ? 1 : (a
.fullPath
< b
.fullPath
) ? -1 : 0; });
38 for (i
= 0; i
< resultEntries
.length
; ++i
) {
39 entry
= resultEntries
[i
];
40 debug('Entry:' + entry
.fullPath
+ ' isDirectory:' + entry
.isDirectory
);
41 shouldBe('testEntries[entry.fullPath]', 'entry.isDirectory');
46 function entriesCallback(_entries
)
48 entriesCallbackCount
++;
50 shouldBe("entries.__proto__", "Array.prototype");
51 resultEntries
.push
.apply(resultEntries
, entries
);
55 reader
.readEntries(entriesCallback
, errorCallback
);
57 // Must have read all the entries.
63 function runReadDirectoryTest()
66 reader
= fileSystem
.root
.createReader();
67 reader
.readEntries(entriesCallback
, errorCallback
);
70 function prepareForTest()
72 var helper
= new JoinHelper();
73 var done = function() { helper
.done(); };
75 for (var path
in testEntries
) {
77 if (testEntries
[path
])
78 helper
.run(function() { fileSystem
.root
.getDirectory(path
, {create
:true}, done
, errorCallback
); });
80 helper
.run(function() { fileSystem
.root
.getFile(path
, {create
:true}, done
, errorCallback
); });
82 helper
.join(runReadDirectoryTest
);
85 function successCallback(fs
)
88 debug("Successfully obtained Persistent FileSystem:" + fileSystem
.name
);
89 removeAllInDirectory(fileSystem
.root
, prepareForTest
, errorCallback
);
92 if (window
.webkitRequestFileSystem
) {
93 webkitRequestFileSystem(window
.TEMPORARY
, 100, successCallback
, errorCallback
);
94 window
.jsTestIsAsync
= true;
96 debug("This test requires FileSystem API support.");