Commit b96acff5 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Remove redundant sort() calls.

Also replace some waitForFileListChange + explicit files list assert
with waitForFiles. This simplifies some tests.

BUG=864844

Change-Id: If859f073e25b122dcd3e9eaf536871e5c31b60f2
Reviewed-on: https://chromium-review.googlesource.com/c/1341431Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609167}
parent 27650b11
......@@ -97,17 +97,14 @@ testcase.driveOpenSidebarOffline = function() {
remoteCall.callRemoteTestUtil(
'selectVolume', appId, ['drive_offline'], this.next);
},
// Wait until the file list is updated.
// Check: the file list should display the offline file set.
function(result) {
chrome.test.assertFalse(!result);
remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length).
then(this.next);
remoteCall
.waitForFiles(appId, TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET))
.then(this.next);
},
// Verify the file list.
function(actualFilesAfter) {
chrome.test.assertEq(
TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET).sort(),
actualFilesAfter);
function() {
checkIfNoErrorsOccured(this.next);
}
]);
......@@ -201,39 +198,33 @@ testcase.driveClickFirstSearchResult = function() {
var appId;
var steps = getStepsForSearchResultsAutoComplete();
steps.push(
function(id) {
appId = id;
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#autocomplete-list', 'ArrowDown', false, false, false],
this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(
appId,
['#autocomplete-list li[selected]']).
then(this.next);
},
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseDown', appId,
['#autocomplete-list li[selected]'],
this.next);
},
function(result)
{
remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length).
then(this.next);
},
function(actualFilesAfter)
{
chrome.test.assertEq(
TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET).sort(),
actualFilesAfter);
checkIfNoErrorsOccured(this.next);
}
);
function(id) {
appId = id;
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#autocomplete-list', 'ArrowDown', false, false, false],
this.next);
},
function(result) {
chrome.test.assertTrue(!!result);
remoteCall.waitForElement(appId, ['#autocomplete-list li[selected]'])
.then(this.next);
},
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseDown', appId, ['#autocomplete-list li[selected]'],
this.next);
},
function(result) {
chrome.test.assertTrue(!!result);
remoteCall
.waitForFiles(
appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET))
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
});
StepsRunner.run(steps);
};
......@@ -252,18 +243,19 @@ testcase.drivePressEnterToSearch = function() {
'fakeEvent', appId, ['#search-box cr-input', 'focus'], this.next);
},
function(result) {
chrome.test.assertTrue(!!result);
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#search-box cr-input', 'Enter', false, false, false], this.next);
},
function(result) {
remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length)
chrome.test.assertTrue(!!result);
remoteCall
.waitForFiles(
appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET))
.then(this.next);
},
function(actualFilesAfter) {
chrome.test.assertEq(
TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET).sort(),
actualFilesAfter);
function() {
checkIfNoErrorsOccured(this.next);
});
......
......@@ -21,7 +21,7 @@ function fileDisplay(path, defaultEntries) {
function() {
setupAndWaitUntilReady(null, path, this.next);
},
// Verify the default file list.
// Verify the default file list is present in |result|.
function(result) {
appId = result.windowId;
chrome.test.assertEq(defaultList, result.fileList);
......@@ -31,17 +31,11 @@ function fileDisplay(path, defaultEntries) {
function() {
addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
},
// Wait for the new file entries.
// Verify the newly added entries appear in the file list.
function() {
remoteCall.waitForFileListChange(appId, defaultList.length)
.then(this.next);
},
// Verify the new file list.
function(fileList) {
const expectedList =
defaultList.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort();
chrome.test.assertEq(expectedList, fileList);
this.next();
defaultList.concat([ENTRIES.newlyAdded.getExpectedRow()]);
remoteCall.waitForFiles(appId, expectedList).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
......@@ -313,14 +307,12 @@ function searchDownloads(searchTerm, expectedResults) {
'fakeEvent', appId, ['#search-box cr-input', 'input'], this.next);
},
function(result) {
remoteCall.waitForFileListChange(appId, BASIC_LOCAL_ENTRY_SET.length).
then(this.next);
chrome.test.assertTrue(!!result);
remoteCall
.waitForFiles(appId, TestEntryInfo.getExpectedRows(expectedResults))
.then(this.next);
},
function(actualFilesAfter) {
chrome.test.assertEq(
TestEntryInfo.getExpectedRows(expectedResults).sort(),
actualFilesAfter);
function() {
checkIfNoErrorsOccured(this.next);
}
]);
......
......@@ -109,42 +109,31 @@ function transferBetweenVolumes(transferInfo) {
let srcContents;
if (transferInfo.source.isTeamDrive) {
srcContents =
TestEntryInfo
.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === transferInfo.source.volumeName))
.sort();
TestEntryInfo.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === transferInfo.source.volumeName));
} else {
srcContents =
TestEntryInfo
.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''))
.sort();
TestEntryInfo.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''));
}
const myDriveContent =
TestEntryInfo
.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''))
.sort();
TestEntryInfo.getExpectedRows(transferInfo.source.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''));
let dstContents;
if (transferInfo.destination.isTeamDrive) {
dstContents =
TestEntryInfo
.getExpectedRows(transferInfo.destination.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName ===
transferInfo.destination.volumeName))
.sort();
dstContents = TestEntryInfo.getExpectedRows(
transferInfo.destination.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === transferInfo.destination.volumeName));
} else {
dstContents =
TestEntryInfo
.getExpectedRows(transferInfo.destination.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''))
.sort();
dstContents = TestEntryInfo.getExpectedRows(
transferInfo.destination.initialEntries.filter(
entry => entry.type !== EntryType.TEAM_DRIVE &&
entry.teamDriveName === ''));
}
const localFiles = BASIC_LOCAL_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