function keyboardDelete(path, treeItem) {
  // Returns true if |fileList| contains |filename|.
  var isFilePresent = function(filename, fileList) {
    for (var i = 0; i < fileList.length; i++) {
      if (getFileName(fileList[i]) == filename)
        return true;
    }
    return false;
  };

  var filename = 'world.ogv';
  var directoryName = 'photos';
  var appId, fileListBefore;
  StepsRunner.run([
    // Set up File Manager.
    function() {
      setupAndWaitUntilReady(null, path, this.next);
    },
    // Delete the file.
    function(results) {
      appId = results.windowId;
      fileListBefore = results.fileList;
      chrome.test.assertTrue(isFilePresent(filename, fileListBefore));
      this.next();
    },
    function() {
      expandRoot(appId, treeItem).then(this.next);
    },
    function(){
      remoteCall.waitForElement(appId, '#detail-table').then(this.next);
    },
    function(){
      remoteCall.callRemoteTestUtil(
          'deleteFile', appId, [filename], this.next);
    },
    // Reply to a dialog.
    function(result) {
      chrome.test.assertTrue(result);
      waitAndAcceptDialog(appId).then(this.next);
    },
    function() {
      // Check that the directory appears in the LHS tree
      waitForDirectoryItem(appId, directoryName).then(this.next);
    },
    // Wait for a file list change.
    function() {
      remoteCall.waitForFileListChange(appId, fileListBefore.length).
        then(this.next);
    },
    // Delete the directory.
    function(fileList) {
      fileListBefore = fileList;
      chrome.test.assertFalse(isFilePresent(filename, fileList));
      chrome.test.assertTrue(isFilePresent(directoryName, fileList));
      remoteCall.callRemoteTestUtil(
          'deleteFile', appId, [directoryName], this.next);
    },
    // Reply to a dialog.
    function(result) {
      chrome.test.assertTrue(result);
      waitAndAcceptDialog(appId).then(this.next);
    },
    // Wait for a file list change.
    function() {
      remoteCall.waitForFileListChange(
          appId, fileListBefore.length).then(this.next);
    },
    // Verify the result.
    function(fileList) {
      chrome.test.assertFalse(isFilePresent(directoryName, fileList));
      this.next();
    },
    function() {
      // Check that the directory is removed from the LHS tree
      waitForDirectoryItemLost(appId, directoryName).then(this.next);
    },
    function() {
      checkIfNoErrorsOccured(this.next);
    }
  ]);
}
/**
 * Tests deleting a file and and waits until the file lists changes.
 * @param {string} path Directory path to be tested.
 * @param {string} treeItem The Downloads or Drive tree item selector.
 */
Tests deleting a file and and waits until the file lists changes.
@param {string} path Directory path to be tested.
@param {string} treeItem The Downloads or Drive tree item selector.
Tests deleting a file and and waits until the file lists changes . @param { string } path Directory path to be tested . @param { string } treeItem The Downloads or Drive tree item selector .
function keyboardDelete(path, treeItem) {
  var isFilePresent = function(filename, fileList) {
    for (var i = 0; i < fileList.length; i++) {
      if (getFileName(fileList[i]) == filename)
        return true;
    }
    return false;
  };
  var filename = 'world.ogv';
  var directoryName = 'photos';
  var appId, fileListBefore;
  StepsRunner.run([
    function() {
      setupAndWaitUntilReady(null, path, this.next);
    },
    function(results) {
      appId = results.windowId;
      fileListBefore = results.fileList;
      chrome.test.assertTrue(isFilePresent(filename, fileListBefore));
      this.next();
    },
    function() {
      expandRoot(appId, treeItem).then(this.next);
    },
    function(){
      remoteCall.waitForElement(appId, '#detail-table').then(this.next);
    },
    function(){
      remoteCall.callRemoteTestUtil(
          'deleteFile', appId, [filename], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      waitAndAcceptDialog(appId).then(this.next);
    },
    function() {
      waitForDirectoryItem(appId, directoryName).then(this.next);
    },
    function() {
      remoteCall.waitForFileListChange(appId, fileListBefore.length).
        then(this.next);
    },
    function(fileList) {
      fileListBefore = fileList;
      chrome.test.assertFalse(isFilePresent(filename, fileList));
      chrome.test.assertTrue(isFilePresent(directoryName, fileList));
      remoteCall.callRemoteTestUtil(
          'deleteFile', appId, [directoryName], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      waitAndAcceptDialog(appId).then(this.next);
    },
    function() {
      remoteCall.waitForFileListChange(
          appId, fileListBefore.length).then(this.next);
    },
    function(fileList) {
      chrome.test.assertFalse(isFilePresent(directoryName, fileList));
      this.next();
    },
    function() {
      waitForDirectoryItemLost(appId, directoryName).then(this.next);
    },
    function() {
      checkIfNoErrorsOccured(this.next);
    }
  ]);
}
function keyboardDelete ( path , treeItem ) { var isFilePresent = function ( filename , fileList ) { for ( var i = 0 ; i < fileList . length ; i ++ ) { if ( getFileName ( fileList [ i ] ) == filename ) return true ; } return false ; } ; var filename = 'world.ogv' ; var directoryName = 'photos' ; var appId , fileListBefore ; StepsRunner . run ( [ function ( ) { setupAndWaitUntilReady ( null , path , this . next ) ; } , function ( results ) { appId = results . windowId ; fileListBefore = results . fileList ; chrome . test . assertTrue ( isFilePresent ( filename , fileListBefore ) ) ; this . next ( ) ; } , function ( ) { expandRoot ( appId , treeItem ) . then ( this . next ) ; } , function ( ) { remoteCall . waitForElement ( appId , '#detail-table' ) . then ( this . next ) ; } , function ( ) { remoteCall . callRemoteTestUtil ( 'deleteFile' , appId , [ filename ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; waitAndAcceptDialog ( appId ) . then ( this . next ) ; } , function ( ) { waitForDirectoryItem ( appId , directoryName ) . then ( this . next ) ; } , function ( ) { remoteCall . waitForFileListChange ( appId , fileListBefore . length ) . then ( this . next ) ; } , function ( fileList ) { fileListBefore = fileList ; chrome . test . assertFalse ( isFilePresent ( filename , fileList ) ) ; chrome . test . assertTrue ( isFilePresent ( directoryName , fileList ) ) ; remoteCall . callRemoteTestUtil ( 'deleteFile' , appId , [ directoryName ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; waitAndAcceptDialog ( appId ) . then ( this . next ) ; } , function ( ) { remoteCall . waitForFileListChange ( appId , fileListBefore . length ) . then ( this . next ) ; } , function ( fileList ) { chrome . test . assertFalse ( isFilePresent ( directoryName , fileList ) ) ; this . next ( ) ; } , function ( ) { waitForDirectoryItemLost ( appId , directoryName ) . then ( this . next ) ; } , function ( ) { checkIfNoErrorsOccured ( this . next ) ; } ] ) ; }
Tests deleting a file and and waits until the file lists changes.
Tests deleting a file and and waits until the file lists changes .
// Returns true if |fileList| contains |filename|. // Set up File Manager. // Delete the file. // Reply to a dialog. // Check that the directory appears in the LHS tree // Wait for a file list change. // Delete the directory. // Reply to a dialog. // Wait for a file list change. // Verify the result. // Check that the directory is removed from the LHS tree