Commit 3583dc21 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Write keyboardCopy test in terms of promises

Most tests herein are promise-based. Having a few tests in StepsRunner
is not great. Let promises win in this file.

Bug: 877557
Change-Id: Ia063d4218e4e1c27957beac2fa3f850532eb4f64
Reviewed-on: https://chromium-review.googlesource.com/1189586Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586223}
parent c02e02c4
...@@ -84,30 +84,21 @@ function waitForDirectoryTreeItemLost(appId, name) { ...@@ -84,30 +84,21 @@ function waitForDirectoryTreeItemLost(appId, name) {
function keyboardCopy(path) { function keyboardCopy(path) {
let appId; let appId;
StepsRunner.run([ return new Promise(function(resolve) {
// Open Files app on |path| containing one file entry: world.
function() {
setupAndWaitUntilReady( setupAndWaitUntilReady(
null, path, this.next, [ENTRIES.world], [ENTRIES.world]); null, path, resolve, [ENTRIES.world], [ENTRIES.world]);
}, }).then(function(results) {
// Copy the file into the same file list.
function(results) {
appId = results.windowId; appId = results.windowId;
remoteCall.callRemoteTestUtil( // Copy the file into the same file list.
'copyFile', appId, ['world.ogv'], this.next); return remoteCall.callRemoteTestUtil('copyFile', appId, ['world.ogv']);
}, }).then(function(result) {
// Check: the copied file should appear in the file list.
function(result) {
chrome.test.assertTrue(result, 'copyFile failed'); chrome.test.assertTrue(result, 'copyFile failed');
const files = [['world.ogv', '59 KB', 'OGG video']].concat( // Check: the copied file should appear in the file list.
const expectedEntryRows = [ENTRIES.world.getExpectedRow()].concat(
[['world (1).ogv', '59 KB', 'OGG video']]); [['world (1).ogv', '59 KB', 'OGG video']]);
remoteCall.waitForFiles( return remoteCall.waitForFiles(
appId, files, {ignoreLastModifiedTime: true}).then(this.next); appId, expectedEntryRows, {ignoreLastModifiedTime: true});
}, });
function() {
checkIfNoErrorsOccured(this.next);
}
]);
} }
/** /**
...@@ -319,11 +310,11 @@ function testRenameFile(path) { ...@@ -319,11 +310,11 @@ function testRenameFile(path) {
} }
testcase.keyboardCopyDownloads = function() { testcase.keyboardCopyDownloads = function() {
keyboardCopy(RootPath.DOWNLOADS); testPromise(keyboardCopy(RootPath.DOWNLOADS));
}; };
testcase.keyboardCopyDrive = function() { testcase.keyboardCopyDrive = function() {
keyboardCopy(RootPath.DRIVE); testPromise(keyboardCopy(RootPath.DRIVE));
}; };
testcase.keyboardDeleteDownloads = function() { testcase.keyboardDeleteDownloads = function() {
......
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