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.
}, await remoteCall.callRemoteTestUtil(
// Click the 'Name' column header and check the list. 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
function(results) { await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
appId = results.windowId; await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
remoteCall.callRemoteTestUtil('fakeMouseClick',
appId, // Click the 'Name' again and check the list.
['.table-header-cell:nth-of-type(1)'], await remoteCall.callRemoteTestUtil(
this.next); 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
}, await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
function() { await remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true});
remoteCall.waitForElement(appId, '.table-header-sort-image-asc').
then(this.next); // Click the 'Size' column header and check the list.
}, await remoteCall.callRemoteTestUtil(
function() { 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(2)']);
remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true}). await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
then(this.next); await remoteCall.waitForFiles(appId, SIZE_DESC, {orderCheck: true});
},
// Click the 'Name' again and check the list. // '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]');
['.table-header-cell:nth-of-type(1)'],
this.next); // Click the 'Size' column header again and check the list.
}, await remoteCall.callRemoteTestUtil(
function() { 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(2)']);
remoteCall.waitForElement(appId, '.table-header-sort-image-desc'). await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
then(this.next); await remoteCall.waitForFiles(appId, SIZE_ASC, {orderCheck: true});
},
function() { // 'Size' should still be checked in the sort menu, even when the sort order
remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true}). // is reversed.
then(this.next); await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#sort-button']);
// Click the 'Size' column header and check the list. await remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]');
function() {
remoteCall.callRemoteTestUtil('fakeMouseClick', // Click the 'Type' column header and check the list.
appId, await remoteCall.callRemoteTestUtil(
['.table-header-cell:nth-of-type(2)'], 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(4)']);
this.next); await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
}, await remoteCall.waitForFiles(appId, TYPE_ASC, {orderCheck: true});
function() {
remoteCall.waitForElement(appId, '.table-header-sort-image-desc'). // Click the 'Type' column header again and check the list.
then(this.next); await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(4)']);
function() { await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
remoteCall.waitForFiles(appId, SIZE_DESC, {orderCheck: true}). await remoteCall.waitForFiles(appId, TYPE_DESC, {orderCheck: true});
then(this.next);
}, // 'Type' should still be checked in the sort menu, even when the sort order
// 'Size' should be checked in the sort menu. // 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); // Click the 'Date modified' column header and check the list.
}, await remoteCall.callRemoteTestUtil(
function() { 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(5)']);
remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]'). await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
then(this.next); await remoteCall.waitForFiles(appId, DATE_DESC, {orderCheck: true});
},
// Click the 'Size' 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(2)'], await remoteCall.waitForFiles(appId, DATE_ASC, {orderCheck: true});
this.next);
}, // 'Date modified' should still be checked in the sort menu.
function() { await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, '.table-header-sort-image-asc'). 'fakeMouseClick', appId, ['#sort-button']);
then(this.next); await remoteCall.waitForElement(appId, '#sort-menu-sort-by-date[checked]');
},
function() { // Click 'Name' in the sort menu and check the result.
remoteCall.waitForFiles(appId, SIZE_ASC, {orderCheck: true}). await remoteCall.callRemoteTestUtil(
then(this.next); 'fakeMouseClick', appId, ['#sort-menu-sort-by-name']);
}, await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
// 'Size' should still be checked in the sort menu, even when the sort order await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
// is reversed.
function() { // Click the 'Name' again to reverse the order (to descending order).
remoteCall.callRemoteTestUtil('fakeMouseClick', await remoteCall.callRemoteTestUtil(
appId, 'fakeMouseClick', appId, ['.table-header-cell:nth-of-type(1)']);
['#sort-button'], await remoteCall.waitForElement(appId, '.table-header-sort-image-desc');
this.next); await remoteCall.waitForFiles(appId, NAME_DESC, {orderCheck: true});
},
function() { // Click 'Name' in the sort menu again should get the order back to
remoteCall.waitForElement(appId, '#sort-menu-sort-by-size[checked]'). // ascending order.
then(this.next); await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#sort-menu-sort-by-name']);
// Click the 'Type' column header and check the list. await remoteCall.waitForElement(appId, '.table-header-sort-image-asc');
function() { await remoteCall.waitForFiles(appId, NAME_ASC, {orderCheck: true});
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);
}
]);
}; };
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