function copyBetweenVolumes(targetFile,
                            srcName,
                            srcEntries,
                            dstName,
                            dstEntries) {
  var srcContents = TestEntryInfo.getExpectedRows(srcEntries).sort();
  var dstContents = TestEntryInfo.getExpectedRows(dstEntries).sort();

  var appId;
  StepsRunner.run([
    // Set up File Manager.
    function() {
      setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
    },
    // Select the source volume.
    function(results) {
      appId = results.windowId;
      remoteCall.callRemoteTestUtil(
          'selectVolume', appId, [srcName], this.next);
    },
    // Wait for the expected files to appear in the file list.
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.waitForFiles(appId, srcContents).then(this.next);
    },
    // Set focus on the file list.
    function() {
      remoteCall.callRemoteTestUtil(
          'focus', appId, ['#file-list:not([hidden])'], this.next);
    },
    // Select the source file.
    function() {
      remoteCall.callRemoteTestUtil(
          'selectFile', appId, [targetFile.nameText], this.next);
    },
    // Copy the file.
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.callRemoteTestUtil('execCommand', appId, ['copy'], this.next);
    },
    // Select the destination volume.
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.callRemoteTestUtil(
          'selectVolume', appId, [dstName], this.next);
    },
    // Wait for the expected files to appear in the file list.
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.waitForFiles(appId, dstContents).then(this.next);
    },
    // Paste the file.
    function() {
      remoteCall.callRemoteTestUtil('execCommand', appId, ['paste'], this.next);
    },
    // Wait for the file list to change.
    function(result) {
      chrome.test.assertTrue(result);
      var ignoreFileSize =
          srcName == 'drive_shared_with_me' ||
          srcName == 'drive_offline' ||
          dstName == 'drive_shared_with_me' ||
          dstName == 'drive_offline';
      var dstContentsAfterPaste = dstContents.slice();
      var pasteFile = targetFile.getExpectedRow();
      for (var i = 0; i < dstContentsAfterPaste.length; i++) {
        if (dstContentsAfterPaste[i][0] === pasteFile[0]) {
          // Replace the last '.' in filename with ' (1).'.
          // e.g. 'my.note.txt' -> 'my.note (1).txt'
          pasteFile[0] = pasteFile[0].replace(/\.(?=[^\.]+$)/, ' (1).');
          break;
        }
      }
      dstContentsAfterPaste.push(pasteFile);
      remoteCall.waitForFiles(appId, dstContentsAfterPaste, {
        ignoreFileSize: ignoreFileSize,
        ignoreLastModifiedTime: true
      }).then(this.next);
    },
    // Check the last contents of file list.
    function() {
      checkIfNoErrorsOccured(this.next);
    }
  ]);
}
/**
 * Test function to copy from the specified source to the specified destination.
 * @param {TestEntryInfo} targetFile TestEntryInfo of target file to be copied.
 * @param {string} srcName Type of source volume. e.g. downloads, drive,
 *     drive_recent, drive_shared_with_me, drive_offline.
 * @param {Array<TestEntryInfo>} srcEntries Expected initial contents in the
 *     source volume.
 * @param {string} dstName Type of destination volume.
 * @param {Array<TestEntryInfo>} dstEntries Expected initial contents in the
 *     destination volume.
 */
