Commit 4a551412 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Remove keyIdentifier from fakeKeyDown test function

keyIdentifier is deprecated and replaced by "key" argument in
KeyboardEvent. Additionally our use of this was pretty inconsistent, so
removed it completely.

Change-Id: I35d6ba9660830b6c419f2a6e106bbde5162cf4b7
Reviewed-on: https://chromium-review.googlesource.com/1245080
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594535}
parent 9d46e6e6
...@@ -92,13 +92,13 @@ test.util.sync.getFileList = function(contentWindow) { ...@@ -92,13 +92,13 @@ test.util.sync.getFileList = function(contentWindow) {
test.util.sync.selectFile = function(contentWindow, filename) { test.util.sync.selectFile = function(contentWindow, filename) {
var rows = contentWindow.document.querySelectorAll('#detail-table li'); var rows = contentWindow.document.querySelectorAll('#detail-table li');
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'Home', 'Home', false, false, false); contentWindow, '#file-list', 'Home', false, false, false);
for (var index = 0; index < rows.length; ++index) { for (var index = 0; index < rows.length; ++index) {
var selection = test.util.sync.getSelectedFiles(contentWindow); var selection = test.util.sync.getSelectedFiles(contentWindow);
if (selection.length === 1 && selection[0] === filename) if (selection.length === 1 && selection[0] === filename)
return true; return true;
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'ArrowDown', 'Down', false, false, false); contentWindow, '#file-list', 'ArrowDown', false, false, false);
} }
console.error('Failed to select file "' + filename + '"'); console.error('Failed to select file "' + filename + '"');
return false; return false;
...@@ -193,19 +193,17 @@ test.util.sync.selectFolderInTree = function(contentWindow, folderName) { ...@@ -193,19 +193,17 @@ test.util.sync.selectFolderInTree = function(contentWindow, folderName) {
var items = var items =
contentWindow.document.querySelectorAll('#directory-tree .tree-item'); contentWindow.document.querySelectorAll('#directory-tree .tree-item');
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#directory-tree', 'Home', 'Home', false, false, false); contentWindow, '#directory-tree', 'Home', false, false, false);
for (var index = 0; index < items.length; ++index) { for (var index = 0; index < items.length; ++index) {
var selectedTreeItemName = var selectedTreeItemName =
test.util.sync.getSelectedTreeItem(contentWindow); test.util.sync.getSelectedTreeItem(contentWindow);
if (selectedTreeItemName === folderName) { if (selectedTreeItemName === folderName) {
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#directory-tree', 'Enter', 'Enter', false, false, contentWindow, '#directory-tree', 'Enter', false, false, false);
false);
return true; return true;
} }
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#directory-tree', 'ArrowDown', 'Down', false, false, contentWindow, '#directory-tree', 'ArrowDown', false, false, false);
false);
} }
console.error('Failed to select folder in tree "' + folderName + '"'); console.error('Failed to select folder in tree "' + folderName + '"');
...@@ -228,7 +226,7 @@ test.util.sync.expandSelectedFolderInTree = function(contentWindow) { ...@@ -228,7 +226,7 @@ test.util.sync.expandSelectedFolderInTree = function(contentWindow) {
} }
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#directory-tree .tree-item[selected]', 'ArrowRight', contentWindow, '#directory-tree .tree-item[selected]', 'ArrowRight',
'Right', false, false, false); false, false, false);
return true; return true;
}; };
...@@ -248,7 +246,7 @@ test.util.sync.collapseSelectedFolderInTree = function(contentWindow) { ...@@ -248,7 +246,7 @@ test.util.sync.collapseSelectedFolderInTree = function(contentWindow) {
} }
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#directory-tree .tree-item[selected]', 'ArrowLeft', contentWindow, '#directory-tree .tree-item[selected]', 'ArrowLeft',
'Left', false, false, false); false, false, false);
return true; return true;
}; };
...@@ -339,9 +337,9 @@ test.util.sync.copyFile = function(contentWindow, filename) { ...@@ -339,9 +337,9 @@ test.util.sync.copyFile = function(contentWindow, filename) {
return false; return false;
// Ctrl+C and Ctrl+V // Ctrl+C and Ctrl+V
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'c', 'U+0043', true, false, false); contentWindow, '#file-list', 'c', true, false, false);
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'v', 'U+0056', true, false, false); contentWindow, '#file-list', 'v', true, false, false);
return true; return true;
}; };
...@@ -358,7 +356,7 @@ test.util.sync.deleteFile = function(contentWindow, filename) { ...@@ -358,7 +356,7 @@ test.util.sync.deleteFile = function(contentWindow, filename) {
return false; return false;
// Delete // Delete
test.util.sync.fakeKeyDown( test.util.sync.fakeKeyDown(
contentWindow, '#file-list', 'Delete', 'U+007F', false, false, false); contentWindow, '#file-list', 'Delete', false, false, false);
return true; return true;
}; };
......
...@@ -350,25 +350,23 @@ test.util.sync.fakeEvent = function(contentWindow, ...@@ -350,25 +350,23 @@ test.util.sync.fakeEvent = function(contentWindow,
/** /**
* Sends a fake key event to the element specified by |targetQuery| or active * Sends a fake key event to the element specified by |targetQuery| or active
* element with the given |keyIdentifier| and optional |ctrl| modifier. * element with the given |key| and optional |ctrl,shift,alt| modifier.
* *
* @param {Window} contentWindow Window to be tested. * @param {Window} contentWindow Window to be tested.
* @param {?string} targetQuery Query to specify the element. If this value is * @param {?string} targetQuery Query to specify the element. If this value is
* null, key event is dispatched to active element of the document. * null, key event is dispatched to active element of the document.
* @param {string} key DOM UI Events key value. * @param {string} key DOM UI Events key value.
* @param {string} keyIdentifier Identifier of the emulated key.
* @param {boolean} ctrl Whether CTRL should be pressed, or not. * @param {boolean} ctrl Whether CTRL should be pressed, or not.
* @param {boolean} shift whether SHIFT should be pressed, or not. * @param {boolean} shift whether SHIFT should be pressed, or not.
* @param {boolean} alt whether ALT should be pressed, or not. * @param {boolean} alt whether ALT should be pressed, or not.
* @return {boolean} True if the event is sent to the target, false otherwise. * @return {boolean} True if the event is sent to the target, false otherwise.
*/ */
test.util.sync.fakeKeyDown = function( test.util.sync.fakeKeyDown = function(
contentWindow, targetQuery, key, keyIdentifier, ctrl, shift, alt) { contentWindow, targetQuery, key, ctrl, shift, alt) {
const event = new KeyboardEvent('keydown', { const event = new KeyboardEvent('keydown', {
bubbles: true, bubbles: true,
composed: true, // Allow the event to bubble past shadow DOM root. composed: true, // Allow the event to bubble past shadow DOM root.
key: key, key: key,
keyIdentifier: keyIdentifier,
ctrlKey: ctrl, ctrlKey: ctrl,
shiftKey: shift, shiftKey: shift,
altKey: alt altKey: alt
......
...@@ -16,7 +16,7 @@ quickview.openCloseQuickView = (file, opt_validate) => { ...@@ -16,7 +16,7 @@ quickview.openCloseQuickView = (file, opt_validate) => {
// changed to text file 'hello.txt'. // changed to text file 'hello.txt'.
assertTrue(test.selectFile(file)); assertTrue(test.selectFile(file));
// Press Space key. // Press Space key.
assertTrue(test.fakeKeyDown('#file-list', ' ', ' ', false, false, false)); assertTrue(test.fakeKeyDown('#file-list', ' ', false, false, false));
// Wait until Quick View is displayed and files-safe-media.src is set. // Wait until Quick View is displayed and files-safe-media.src is set.
return test return test
.repeatUntil(() => { .repeatUntil(() => {
......
...@@ -24,7 +24,7 @@ function selectFirstFileListItem(appId) { ...@@ -24,7 +24,7 @@ function selectFirstFileListItem(appId) {
return remoteCall.waitForElementLost(appId, '#file-list [selected]'); return remoteCall.waitForElementLost(appId, '#file-list [selected]');
}).then(function() { }).then(function() {
// Press DownArrow key to select an item. // Press DownArrow key to select an item.
const key = ['#file-list', 'ArrowDown', 'Down', false, false, false]; const key = ['#file-list', 'ArrowDown', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -58,7 +58,7 @@ function createNewFolder(appId, initialEntrySet, selector) { ...@@ -58,7 +58,7 @@ function createNewFolder(appId, initialEntrySet, selector) {
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
// Press Ctrl+E to create a new folder. // Press Ctrl+E to create a new folder.
const key = ['#file-list', 'e', 'U+0045', true, false, false]; const key = ['#file-list', 'e', true, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -101,7 +101,7 @@ function createNewFolder(appId, initialEntrySet, selector) { ...@@ -101,7 +101,7 @@ function createNewFolder(appId, initialEntrySet, selector) {
'inputText', appId, [textInput, 'Test Folder Name']); 'inputText', appId, [textInput, 'Test Folder Name']);
}).then(function() { }).then(function() {
// Press the Enter key. // Press the Enter key.
const key = [textInput, 'Enter', 'Enter', false, false, false]; const key = [textInput, 'Enter', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
......
...@@ -87,7 +87,7 @@ function navigateToDestinationDirectoryAndTestPaste(windowId) { ...@@ -87,7 +87,7 @@ function navigateToDestinationDirectoryAndTestPaste(windowId) {
// Paste // Paste
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId,
['body', 'v', 'U+0056' /* v */, true /* ctrl */, false, false]); ['body', 'v', true /* ctrl */, false, false]);
}) })
.then(function() { .then(function() {
// Confirm the photos directory is pasted correctly. // Confirm the photos directory is pasted correctly.
...@@ -104,7 +104,7 @@ function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) { ...@@ -104,7 +104,7 @@ function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) {
return (useKeyboardShortcut ? return (useKeyboardShortcut ?
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId,
['body', 'Enter', 'Enter', true /* ctrl */, false, false]) : ['body', 'Enter', true /* ctrl */, false, false]) :
clickDirectoryTreeContextMenuItem(windowId, '/photos', 'rename') clickDirectoryTreeContextMenuItem(windowId, '/photos', 'rename')
).then(function() { ).then(function() {
return remoteCall.waitForElement(windowId, '.tree-row > input'); return remoteCall.waitForElement(windowId, '.tree-row > input');
...@@ -114,7 +114,7 @@ function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) { ...@@ -114,7 +114,7 @@ function renamePhotosDirectoryTo(windowId, newName, useKeyboardShortcut) {
}).then(function() { }).then(function() {
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId,
['.tree-row > input', 'Enter', 'Enter', false, false, false]); ['.tree-row > input', 'Enter', false, false, false]);
}); });
} }
...@@ -171,7 +171,7 @@ function createDirectoryFromDirectoryTree( ...@@ -171,7 +171,7 @@ function createDirectoryFromDirectoryTree(
}).then(function() { }).then(function() {
if (useKeyboardShortcut) { if (useKeyboardShortcut) {
return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId,
['body', 'e', 'U+0045' /* e */, true /* ctrl */, false, false]); ['body', 'e', true /* ctrl */, false, false]);
} else { } else {
return clickDirectoryTreeContextMenuItem( return clickDirectoryTreeContextMenuItem(
windowId, '/photos', 'new-folder'); windowId, '/photos', 'new-folder');
...@@ -184,7 +184,7 @@ function createDirectoryFromDirectoryTree( ...@@ -184,7 +184,7 @@ function createDirectoryFromDirectoryTree(
}).then(function() { }).then(function() {
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId,
['.tree-row > input', 'Enter', 'Enter', false, false, false]); ['.tree-row > input', 'Enter', false, false, false]);
}).then(function() { }).then(function() {
// Confirm that new directory is added to the directory tree. // Confirm that new directory is added to the directory tree.
return remoteCall.waitForElement( return remoteCall.waitForElement(
...@@ -228,7 +228,7 @@ testcase.dirCopyWithKeyboard = function() { ...@@ -228,7 +228,7 @@ testcase.dirCopyWithKeyboard = function() {
}).then(function() { }).then(function() {
// Press Ctrl+C. // Press Ctrl+C.
return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId,
['body', 'c', 'U+0043' /* c */, true /* ctrl */, false, false]); ['body', 'c', true /* ctrl */, false, false]);
}).then(function() { }).then(function() {
return navigateToDestinationDirectoryAndTestPaste(windowId); return navigateToDestinationDirectoryAndTestPaste(windowId);
})); }));
...@@ -281,7 +281,7 @@ testcase.dirCutWithKeyboard = function() { ...@@ -281,7 +281,7 @@ testcase.dirCutWithKeyboard = function() {
}).then(function() { }).then(function() {
// Press Ctrl+X. // Press Ctrl+X.
return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId,
['body', 'x', 'U+0058' /* x */, true /* ctrl */, false, false]); ['body', 'x', true /* ctrl */, false, false]);
}).then(function() { }).then(function() {
return navigateToDestinationDirectoryAndTestPaste(windowId); return navigateToDestinationDirectoryAndTestPaste(windowId);
}).then(function() { }).then(function() {
...@@ -325,7 +325,7 @@ testcase.dirPasteWithContextMenu = function() { ...@@ -325,7 +325,7 @@ testcase.dirPasteWithContextMenu = function() {
.then(function() { .then(function() {
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId,
['body', 'c', 'U+0043' /* c */, true /* ctrl */, false, false]); ['body', 'c', true /* ctrl */, false, false]);
}) })
.then(function() { .then(function() {
return remoteCall.navigateWithDirectoryTree( return remoteCall.navigateWithDirectoryTree(
...@@ -437,7 +437,7 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() { ...@@ -437,7 +437,7 @@ testcase.dirRenameUpdateChildrenBreadcrumbs = function() {
}) })
.then(function() { .then(function() {
const enterKey = [ const enterKey = [
'.tree-row > input', 'Enter', 'Enter', false, false, false '.tree-row > input', 'Enter', false, false, false
]; ];
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, enterKey); 'fakeKeyDown', appId, enterKey);
......
...@@ -167,7 +167,7 @@ testcase.driveClickFirstSearchResult = function() { ...@@ -167,7 +167,7 @@ testcase.driveClickFirstSearchResult = function() {
appId = id; appId = id;
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
['#autocomplete-list', 'ArrowDown', 'Down', false, false, false], ['#autocomplete-list', 'ArrowDown', false, false, false],
this.next); this.next);
}, },
function(result) { function(result) {
...@@ -216,8 +216,7 @@ testcase.drivePressEnterToSearch = function() { ...@@ -216,8 +216,7 @@ testcase.drivePressEnterToSearch = function() {
function(result) { function(result) {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
['#search-box cr-input', 'Enter', 'Enter', false, false, false], ['#search-box cr-input', 'Enter', false, false, false], this.next);
this.next);
}, },
function(result) { function(result) {
remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length) remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length)
...@@ -330,7 +329,7 @@ testcase.drivePressCtrlAFromSearch = function() { ...@@ -330,7 +329,7 @@ testcase.drivePressCtrlAFromSearch = function() {
function(result) { function(result) {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
['#search-box cr-input', 'A', 'A', true, false, false], this.next); ['#search-box cr-input', 'A', true, false, false], this.next);
}, },
// Check we didn't enter check-select mode. // Check we didn't enter check-select mode.
function(result) { function(result) {
......
...@@ -176,7 +176,7 @@ function openFileDialogClickCancelButton(volume, name) { ...@@ -176,7 +176,7 @@ function openFileDialogClickCancelButton(volume, name) {
function openFileDialogSendEscapeKey(volume, name) { function openFileDialogSendEscapeKey(volume, name) {
const type = {type: 'openFile'}; const type = {type: 'openFile'};
const escapeKey = ['#file-list', 'Escape', 'U+001B', false, false, false]; const escapeKey = ['#file-list', 'Escape', false, false, false];
let closer = sendOpenFileDialogKey.bind(null, name, escapeKey); let closer = sendOpenFileDialogKey.bind(null, name, escapeKey);
return createFileEntryPromise(volume) return createFileEntryPromise(volume)
......
...@@ -265,7 +265,7 @@ testcase.traverseFolderShortcuts = function() { ...@@ -265,7 +265,7 @@ testcase.traverseFolderShortcuts = function() {
}, },
// Send Ctrl+3 key to file-list to select 3rd shortcut. // Send Ctrl+3 key to file-list to select 3rd shortcut.
function() { function() {
const key = ['#file-list', '3', '3', true, false, false]; const key = ['#file-list', '3', true, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: current directory and selection should be D. // Check: current directory and selection should be D.
...@@ -275,7 +275,7 @@ testcase.traverseFolderShortcuts = function() { ...@@ -275,7 +275,7 @@ testcase.traverseFolderShortcuts = function() {
}, },
// Send UpArrow key to directory tree to select the shortcut above D. // Send UpArrow key to directory tree to select the shortcut above D.
function() { function() {
const key = ['#directory-tree', 'ArrowUp', 'Up', false, false, false]; const key = ['#directory-tree', 'ArrowUp', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: current directory should be D, with shortcut C selected. // Check: current directory should be D, with shortcut C selected.
...@@ -285,7 +285,7 @@ testcase.traverseFolderShortcuts = function() { ...@@ -285,7 +285,7 @@ testcase.traverseFolderShortcuts = function() {
}, },
// Send Enter key to the directory tree to change to directory C. // Send Enter key to the directory tree to change to directory C.
function() { function() {
const key = ['#directory-tree', 'Enter', 'Enter', false, false, false]; const key = ['#directory-tree', 'Enter', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: current directory and selection should be C. // Check: current directory and selection should be C.
......
...@@ -269,7 +269,7 @@ testcase.toogleGoogleDocsDrive = function() { ...@@ -269,7 +269,7 @@ testcase.toogleGoogleDocsDrive = function() {
}, },
// Open the gear meny by a shortcut (Alt-E). // Open the gear meny by a shortcut (Alt-E).
function() { function() {
remoteCall.fakeKeyDown(appId, 'body', 'e', 'U+0045', false, false, true) remoteCall.fakeKeyDown(appId, 'body', 'e', false, false, true)
.then(this.next); .then(this.next);
}, },
// Wait for menu to appear. // Wait for menu to appear.
...@@ -548,7 +548,7 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -548,7 +548,7 @@ testcase.showPasteIntoCurrentFolder = function() {
function(result) { function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
remoteCall remoteCall
.fakeKeyDown(appId, '#file-list', 'c', 'U+0043', true, false, false) .fakeKeyDown(appId, '#file-list', 'c', true, false, false)
.then(this.next); .then(this.next);
}, },
function() { function() {
......
...@@ -179,7 +179,7 @@ function renameFile(appId, oldName, newName) { ...@@ -179,7 +179,7 @@ function renameFile(appId, oldName, newName) {
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result, 'selectFile failed'); chrome.test.assertTrue(result, 'selectFile failed');
// Press Ctrl+Enter key to rename the file. // Press Ctrl+Enter key to rename the file.
const key = ['#file-list', 'Enter', 'Enter', true, false, false]; const key = ['#file-list', 'Enter', true, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -191,7 +191,7 @@ function renameFile(appId, oldName, newName) { ...@@ -191,7 +191,7 @@ function renameFile(appId, oldName, newName) {
'inputText', appId, [textInput, newName]); 'inputText', appId, [textInput, newName]);
}).then(function() { }).then(function() {
// Send Enter key to the text input. // Send Enter key to the text input.
const key = [textInput, 'Enter', 'Enter', false, false, false]; const key = [textInput, 'Enter', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -227,7 +227,7 @@ function testRenameFolder(path, treeItem) { ...@@ -227,7 +227,7 @@ function testRenameFolder(path, treeItem) {
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
// Press ArrowDown to select the photos folder. // Press ArrowDown to select the photos folder.
const select = ['#file-list', 'ArrowDown', 'Down', false, false, false]; const select = ['#file-list', 'ArrowDown', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, select); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, select);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -236,7 +236,7 @@ function testRenameFolder(path, treeItem) { ...@@ -236,7 +236,7 @@ function testRenameFolder(path, treeItem) {
return remoteCall.waitForElement(appId, selectedItem); return remoteCall.waitForElement(appId, selectedItem);
}).then(function() { }).then(function() {
// Press Ctrl+Enter to rename the photos folder. // Press Ctrl+Enter to rename the photos folder.
const key = ['#file-list', 'Enter', 'Enter', true, false, false]; const key = ['#file-list', 'Enter', true, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
...@@ -248,12 +248,12 @@ function testRenameFolder(path, treeItem) { ...@@ -248,12 +248,12 @@ function testRenameFolder(path, treeItem) {
'inputText', appId, [textInput, 'bbq photos']); 'inputText', appId, [textInput, 'bbq photos']);
}).then(function() { }).then(function() {
// Send Enter to the list to attempt to enter the directory. // Send Enter to the list to attempt to enter the directory.
const key = ['#list-container', 'Enter', 'Enter', false, false, false]; const key = ['#list-container', 'Enter', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
// Send Enter to the text input to complete renaming. // Send Enter to the text input to complete renaming.
const key = [textInput, 'Enter', 'Enter', false, false, false]; const key = [textInput, 'Enter', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key); return remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
}).then(function(result) { }).then(function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
......
...@@ -77,7 +77,7 @@ function audioPlayingQuery(fileName) { ...@@ -77,7 +77,7 @@ function audioPlayingQuery(fileName) {
function audioTimeLeapForward(audioAppId) { function audioTimeLeapForward(audioAppId) {
for (let i = 1; i <= 9; ++i) { for (let i = 1; i <= 9; ++i) {
audioPlayerApp.fakeKeyDown( audioPlayerApp.fakeKeyDown(
audioAppId, 'body', 'ArrowRight', 'Right', false, false, false); audioAppId, 'body', 'ArrowRight', false, false, false);
} }
} }
......
...@@ -30,7 +30,7 @@ function openQuickViewSteps(appId, name) { ...@@ -30,7 +30,7 @@ function openQuickViewSteps(appId, name) {
// Press the space key. // Press the space key.
function(result) { function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed'); chrome.test.assertTrue(!!result, 'selectFile failed');
const space = ['#file-list', ' ', ' ', false, false, false]; const space = ['#file-list', ' ', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space, this.next);
}, },
// Check: the Quick View element should be shown. // Check: the Quick View element should be shown.
......
...@@ -22,9 +22,7 @@ testcase.tabindexSearchBoxFocus = function() { ...@@ -22,9 +22,7 @@ testcase.tabindexSearchBoxFocus = function() {
// Press the Ctrl-F key. // Press the Ctrl-F key.
function(element) { function(element) {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId, ['body', 'f', true, false, false], this.next);
['body', 'f', 'U+0046', true, false, false],
this.next);
}, },
// Check that the search box has the focus. // Check that the search box has the focus.
function(result) { function(result) {
...@@ -36,8 +34,7 @@ testcase.tabindexSearchBoxFocus = function() { ...@@ -36,8 +34,7 @@ testcase.tabindexSearchBoxFocus = function() {
function(element) { function(element) {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
['#search-box cr-input', 'Escape', 'U+001B', false, false, false], ['#search-box cr-input', 'Escape', false, false, false], this.next);
this.next);
}, },
// Check that the file list has the focus. // Check that the file list has the focus.
function(result) { function(result) {
...@@ -286,8 +283,7 @@ function tabindexFocus(dialogParams, volumeName, expectedSet, initialize, ...@@ -286,8 +283,7 @@ function tabindexFocus(dialogParams, volumeName, expectedSet, initialize,
promise = promise.then(function() { promise = promise.then(function() {
// Closes the window by pressing Enter. // Closes the window by pressing Enter.
return remoteCall.callRemoteTestUtil( return remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, ['#file-list', 'Enter', 'Enter', false, false, 'fakeKeyDown', appId, ['#file-list', 'Enter', false, false, false]);
false]);
}); });
return promise; return promise;
......
...@@ -36,7 +36,7 @@ testcase.zipFileOpenDownloads = function() { ...@@ -36,7 +36,7 @@ testcase.zipFileOpenDownloads = function() {
// Press the Enter key. // Press the Enter key.
function(result) { function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed'); chrome.test.assertTrue(!!result, 'selectFile failed');
const key = ['#file-list', 'Enter', 'Enter', false, false, false]; const key = ['#file-list', 'Enter', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: the zip file content should be shown (unzip). // Check: the zip file content should be shown (unzip).
...@@ -69,7 +69,7 @@ testcase.zipFileOpenDrive = function() { ...@@ -69,7 +69,7 @@ testcase.zipFileOpenDrive = function() {
// Press the Enter key. // Press the Enter key.
function(result) { function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed'); chrome.test.assertTrue(!!result, 'selectFile failed');
const key = ['#file-list', 'Enter', 'Enter', false, false, false]; const key = ['#file-list', 'Enter', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: the zip file content should be shown (unzip). // Check: the zip file content should be shown (unzip).
...@@ -127,7 +127,7 @@ testcase.zipFileOpenUsb = function() { ...@@ -127,7 +127,7 @@ testcase.zipFileOpenUsb = function() {
// Press the Enter key. // Press the Enter key.
function(result) { function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed'); chrome.test.assertTrue(!!result, 'selectFile failed');
const key = ['#file-list', 'Enter', 'Enter', false, false, false]; const key = ['#file-list', 'Enter', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next); remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, },
// Check: the zip file content should be shown (unzip). // Check: the zip file content should be shown (unzip).
......
...@@ -114,7 +114,7 @@ function openMultipleImagesAndChangeToSlideMode(testVolumeName, volumeType) { ...@@ -114,7 +114,7 @@ function openMultipleImagesAndChangeToSlideMode(testVolumeName, volumeType) {
// Press Enter key and mode should be changed to slide mode. // Press Enter key and mode should be changed to slide mode.
return gallery.callRemoteTestUtil( return gallery.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
[null /* active element */, 'Enter', 'Enter', false, false, false]); [null /* active element */, 'Enter', false, false, false]);
}).then(function() { }).then(function() {
// Wait until it changes to slide mode. // Wait until it changes to slide mode.
return gallery.waitForElement(appId, '.gallery[mode="slide"]'); return gallery.waitForElement(appId, '.gallery[mode="slide"]');
......
...@@ -94,7 +94,7 @@ function cropImage(testVolumeName, volumeType) { ...@@ -94,7 +94,7 @@ function cropImage(testVolumeName, volumeType) {
}). }).
then(function() { then(function() {
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, 'body', 'Enter', 'Enter', false, false, false); appId, 'body', 'Enter', false, false, false);
}). }).
then(function(ret) { then(function(ret) {
chrome.test.assertTrue(ret); chrome.test.assertTrue(ret);
...@@ -158,8 +158,7 @@ function exposureImage(testVolumeName, volumeType) { ...@@ -158,8 +158,7 @@ function exposureImage(testVolumeName, volumeType) {
origMetadata = metadata; origMetadata = metadata;
// Push the Enter key. // Push the Enter key.
return gallery.fakeKeyDown(appId, 'body', 'Enter', 'Enter', false, false, return gallery.fakeKeyDown(appId, 'body', 'Enter', false, false, false);
false);
}).then(function() { }).then(function() {
// Wait until the image is updated. // Wait until the image is updated.
return repeatUntil(function() { return repeatUntil(function() {
...@@ -209,7 +208,7 @@ function resizeImage(testVolumeName, volumeType) { ...@@ -209,7 +208,7 @@ function resizeImage(testVolumeName, volumeType) {
}) })
.then(function() { .then(function() {
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, 'body', 'Enter', 'Enter', false, false, false); appId, 'body', 'Enter', false, false, false);
}) })
.then(function() { .then(function() {
return gallery.waitForSlideImage(appId, 667, 500, return gallery.waitForSlideImage(appId, 667, 500,
...@@ -248,7 +247,7 @@ function resizeImage(testVolumeName, volumeType) { ...@@ -248,7 +247,7 @@ function resizeImage(testVolumeName, volumeType) {
}) })
.then(function() { .then(function() {
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, 'body', 'Enter', 'Enter', false, false, false); appId, 'body', 'Enter', false, false, false);
}) })
.then(function() { .then(function() {
return gallery.waitForSlideImage(appId, 500, 300, return gallery.waitForSlideImage(appId, 500, 300,
......
...@@ -96,7 +96,7 @@ function deleteAllImagesInThumbnailMode(testVolumeName, volumeType, operation) { ...@@ -96,7 +96,7 @@ function deleteAllImagesInThumbnailMode(testVolumeName, volumeType, operation) {
}).then(function() { }).then(function() {
return gallery.callRemoteTestUtil( return gallery.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId,
['button.delete', 'Enter', 'Enter', false, false, false]); ['button.delete', 'Enter', false, false, false]);
}).then(function() { }).then(function() {
// When user has pressed enter key on button, click event is // When user has pressed enter key on button, click event is
// dispatched after keydown event. // dispatched after keydown event.
...@@ -107,8 +107,7 @@ function deleteAllImagesInThumbnailMode(testVolumeName, volumeType, operation) { ...@@ -107,8 +107,7 @@ function deleteAllImagesInThumbnailMode(testVolumeName, volumeType, operation) {
case 'delete-key': case 'delete-key':
// Press delete key. // Press delete key.
return gallery.callRemoteTestUtil( return gallery.callRemoteTestUtil(
'fakeKeyDown', appId, 'fakeKeyDown', appId, ['body', 'Delete', false, false, false]);
['body', 'Delete', 'U+007F' /* Delete */, false, false, false]);
break; break;
} }
}).then(function(result) { }).then(function(result) {
...@@ -198,8 +197,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) { ...@@ -198,8 +197,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) {
// Press Right key with shift. // Press Right key with shift.
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, '.thumbnail-view', 'ArrowRight', 'Right', false, appId, '.thumbnail-view', 'ArrowRight', false, true /* Shift */, false);
true /* Shift */, false);
}).then(function() { }).then(function() {
// Confirm 2 images are selected: [1][2] 3 // Confirm 2 images are selected: [1][2] 3
return gallery.callRemoteTestUtil('queryAllElements', appId, return gallery.callRemoteTestUtil('queryAllElements', appId,
...@@ -211,8 +209,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) { ...@@ -211,8 +209,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) {
// Press Right key with shift. // Press Right key with shift.
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, '.thumbnail-view', 'ArrowRight', 'Right', false, appId, '.thumbnail-view', 'ArrowRight', false, true /* Shift */, false);
true /* Shift */, false);
}).then(function() { }).then(function() {
// Confirm 3 images are selected: [1][2][3] // Confirm 3 images are selected: [1][2][3]
return gallery.callRemoteTestUtil('queryAllElements', appId, return gallery.callRemoteTestUtil('queryAllElements', appId,
...@@ -226,8 +223,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) { ...@@ -226,8 +223,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) {
// Press Left key with shift. // Press Left key with shift.
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, '.thumbnail-view', 'ArrowLeft', 'Left', false, appId, '.thumbnail-view', 'ArrowLeft', false, true /* Shift */, false);
true /* Shift */, false);
}).then(function() { }).then(function() {
// Confirm 2 images are selected: [1][2] 3 // Confirm 2 images are selected: [1][2] 3
return gallery.callRemoteTestUtil('queryAllElements', appId, return gallery.callRemoteTestUtil('queryAllElements', appId,
...@@ -239,8 +235,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) { ...@@ -239,8 +235,7 @@ function selectMultipleImagesWithShiftKey(testVolumeName, volumeType) {
// Press Right key without shift. // Press Right key without shift.
return gallery.fakeKeyDown( return gallery.fakeKeyDown(
appId, '.thumbnail-view', 'ArrowRight', 'Right', false, appId, '.thumbnail-view', 'ArrowRight', false, false, false);
false, false);
}).then(function() { }).then(function() {
// Confirm only the last image is selected: 1 2 [3] // Confirm only the last image is selected: 1 2 [3]
return gallery.callRemoteTestUtil('queryAllElements', appId, return gallery.callRemoteTestUtil('queryAllElements', appId,
...@@ -285,8 +280,7 @@ function selectAllImagesAfterImageDeletionOnDownloads( ...@@ -285,8 +280,7 @@ function selectAllImagesAfterImageDeletionOnDownloads(
}).then(function() { }).then(function() {
// Press Ctrl+A to select all images. // Press Ctrl+A to select all images.
return gallery.fakeKeyDown(appId, '.thumbnail-view', return gallery.fakeKeyDown(appId, '.thumbnail-view',
'a', 'U+0041' /* A */, true /* Ctrl*/, false /* Shift */, 'a', true /* Ctrl*/, false /* Shift */, false /* Alt */);
false /* Alt */);
}).then(function() { }).then(function() {
// Confirm that 2 images are selected. // Confirm that 2 images are selected.
return gallery.callRemoteTestUtil('queryAllElements', appId, return gallery.callRemoteTestUtil('queryAllElements', appId,
......
...@@ -259,7 +259,6 @@ RemoteCall.prototype.waitForElementLost = function(windowId, query) { ...@@ -259,7 +259,6 @@ RemoteCall.prototype.waitForElementLost = function(windowId, query) {
* @param {string} windowId Window ID. * @param {string} windowId Window ID.
* @param {string} query Query for the target element. * @param {string} query Query for the target element.
* @param {string} key DOM UI Events Key value. * @param {string} key DOM UI Events Key value.
* @param {string} keyIdentifer Key identifier.
* @param {boolean} ctrlKey Control key flag. * @param {boolean} ctrlKey Control key flag.
* @param {boolean} shiftKey Shift key flag. * @param {boolean} shiftKey Shift key flag.
* @param {boolean} altKey Alt key flag. * @param {boolean} altKey Alt key flag.
...@@ -267,10 +266,9 @@ RemoteCall.prototype.waitForElementLost = function(windowId, query) { ...@@ -267,10 +266,9 @@ RemoteCall.prototype.waitForElementLost = function(windowId, query) {
* result. * result.
*/ */
RemoteCall.prototype.fakeKeyDown = RemoteCall.prototype.fakeKeyDown =
function(windowId, query, key, keyIdentifer, ctrlKey, shiftKey, altKey) { function(windowId, query, key, ctrlKey, shiftKey, altKey) {
var resultPromise = this.callRemoteTestUtil( var resultPromise = this.callRemoteTestUtil(
'fakeKeyDown', windowId, 'fakeKeyDown', windowId, [query, key, ctrlKey, shiftKey, altKey]);
[query, key, keyIdentifer, ctrlKey, shiftKey, altKey]);
return resultPromise.then(function(result) { return resultPromise.then(function(result) {
if (result) if (result)
return true; return true;
...@@ -422,9 +420,8 @@ RemoteCallFilesApp.prototype.waitUntilTaskExecutes = function( ...@@ -422,9 +420,8 @@ RemoteCallFilesApp.prototype.waitUntilTaskExecutes = function(
*/ */
RemoteCallFilesApp.prototype.checkNextTabFocus = RemoteCallFilesApp.prototype.checkNextTabFocus =
function(windowId, elementId) { function(windowId, elementId) {
return remoteCall.callRemoteTestUtil('fakeKeyDown', return remoteCall.callRemoteTestUtil(
windowId, 'fakeKeyDown', windowId, ['body', 'Tab', false, false, false]).then(
['body', 'Tab', 'U+0009', false]).then(
function(result) { function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
return remoteCall.callRemoteTestUtil('getActiveElement', return remoteCall.callRemoteTestUtil('getActiveElement',
......
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