Commit 964d4e7d authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Modernize CreateNewFolder selectFirstListItem helper

Document all steps. Use ArrowDown key to select a file list item (Ctrl
is not needed) and check its fakeKeyDown return value. Also rename the
helper to selectFirstFileListItem, and use class and id selectors when
querying for file list row item selection.

Test: browser_tests --gtest_filter="CreateNewFolder/FilesApp*"
Bug: 876267
Change-Id: I230ca4a54069c79169eac7a44003d81cd57d3c64
Reviewed-on: https://chromium-review.googlesource.com/1183271
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584999}
parent 50d9f1fe
......@@ -14,32 +14,28 @@ var TREEITEM_DOWNLOADS = '#directory-tree [entry-label="Downloads"] ';
/**
* Selects the first item in the file list.
*
* @param {string} windowId The Files app windowId.
* @return {Promise} Promise to be fulfilled on success.
*/
function selectFirstListItem(windowId) {
function selectFirstFileListItem(windowId) {
return Promise.resolve().then(function() {
// Ensure no selected item.
return remoteCall.waitForElementLost(
windowId,
'div.detail-table > list > li[selected]');
}).then(function() {
// Push Down.
return remoteCall.callRemoteTestUtil(
'fakeKeyDown', windowId,
// Down
['#file-list', 'ArrowDown', 'Down', true, false, false]);
// Ensure no file list items are selected.
return remoteCall.waitForElementLost(windowId, ['#file-list [selected]']);
}).then(function() {
// Wait for selection.
return remoteCall.waitForElement(windowId,
'div.detail-table > list > li[selected]');
// Press DownArrow key to select an item.
const key = ['#file-list', 'ArrowDown', 'Down', false, false, false];
return remoteCall.callRemoteTestUtil('fakeKeyDown', windowId, key);
}).then(function(result) {
chrome.test.assertTrue(result);
// Await file list item selection.
return remoteCall.waitForElement(windowId, ['.table-row[selected]']);
}).then(function() {
// Ensure that only the first item is selected.
// Retrieve all selected items in the file list.
return remoteCall.callRemoteTestUtil(
'queryAllElements',
windowId,
['div.detail-table > list > li[selected]']);
'queryAllElements', windowId, ['#file-list [selected]']);
}).then(function(elements) {
// Check: the first list item only should be selected.
chrome.test.assertEq(1, elements.length);
chrome.test.assertEq('listitem-1', elements[0].attributes['id']);
});
......@@ -174,7 +170,7 @@ testcase.selectCreateFolderDownloads = function() {
windowId = results.windowId;
return expandRoot(windowId, TREEITEM_DOWNLOADS);
}).then(function() {
return selectFirstListItem(windowId);
return selectFirstFileListItem(windowId);
}).then(function() {
return createNewFolder(windowId, '', BASIC_LOCAL_ENTRY_SET, 'Downloads');
});
......
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