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