Test function to copy from the specified source to the specified destination.
@param {TestEntryInfo} targetFile TestEntryInfo of target file to be copied.
@param {string} srcName Type of source volume.
Test function to copy from the specified source to the specified destination . @param { TestEntryInfo } targetFile TestEntryInfo of target file to be copied . @param { string } srcName Type of source volume .
function copyBetweenVolumes(targetFile,
                            srcName,
                            srcEntries,
                            dstName,
                            dstEntries) {
  var srcContents = TestEntryInfo.getExpectedRows(srcEntries).sort();
  var dstContents = TestEntryInfo.getExpectedRows(dstEntries).sort();
  var appId;
  StepsRunner.run([
    function() {
      setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
    },
    function(results) {
      appId = results.windowId;
      remoteCall.callRemoteTestUtil(
          'selectVolume', appId, [srcName], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.waitForFiles(appId, srcContents).then(this.next);
    },
    function() {
      remoteCall.callRemoteTestUtil(
          'focus', appId, ['#file-list:not([hidden])'], this.next);
    },
    function() {
      remoteCall.callRemoteTestUtil(
          'selectFile', appId, [targetFile.nameText], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.callRemoteTestUtil('execCommand', appId, ['copy'], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.callRemoteTestUtil(
          'selectVolume', appId, [dstName], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      remoteCall.waitForFiles(appId, dstContents).then(this.next);
    },
    function() {
      remoteCall.callRemoteTestUtil('execCommand', appId, ['paste'], this.next);
    },
    function(result) {
      chrome.test.assertTrue(result);
      var ignoreFileSize =
          srcName == 'drive_shared_with_me' ||
          srcName == 'drive_offline' ||
          dstName == 'drive_shared_with_me' ||
          dstName == 'drive_offline';
      var dstContentsAfterPaste = dstContents.slice();
      var pasteFile = targetFile.getExpectedRow();
      for (var i = 0; i < dstContentsAfterPaste.length; i++) {
        if (dstContentsAfterPaste[i][0] === pasteFile[0]) {
          pasteFile[0] = pasteFile[0].replace(/\.(?=[^\.]+$)/, ' (1).');
          break;
        }
      }
      dstContentsAfterPaste.push(pasteFile);
      remoteCall.waitForFiles(appId, dstContentsAfterPaste, {
        ignoreFileSize: ignoreFileSize,
        ignoreLastModifiedTime: true
      }).then(this.next);
    },
    function() {
      checkIfNoErrorsOccured(this.next);
    }
  ]);
}
function copyBetweenVolumes ( targetFile , srcName , srcEntries , dstName , dstEntries ) { var srcContents = TestEntryInfo . getExpectedRows ( srcEntries ) . sort ( ) ; var dstContents = TestEntryInfo . getExpectedRows ( dstEntries ) . sort ( ) ; var appId ; StepsRunner . run ( [ function ( ) { setupAndWaitUntilReady ( null , RootPath . DOWNLOADS , this . next ) ; } , function ( results ) { appId = results . windowId ; remoteCall . callRemoteTestUtil ( 'selectVolume' , appId , [ srcName ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; remoteCall . waitForFiles ( appId , srcContents ) . then ( this . next ) ; } , function ( ) { remoteCall . callRemoteTestUtil ( 'focus' , appId , [ '#file-list:not([hidden])' ] , this . next ) ; } , function ( ) { remoteCall . callRemoteTestUtil ( 'selectFile' , appId , [ targetFile . nameText ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; remoteCall . callRemoteTestUtil ( 'execCommand' , appId , [ 'copy' ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; remoteCall . callRemoteTestUtil ( 'selectVolume' , appId , [ dstName ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; remoteCall . waitForFiles ( appId , dstContents ) . then ( this . next ) ; } , function ( ) { remoteCall . callRemoteTestUtil ( 'execCommand' , appId , [ 'paste' ] , this . next ) ; } , function ( result ) { chrome . test . assertTrue ( result ) ; var ignoreFileSize = srcName == 'drive_shared_with_me' || srcName == 'drive_offline' || dstName == 'drive_shared_with_me' || dstName == 'drive_offline' ; var dstContentsAfterPaste = dstContents . slice ( ) ; var pasteFile = targetFile . getExpectedRow ( ) ; for ( var i = 0 ; i < dstContentsAfterPaste . length ; i ++ ) { if ( dstContentsAfterPaste [ i ] [ 0 ] === pasteFile [ 0 ] ) { pasteFile [ 0 ] = pasteFile [ 0 ] . replace ( / \.(?=[^\.]+$) / , ' (1).' ) ; break ; } } dstContentsAfterPaste . push ( pasteFile ) ; remoteCall . waitForFiles ( appId , dstContentsAfterPaste , { ignoreFileSize : ignoreFileSize , ignoreLastModifiedTime : true } ) . then ( this . next ) ; } , function ( ) { checkIfNoErrorsOccured ( this . next ) ; } ] ) ; }
Test function to copy from the specified source to the specified destination.
Test function to copy from the specified source to the specified destination .
// Set up File Manager. // Select the source volume. // Wait for the expected files to appear in the file list. // Set focus on the file list. // Select the source file. // Copy the file. // Select the destination volume. // Wait for the expected files to appear in the file list. // Paste the file. // Wait for the file list to change. // Replace the last '.' in filename with ' (1).'. // e.g. 'my.note.txt' -> 'my.note (1).txt' // Check the last contents of file list.