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 @@ ...@@ -14,42 +14,32 @@
* @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);
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']);
});
// Compare the grid labels of the entries. // Open Files app on |rootPath|.
return clickedPromise.then(function() { const {appId} = await setupAndWaitUntilReady(null, rootPath);
return repeatUntil(function() {
var labelsPromise = remoteCall.callRemoteTestUtil( // Click the grid view button.
'queryAllElements', await remoteCall.waitForElement(appId, '#view-button');
windowId, await remoteCall.callRemoteTestUtil(
['grid:not([hidden]) .thumbnail-item .entry-name']); 'fakeEvent', appId, ['#view-button', 'click']);
return labelsPromise.then(function(labels) {
var actualLabels = labels.map(function(label) { // Compare the grid labels of the entries.
return label.text; await repeatUntil(async () => {
}).sort(); const labels = await remoteCall.callRemoteTestUtil(
if (chrome.test.checkDeepEq(expectedLabels, actualLabels)) 'queryAllElements', appId,
return true; ['grid:not([hidden]) .thumbnail-item .entry-name']);
return pending( const actualLabels = labels.map((label) => label.text).sort();
caller,
'Failed to compare the grid lables, expected: %j, actual %j.', if (chrome.test.checkDeepEq(expectedLabels, actualLabels)) {
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) { ...@@ -57,14 +47,12 @@ function showGridView(rootPath, expectedSet) {
* 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