Commit eaf6bdfe authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert sort_columns.js to use async-await.

Bug: 909056
Change-Id: Idafd58064585c900805629044cd192b2cfe2461a
Reviewed-on: https://chromium-review.googlesource.com/c/1354731Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612086}
parent 80223a4b
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* Tests the order is sorted correctly for each of the columns.
*/
testcase.sortColumns = function() {
var appId;
testcase.sortColumns = async function() {
var NAME_ASC = TestEntryInfo.getExpectedRows([
ENTRIES.photos,
ENTRIES.beautiful,
ENTRIES.hello,
ENTRIES.desktop,
ENTRIES.world
ENTRIES.world,
]);
var NAME_DESC = TestEntryInfo.getExpectedRows([
......@@ -23,7 +20,7 @@ testcase.sortColumns = function() {
ENTRIES.world,
ENTRIES.desktop,
ENTRIES.hello,
ENTRIES.beautiful
ENTRIES.beautiful,
]);
var SIZE_ASC = TestEntryInfo.getExpectedRows([
......@@ -31,7 +28,7 @@ testcase.sortColumns = function() {
ENTRIES.hello,
ENTRIES.desktop,
ENTRIES.beautiful,
ENTRIES.world
ENTRIES.world,
]);
var SIZE_DESC = TestEntryInfo.getExpectedRows([
......@@ -39,7 +36,7 @@ testcase.sortColumns = function() {
ENTRIES.world,
ENTRIES.beautiful,
ENTRIES.desktop,
ENTRIES.hello
ENTRIES.hello,
]);
var TYPE_ASC = TestEntryInfo.getExpectedRows([
......@@ -47,7 +44,7 @@ testcase.sortColumns = function() {
ENTRIES.beautiful,
ENTRIES.world,
ENTRIES.hello,
ENTRIES.desktop
ENTRIES.desktop,
]);
var TYPE_DESC = TestEntryInfo.getExpectedRows([
......@@ -55,7 +52,7 @@ testcase.sortColumns = function() {
ENTRIES.desktop,
ENTRIES.hello,
ENTRIES.world,
ENTRIES.beautiful
ENTRIES.beautiful,
]);
var DATE_ASC = TestEntryInfo.getExpectedRows([
......@@ -63,7 +60,7 @@ testcase.sortColumns = function() {
ENTRIES.hello,
ENTRIES.world,
ENTRIES.desktop,
ENTRIES.beautiful
ENTRIES.beautiful,
]);
var DATE_DESC = TestEntryInfo.getExpectedRows([
......@@ -71,228 +68,97 @@ testcase.sortColumns = function() {
ENTRIES.beautiful,
ENTRIES.desktop,
ENTRIES.world,
ENTRIES.hello
ENTRIES.hello,
]);
StepsRunner.run([
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
// Click the 'Name' column header and check the list.
function(results) {
appId = results.windowId;
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(1)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true}).
then(this.next);
},
// Click the 'Name' again and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(1)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true}).
then(this.next);
},
// Click the 'Size' column header and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(2)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, SIZE_DESC, {orderCheck: true}).
then(this.next);
},
// 'Size' should be checked in the sort menu.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-button'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]').
then(this.next);
},
// Click the 'Size' column header again and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(2)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, SIZE_ASC, {orderCheck: true}).
then(this.next);
},
// 'Size' should still be checked in the sort menu, even when the sort order
// is reversed.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-button'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]').
then(this.next);
},
// Click the 'Type' column header and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(4)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, TYPE_ASC, {orderCheck: true}).
then(this.next);
},
// Click the 'Type' column header again and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(4)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, TYPE_DESC, {orderCheck: true}).
then(this.next);
},
// 'Type' should still be checked in the sort menu, even when the sort order
// is reversed.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-button'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '#sort-menu-sort-by-type[checked]').
then(this.next);
},
// Click the 'Date modified' column header and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(5)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, DATE_DESC, {orderCheck: true}).
then(this.next);
},
// Click the 'Date modified' column header again and check the list.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(5)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, DATE_ASC, {orderCheck: true}).
then(this.next);
},
// 'Date modified' should still be checked in the sort menu.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-button'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '#sort-menu-sort-by-date[checked]').
then(this.next);
},
// Click 'Name' in the sort menu and check the result.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-menu-sort-by-name'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true}).
then(this.next);
},
// Click the 'Name' again to reverse the order (to descending order).
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['.table-header-cell:nth-of-type(1)'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true}).
then(this.next);
},
// Click 'Name' in the sort menu again should get the order back to
// ascending order.
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId,
['#sort-menu-sort-by-name'],
this.next);
},
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next);
},
function() {
remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true}).
then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null);
// Click the 'Name' column header and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
// Click the 'Name' again and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
await remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true});
// Click the 'Size' column header and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(2)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
await remoteCall.waitForFiles(appId, SIZE_DESC, {orderCheck: true});
// 'Size' should be checked in the sort menu.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-button']);
await remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]');
// Click the 'Size' column header again and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(2)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, SIZE_ASC, {orderCheck: true});
// 'Size' should still be checked in the sort menu, even when the sort order
// is reversed.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-button']);
await remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]');
// Click the 'Type' column header and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(4)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, TYPE_ASC, {orderCheck: true});
// Click the 'Type' column header again and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(4)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
await remoteCall.waitForFiles(appId, TYPE_DESC, {orderCheck: true});
// 'Type' should still be checked in the sort menu, even when the sort order
// is reversed.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-button']);
await remoteCall.waitForElement(appId, '#sort-menu-sort-by-type[checked]');
// Click the 'Date modified' column header and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(5)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
await remoteCall.waitForFiles(appId, DATE_DESC, {orderCheck: true});
// Click the 'Date modified' column header again and check the list.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(5)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, DATE_ASC, {orderCheck: true});
// 'Date modified' should still be checked in the sort menu.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-button']);
await remoteCall.waitForElement(appId, '#sort-menu-sort-by-date[checked]');
// Click 'Name' in the sort menu and check the result.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-menu-sort-by-name']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
// Click the 'Name' again to reverse the order (to descending order).
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
await remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true});
// Click 'Name' in the sort menu again should get the order back to
// ascending order.
await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#sort-menu-sort-by-name']);
await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
};
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