function runTests() {
  chrome.test.runTests([
    // Read contents of the /hello directory. This directory exists, so it
    // should succeed.
    function readEntriesSuccess() {
      test_util.fileSystem.root.getDirectory(
          'hello',
          {create: false},
          chrome.test.callbackPass(function(dirEntry) {
            var dirReader = dirEntry.createReader();
            var entries = [];
            var readEntriesNext = function() {
              dirReader.readEntries(
                  chrome.test.callbackPass(function(inEntries) {
                    Array.prototype.push.apply(entries, inEntries);
                    if (!inEntries.length) {
                      // No more entries, so verify.
                      chrome.test.assertEq(2, entries.length);
                      chrome.test.assertTrue(entries[0].isFile);
                      chrome.test.assertEq('tiramisu.txt', entries[0].name);
                      chrome.test.assertEq(
                          '/hello/tiramisu.txt', entries[0].fullPath);
                      chrome.test.assertTrue(entries[1].isDirectory);
                      chrome.test.assertEq('candies', entries[1].name);
                      chrome.test.assertEq(
                          '/hello/candies', entries[1].fullPath);
                    } else {
                      readEntriesNext();
                    }
                  }), function(error) {
                    chrome.test.fail();
                  });
            };
            readEntriesNext();
          }),
          function(error) {
            chrome.test.fail();
          });
    },
    // Read contents of a directory which does not exist, what should return an
    // error.
    function readEntriesError() {
      test_util.fileSystem.root.getDirectory(
          'cranberries',
          {create: false},
          function(dirEntry) {
            chrome.test.fail();
          },
          chrome.test.callbackPass(function(error) {
            chrome.test.assertEq('NotFoundError', error.name);
          }));
    }
  ]);
}
/**
 * Runs all of the test cases, one by one.
 */
Runs all of the test cases, one by one.
Runs all of the test cases one by one .
function runTests() {
  chrome.test.runTests([
    function readEntriesSuccess() {
      test_util.fileSystem.root.getDirectory(
          'hello',
          {create: false},
          chrome.test.callbackPass(function(dirEntry) {
            var dirReader = dirEntry.createReader();
            var entries = [];
            var readEntriesNext = function() {
              dirReader.readEntries(
                  chrome.test.callbackPass(function(inEntries) {
                    Array.prototype.push.apply(entries, inEntries);
                    if (!inEntries.length) {
                      chrome.test.assertEq(2, entries.length);
                      chrome.test.assertTrue(entries[0].isFile);
                      chrome.test.assertEq('tiramisu.txt', entries[0].name);
                      chrome.test.assertEq(
                          '/hello/tiramisu.txt', entries[0].fullPath);
                      chrome.test.assertTrue(entries[1].isDirectory);
                      chrome.test.assertEq('candies', entries[1].name);
                      chrome.test.assertEq(
                          '/hello/candies', entries[1].fullPath);
                    } else {
                      readEntriesNext();
                    }
                  }), function(error) {
                    chrome.test.fail();
                  });
            };
            readEntriesNext();
          }),
          function(error) {
            chrome.test.fail();
          });
    },
    function readEntriesError() {
      test_util.fileSystem.root.getDirectory(
          'cranberries',
          {create: false},
          function(dirEntry) {
            chrome.test.fail();
          },
          chrome.test.callbackPass(function(error) {
            chrome.test.assertEq('NotFoundError', error.name);
          }));
    }
  ]);
}
function runTests ( ) { chrome . test . runTests ( [ function readEntriesSuccess ( ) { test_util . fileSystem . root . getDirectory ( 'hello' , { create : false } , chrome . test . callbackPass ( function ( dirEntry ) { var dirReader = dirEntry . createReader ( ) ; var entries = [ ] ; var readEntriesNext = function ( ) { dirReader . readEntries ( chrome . test . callbackPass ( function ( inEntries ) { Array . prototype . push . apply ( entries , inEntries ) ; if ( ! inEntries . length ) { chrome . test . assertEq ( 2 , entries . length ) ; chrome . test . assertTrue ( entries [ 0 ] . isFile ) ; chrome . test . assertEq ( 'tiramisu.txt' , entries [ 0 ] . name ) ; chrome . test . assertEq ( '/hello/tiramisu.txt' , entries [ 0 ] . fullPath ) ; chrome . test . assertTrue ( entries [ 1 ] . isDirectory ) ; chrome . test . assertEq ( 'candies' , entries [ 1 ] . name ) ; chrome . test . assertEq ( '/hello/candies' , entries [ 1 ] . fullPath ) ; } else { readEntriesNext ( ) ; } } ) , function ( error ) { chrome . test . fail ( ) ; } ) ; } ; readEntriesNext ( ) ; } ) , function ( error ) { chrome . test . fail ( ) ; } ) ; } , function readEntriesError ( ) { test_util . fileSystem . root . getDirectory ( 'cranberries' , { create : false } , function ( dirEntry ) { chrome . test . fail ( ) ; } , chrome . test . callbackPass ( function ( error ) { chrome . test . assertEq ( 'NotFoundError' , error . name ) ; } ) ) ; } ] ) ; }
Runs all of the test cases, one by one.
Runs all of the test cases one by one .
// Read contents of the /hello directory. This directory exists, so it // should succeed. // No more entries, so verify. // Read contents of a directory which does not exist, what should return an // error.