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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
function generateVerifyRecentsSteps(expectedRecents = RECENT_ENTRY_SET) {
let appId;
return [
// Navigate to Recents.
function(results) {
appId = results.windowId;
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']'],
this.next);
},
// Verify Recents contains the expected files - those with an mtime in the
// future.
function(result) {
chrome.test.assertTrue(result);
const files = TestEntryInfo.getExpectedRows(expectedRecents);
remoteCall.waitForFiles(appId, files).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
];
async function verifyRecents(appId, expectedRecents = RECENT_ENTRY_SET) {
// Navigate to Recents.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']']));
// Verify Recents contains the expected files - those with an mtime in the
// future.
const files = TestEntryInfo.getExpectedRows(expectedRecents);
await remoteCall.waitForFiles(appId, files);
}
testcase.recentsDownloads = function() {
StepsRunner.run([
// Populate downloads.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, BASIC_LOCAL_ENTRY_SET, []);
},
].concat(generateVerifyRecentsSteps()));
testcase.recentsDownloads = async function() {
// Populate downloads.
const {appId} = await setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, null, BASIC_LOCAL_ENTRY_SET, []);
await verifyRecents(appId);
};
testcase.recentsDrive = function() {
StepsRunner.run([
// Populate drive.
function() {
setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET);
},
].concat(generateVerifyRecentsSteps()));
testcase.recentsDrive = async function() {
// Populate drive.
const {appId} = await setupAndWaitUntilReady(
null, RootPath.DRIVE, null, [], BASIC_DRIVE_ENTRY_SET);
await verifyRecents(appId);
};
testcase.recentsDownloadsAndDrive = function() {
StepsRunner.run([
// Populate both downloads and drive with disjoint sets of files.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next,
[ENTRIES.beautiful, ENTRIES.hello, ENTRIES.photos],
[ENTRIES.desktop, ENTRIES.world, ENTRIES.testDocument]);
},
].concat(generateVerifyRecentsSteps()));
testcase.recentsDownloadsAndDrive = async function() {
// Populate both downloads and drive with disjoint sets of files.
const {appId} = await setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, null,
[ENTRIES.beautiful, ENTRIES.hello, ENTRIES.photos],
[ENTRIES.desktop, ENTRIES.world, ENTRIES.testDocument]);
await verifyRecents(appId);
};
testcase.recentsDownloadsAndDriveWithOverlap = function() {
StepsRunner.run([
// Populate both downloads and drive with overlapping sets of files.
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
].concat(generateVerifyRecentsSteps(RECENT_ENTRY_SET
.concat(RECENT_ENTRY_SET))));
testcase.recentsDownloadsAndDriveWithOverlap = async function() {
// Populate both downloads and drive with overlapping sets of files.
const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null);
await verifyRecents(appId, 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