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

Convert recents.js to use async-await.

Bug: 909056
Change-Id: Ic44a7ba350b852fcdd0a2983125c7239dc8d7a1a
Reviewed-on: https://chromium-review.googlesource.com/c/1351328Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612453}
parent d4d88901
// Copyright 2018 The Chromium Authors. All rights reserved. // Copyright 2018 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';
function generateVerifyRecentsSteps(expectedRecents = RECENT_ENTRY_SET) { async function verifyRecents(appId, expectedRecents = RECENT_ENTRY_SET) {
let appId;
return [
// Navigate to Recents. // Navigate to Recents.
function(results) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
appId = results.windowId; 'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']']));
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']'],
this.next);
},
// Verify Recents contains the expected files - those with an mtime in the // Verify Recents contains the expected files - those with an mtime in the
// future. // future.
function(result) {
chrome.test.assertTrue(result);
const files = TestEntryInfo.getExpectedRows(expectedRecents); const files = TestEntryInfo.getExpectedRows(expectedRecents);
remoteCall.waitForFiles(appId, files).then(this.next); await remoteCall.waitForFiles(appId, files);
},
function() {
checkIfNoErrorsOccured(this.next);
}
];
} }
testcase.recentsDownloads = function() { testcase.recentsDownloads = async function() {
StepsRunner.run([
// Populate downloads. // Populate downloads.
function() { const {appId} = await setupAndWaitUntilReady(
setupAndWaitUntilReady( null, RootPath.DOWNLOADS, null, BASIC_LOCAL_ENTRY_SET, []);
null, RootPath.DOWNLOADS, this.next, BASIC_LOCAL_ENTRY_SET, []); await verifyRecents(appId);
},
].concat(generateVerifyRecentsSteps()));
}; };
testcase.recentsDrive = function() { testcase.recentsDrive = async function() {
StepsRunner.run([
// Populate drive. // Populate drive.
function() { const {appId} = await setupAndWaitUntilReady(
setupAndWaitUntilReady( null, RootPath.DRIVE, null, [], BASIC_DRIVE_ENTRY_SET);
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET); await verifyRecents(appId);
},
].concat(generateVerifyRecentsSteps()));
}; };
testcase.recentsDownloadsAndDrive = function() { testcase.recentsDownloadsAndDrive = async function() {
StepsRunner.run([
// Populate both downloads and drive with disjoint sets of files. // Populate both downloads and drive with disjoint sets of files.
function() { const {appId} = await setupAndWaitUntilReady(
setupAndWaitUntilReady( null, RootPath.DOWNLOADS, null,
null, RootPath.DOWNLOADS, this.next,
[ENTRIES.beautiful, ENTRIES.hello, ENTRIES.photos], [ENTRIES.beautiful, ENTRIES.hello, ENTRIES.photos],
[ENTRIES.desktop, ENTRIES.world, ENTRIES.testDocument]); [ENTRIES.desktop, ENTRIES.world, ENTRIES.testDocument]);
}, await verifyRecents(appId);
].concat(generateVerifyRecentsSteps()));
}; };
testcase.recentsDownloadsAndDriveWithOverlap = function() { testcase.recentsDownloadsAndDriveWithOverlap = async function() {
StepsRunner.run([
// Populate both downloads and drive with overlapping sets of files. // Populate both downloads and drive with overlapping sets of files.
function() { const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null);
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); await verifyRecents(appId, RECENT_ENTRY_SET.concat(RECENT_ENTRY_SET));
},
].concat(generateVerifyRecentsSteps(RECENT_ENTRY_SET
.concat(RECENT_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