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,42 +14,32 @@
* @return {Promise} Promise to be fulfilled or rejected depending on the test
* result.
*/
function showGridView(rootPath, expectedSet) {
var caller = getCaller();
var expectedLabels = expectedSet.map(function(entryInfo) {
return entryInfo.nameText;
}).sort();
var setupPromise = setupAndWaitUntilReady(null, rootPath);
return setupPromise.then(function(results) {
var windowId = results.windowId;
// Click the grid view button.
var clickedPromise = remoteCall.waitForElement(windowId,
'#view-button').
then(function() {
return remoteCall.callRemoteTestUtil(
'fakeEvent', windowId, ['#view-button', 'click']);
});
async function showGridView(rootPath, expectedSet) {
const caller = getCaller();
const expectedLabels =
expectedSet.map((entryInfo) => entryInfo.nameText).sort();
// Compare the grid labels of the entries.
return clickedPromise.then(function() {
return repeatUntil(function() {
var labelsPromise = remoteCall.callRemoteTestUtil(
'queryAllElements',
windowId,
['grid:not([hidden]) .thumbnail-item .entry-name']);
return labelsPromise.then(function(labels) {
var actualLabels = labels.map(function(label) {
return label.text;
}).sort();
if (chrome.test.checkDeepEq(expectedLabels, actualLabels))
return true;
return pending(
caller,
'Failed to compare the grid lables, expected: %j, actual %j.',
expectedLabels, actualLabels);
});
});
});
// Open Files app on |rootPath|.
const {appId} = await setupAndWaitUntilReady(null, rootPath);
// Click the grid view button.
await remoteCall.waitForElement(appId, '#view-button');
await remoteCall.callRemoteTestUtil(
'fakeEvent', appId, ['#view-button', 'click']);
// Compare the grid labels of the entries.
await repeatUntil(async () => {
const labels = await remoteCall.callRemoteTestUtil(
'queryAllElements', appId,
['grid:not([hidden]) .thumbnail-item .entry-name']);
const actualLabels = labels.map((label) => label.text).sort();
if (chrome.test.checkDeepEq(expectedLabels, actualLabels)) {
return true;
}
return pending(
caller, 'Failed to compare the grid lables, expected: %j, actual %j.',
expectedLabels, actualLabels);
});
}
......@@ -57,14 +47,12 @@ function showGridView(rootPath, expectedSet) {
* Tests to show grid view on a local directory.
*/
testcase.showGridViewDownloads = function() {
testPromise(showGridView(
RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET));
return showGridView(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET);
};
/**
* Tests to show grid view on a drive directory.
*/
testcase.showGridViewDrive = function() {
testPromise(showGridView(
RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET));
return showGridView(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