Commit 9973a074 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Speed-up keyboard_operations.js delete file tests

Bug 873915 notes flakey time-outs on the Mash bots for keyboard delete
on Drive tests. Speed-up the delete file tests by loading the one file
needed for the test (photos). Make the test delete one file (not two).

Minor: fix comments, group the keyboard delete test cases together.

Test: browser_tests --gtest_filter="*/FilesApp*keyboardDelete*"
Bug: 873915
Change-Id: I2af501ef6b10cbad323991fcdec2f500260ad0d3
Reviewed-on: https://chromium-review.googlesource.com/1174336Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583119}
parent 9625bbf1
...@@ -26,7 +26,7 @@ function waitAndAcceptDialog(windowId) { ...@@ -26,7 +26,7 @@ function waitAndAcceptDialog(windowId) {
} }
/** /**
* Obtains visible tree items. * Returns the visible directory tree items.
* *
* @param {string} windowId Window ID. * @param {string} windowId Window ID.
* @return {!Promise<!Array<string>>} List of visible item names. * @return {!Promise<!Array<string>>} List of visible item names.
...@@ -36,10 +36,10 @@ function getTreeItems(windowId) { ...@@ -36,10 +36,10 @@ function getTreeItems(windowId) {
} }
/** /**
* Waits until the directory item appears. * Waits until the directory tree item |name| appears.
* *
* @param {string} windowId Window ID. * @param {string} windowId Window ID.
* @param {string} name Name of item. * @param {string} name Name of tree item.
* @return {!Promise} * @return {!Promise}
*/ */
function waitForDirectoryItem(windowId, name) { function waitForDirectoryItem(windowId, name) {
...@@ -56,10 +56,10 @@ function waitForDirectoryItem(windowId, name) { ...@@ -56,10 +56,10 @@ function waitForDirectoryItem(windowId, name) {
} }
/** /**
* Waits until the directory item disappears. * Waits until the directory tree item |name| disappears.
* *
* @param {string} windowId Window ID. * @param {string} windowId Window ID.
* @param {string} name Name of item. * @param {string} name Name of tree item.
* @return {!Promise} * @return {!Promise}
*/ */
function waitForDirectoryItemLost(windowId, name) { function waitForDirectoryItemLost(windowId, name) {
...@@ -77,10 +77,10 @@ function waitForDirectoryItemLost(windowId, name) { ...@@ -77,10 +77,10 @@ function waitForDirectoryItemLost(windowId, name) {
} }
/** /**
* Tests copying a file to the same directory and waits until the file lists * Tests copying a file to the same directory and waits until the file list
* changes. * changes.
* *
* @param {string} path Directory path to be tested. * @param {string} path Directory path to be tested, Downloads or Drive.
*/ */
function keyboardCopy(path, callback) { function keyboardCopy(path, callback) {
var filename = 'world.ogv'; var filename = 'world.ogv';
...@@ -92,7 +92,7 @@ function keyboardCopy(path, callback) { ...@@ -92,7 +92,7 @@ function keyboardCopy(path, callback) {
var appId; var appId;
StepsRunner.run([ StepsRunner.run([
// Set up File Manager. // Open Files app on |path|.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next);
}, },
...@@ -118,85 +118,46 @@ function keyboardCopy(path, callback) { ...@@ -118,85 +118,46 @@ function keyboardCopy(path, callback) {
} }
/** /**
* Tests deleting a file and and waits until the file lists changes. * Tests deleting an entry from the file list. The entry is also shown in the
* @param {string} path Directory path to be tested. * directory tree, and should not be shown there when it is deleted.
* @param {string} treeItem The Downloads or Drive tree item selector. *
* @param {string} path Directory path to be tested, Downloads or Drive.
* @param {string} treeItem The directory tree item selector.
*/ */
function keyboardDelete(path, treeItem) { function keyboardDelete(path, treeItem) {
// Returns true if |fileList| contains |filename|. let appId;
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([ StepsRunner.run([
// Set up File Manager. // Open Files app on |path| containing one file entry: photos.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(
null, path, this.next, [ENTRIES.photos], [ENTRIES.photos]);
}, },
// Delete the file. // Expand the directory tree |treeItem|.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
fileListBefore = results.fileList;
chrome.test.assertTrue(isFilePresent(filename, fileListBefore));
this.next();
},
function() {
expandRoot(appId, treeItem).then(this.next); expandRoot(appId, treeItem).then(this.next);
}, },
function(){ // Check: the file should be shown in the directory tree.
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() { function() {
// Check that the directory appears in the LHS tree waitForDirectoryItem(appId, 'photos').then(this.next);
waitForDirectoryItem(appId, directoryName).then(this.next);
}, },
// Wait for a file list change. // Delete the file from the file list.
function() { function() {
remoteCall.waitForFileListChange(appId, fileListBefore.length). remoteCall.callRemoteTestUtil('deleteFile', appId, ['photos'], this.next);
then(this.next);
}, },
// Delete the directory. // Run the file delete confirmation dialog.
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) { function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result, 'deleteFile failed');
waitAndAcceptDialog(appId).then(this.next); waitAndAcceptDialog(appId).then(this.next);
}, },
// Wait for a file list change. // Check: the file list should now be empty.
function() { function() {
remoteCall.waitForFileListChange( remoteCall.waitForFiles(appId, []).then(this.next);
appId, fileListBefore.length).then(this.next);
},
// Verify the result.
function(fileList) {
chrome.test.assertFalse(isFilePresent(directoryName, fileList));
this.next();
}, },
// Check: the file should not be shown in the directory tree.
function() { function() {
// Check that the directory is removed from the LHS tree waitForDirectoryItemLost(appId, 'photos').then(this.next);
waitForDirectoryItemLost(appId, directoryName).then(this.next);
}, },
function() { function() {
checkIfNoErrorsOccured(this.next); checkIfNoErrorsOccured(this.next);
...@@ -337,14 +298,14 @@ testcase.keyboardCopyDownloads = function() { ...@@ -337,14 +298,14 @@ testcase.keyboardCopyDownloads = function() {
keyboardCopy(RootPath.DOWNLOADS); keyboardCopy(RootPath.DOWNLOADS);
}; };
testcase.keyboardDeleteDownloads = function() {
keyboardDelete(RootPath.DOWNLOADS, TREEITEM_DOWNLOADS);
};
testcase.keyboardCopyDrive = function() { testcase.keyboardCopyDrive = function() {
keyboardCopy(RootPath.DRIVE); keyboardCopy(RootPath.DRIVE);
}; };
testcase.keyboardDeleteDownloads = function() {
keyboardDelete(RootPath.DOWNLOADS, TREEITEM_DOWNLOADS);
};
testcase.keyboardDeleteDrive = function() { testcase.keyboardDeleteDrive = function() {
keyboardDelete(RootPath.DRIVE, TREEITEM_DRIVE); keyboardDelete(RootPath.DRIVE, TREEITEM_DRIVE);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment