Commit 298c4d34 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert grid_view.js to use async-await.

Bug: 909056
Change-Id: I70453c9a11b2d2cab1fa0355647b333508ba700c
Reviewed-on: https://chromium-review.googlesource.com/c/1351982
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612480}
parent d2cc7586
...@@ -14,57 +14,45 @@ ...@@ -14,57 +14,45 @@
* @return {Promise} Promise to be fulfilled or rejected depending on the test * @return {Promise} Promise to be fulfilled or rejected depending on the test
* result. * result.
*/ */
function showGridView(rootPath, expectedSet) { async function showGridView(rootPath, expectedSet) {
var caller = getCaller(); const caller = getCaller();
var expectedLabels = expectedSet.map(function(entryInfo) { const expectedLabels =
return entryInfo.nameText; expectedSet.map((entryInfo) => entryInfo.nameText).sort();
}).sort();
var setupPromise = setupAndWaitUntilReady(null, rootPath); // Open Files app on |rootPath|.
return setupPromise.then(function(results) { const {appId} = await setupAndWaitUntilReady(null, rootPath);
var windowId = results.windowId;
// Click the grid view button. // Click the grid view button.
var clickedPromise = remoteCall.waitForElement(windowId, await remoteCall.waitForElement(appId, '#view-button');
'#view-button'). await remoteCall.callRemoteTestUtil(
then(function() { 'fakeEvent', appId, ['#view-button', 'click']);
return remoteCall.callRemoteTestUtil(
'fakeEvent', windowId, ['#view-button', 'click']);
});
// Compare the grid labels of the entries. // Compare the grid labels of the entries.
return clickedPromise.then(function() { await repeatUntil(async () => {
return repeatUntil(function() { const labels = await remoteCall.callRemoteTestUtil(
var labelsPromise = remoteCall.callRemoteTestUtil( 'queryAllElements', appId,
'queryAllElements',
windowId,
['grid:not([hidden]) .thumbnail-item .entry-name']); ['grid:not([hidden]) .thumbnail-item .entry-name']);
return labelsPromise.then(function(labels) { const actualLabels = labels.map((label) => label.text).sort();
var actualLabels = labels.map(function(label) {
return label.text; if (chrome.test.checkDeepEq(expectedLabels, actualLabels)) {
}).sort();
if (chrome.test.checkDeepEq(expectedLabels, actualLabels))
return true; return true;
}
return pending( return pending(
caller, caller, 'Failed to compare the grid lables, expected: %j, actual %j.',
'Failed to compare the grid lables, expected: %j, actual %j.',
expectedLabels, actualLabels); expectedLabels, actualLabels);
}); });
});
});
});
} }
/** /**
* Tests to show grid view on a local directory. * Tests to show grid view on a local directory.
*/ */
testcase.showGridViewDownloads = function() { testcase.showGridViewDownloads = function() {
testPromise(showGridView( return showGridView(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET);
RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET));
}; };
/** /**
* Tests to show grid view on a drive directory. * Tests to show grid view on a drive directory.
*/ */
testcase.showGridViewDrive = function() { testcase.showGridViewDrive = function() {
testPromise(showGridView( return showGridView(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET);
RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET));
}; };
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