Commit 00dda813 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Update KeyboardOperations test renameFile helper

Use appId, document all test steps, use precise selectors when dealing
with the #file-list [renaming] element and its <input> (exactly as per
the testRenameFolder test below), check step return results.

Bug: 877557
Change-Id: If57085de229f8213852d0fd1730871a5ad059004
Reviewed-on: https://chromium-review.googlesource.com/1189516Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586200}
parent 029a2d98
...@@ -195,29 +195,38 @@ function keyboardDeleteFolder(path, treeItem) { ...@@ -195,29 +195,38 @@ function keyboardDeleteFolder(path, treeItem) {
/** /**
* Renames a file. * Renames a file.
* @param {string} windowId ID of the window. *
* @param {string} appId The Files app windowId.
* @param {string} oldName Old name of a file. * @param {string} oldName Old name of a file.
* @param {string} newName New name of a file. * @param {string} newName New name of a file.
* @return {Promise} Promise to be fulfilled on success. * @return {Promise} Promise to be fulfilled on success.
*/ */
function renameFile(windowId, oldName, newName) { function renameFile(appId, oldName, newName) {
return remoteCall.callRemoteTestUtil('selectFile', windowId, [oldName]). const textInput = '#file-list .table-row[renaming] input.rename';
then(function() {
// Push Ctrl+Enter. return Promise.resolve().then(function() {
return remoteCall.fakeKeyDown( // Select the file.
windowId, '#detail-table', 'Enter', 'Enter', true, false, false); return remoteCall.callRemoteTestUtil('selectFile', appId, [oldName]);
}).then(function() { }).then(function(result) {
// Wait for rename text field. chrome.test.assertTrue(result, 'selectFile failed');
return remoteCall.waitForElement(windowId, 'input.rename'); // Press Ctrl+Enter key to rename the file.
}).then(function() { const key = ['#file-list', 'Enter', 'Enter', true, false, false];
// Type new file name. return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
return remoteCall.callRemoteTestUtil( }).then(function(result) {
'inputText', windowId, ['input.rename', newName]); chrome.test.assertTrue(result);
}).then(function() { // Check: the renaming text input should be shown in the file list.
// Push Enter. return remoteCall.waitForElement(appId, textInput);
return remoteCall.fakeKeyDown( }).then(function() {
windowId, 'input.rename', 'Enter', 'Enter', false, false, false); // Type new file name.
}); return remoteCall.callRemoteTestUtil(
'inputText', appId, [textInput, newName]);
}).then(function() {
// Send Enter key to the text input.
const key = [textInput, 'Enter', 'Enter', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) {
chrome.test.assertTrue(result);
});
} }
/** /**
......
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