111 "test1",
"test11",
"test12",
"test13",
112 "test2",
"test21",
"test211",
"test212",
113 "test3",
"test31",
"test311",
"test312",
114 "test32",
"test321",
"test3211",
122 enumConfig: { maxDepth: 2 },
123 expectedResult: [
"test1",
"test11",
"test12",
"test13",
125 "test3",
"test31",
"test32",
132 enumConfig: { filesOnly:
true },
133 expectedResult: [
"test11",
"test12",
"test13",
134 "test211",
"test212",
135 "test311",
"test312",
"test3211" ]
140 name:
"directories only",
141 enumConfig: { directoriesOnly:
true },
142 expectedResult: [
"test1",
"test2",
"test21",
143 "test3",
"test31",
"test32",
"test321",
160 _testPendingIndicated:
false,
161 _allTestsComplete:
false,
168 start:
function testDirectoryEnumerator_start() {
174 func =
function() {
return _this._testExistence(); };
175 this._testList.push(func);
176 for (var
i = 0;
i < this.enumerationTestList.length;
i++) {
181 let enumerationTest = this.enumerationTestList[
i];
182 func =
function() {
return _this._testEnumeration(enumerationTest); };
185 this._testList.push(func);
189 this._nextTestIndex = 0;
198 _runNextTest:
function testDirectoryEnumerator__runNextTest() {
202 if (this._nextTestIndex >= this._testList.length) {
203 this._allTestsComplete =
true;
204 if (this._testPendingIndicated) {
211 if (!this._testList[this._nextTestIndex++]()) {
214 if (!this._allTestsComplete && !this._testPendingIndicated) {
215 this._testPendingIndicated =
true;
228 _testExistence:
function testDirectoryEnumerator__testExistence() {
230 dump(
"Running existence test.");
233 var directoryEnumerator;
235 directoryEnumerator =
236 Cc[
"@songbirdnest.com/Songbird/DirectoryEnumerator;1"]
237 .createInstance(
Ci.sbIDirectoryEnumerator);
240 "Directory enumerator component is not available.");
254 function testDirectoryEnumerator__testEnumeration(aTestConfig) {
256 dump(
"Running enumeration test " + aTestConfig.name +
"\n");
259 var testDir = this._createTestDir(this.testDir);
262 var directoryEnumerator =
263 Cc[
"@songbirdnest.com/Songbird/DirectoryEnumerator;1"]
264 .createInstance(
Ci.sbIDirectoryEnumerator);
267 var enumConfig = aTestConfig.enumConfig;
268 for (var config in enumConfig) {
269 directoryEnumerator[config] = enumConfig[config];
274 directoryEnumerator.enumerate(testDir);
275 while (directoryEnumerator.hasMoreElements()) {
276 result.push(directoryEnumerator.getNext().leafName);
278 dump(
"Result: " + result +
"\n");
282 testDir.remove(
true);
299 function testDirectoryEnumerator__createTestDir(aTestDirStruct) {
301 var temporaryFileService =
302 Cc[
"@songbirdnest.com/Songbird/TemporaryFileService;1"]
303 .getService(
Ci.sbITemporaryFileService);
304 var testDir = temporaryFileService.createFile(
Ci.nsIFile.DIRECTORY_TYPE);
307 this._addTestSubDir(aTestDirStruct, testDir);
313 function testDirectoryEnumerator__createTestSubdir(aTestDirStruct,
316 for (var
name in aTestDirStruct) {
324 var
dir = aTestDir.clone();
326 dir.create(
Ci.nsIFile.DIRECTORY_TYPE, aTestDir.permissions);
327 this._addTestSubDir(entry, dir);
330 var
file = aTestDir.clone();
332 file.create(
Ci.nsIFile.NORMAL_FILE_TYPE, aTestDir.permissions);
function assertTrue(aTest, aMessage)
function assertSetsEqual(s1, s2)
var testDirectoryEnumerator
function runTest()
Advanced DataRemote unit tests.
_getSelectedPageStyle s i