Commit d7b0fb62 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Even more OpenAudioFiles FilesAppBrowserTest speed

Shave about 500ms off per test by only loading the file(s) the tests
require. Remove getExpectedFileEntryRows helper as a side-effect: it
is now unused so git-mv it to /dev/null.

Bug: 859008
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Id49678e63d2160cbf7ce4daee45d36edaa124b97
Reviewed-on: https://chromium-review.googlesource.com/1125639Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572506}
parent 7e830210
...@@ -6,21 +6,6 @@ ...@@ -6,21 +6,6 @@
(function() { (function() {
/**
* Returns an array of file entry row content, where the rows are the basic
* file entry set for the given path, plus the given file |entries|.
*
* @param {string} path Directory path (Downloads or Drive).
* @pram {Array<!TestEntryInfo>} entries Array of file TestEntryInfo.
* @return {Array} File entry row content.
*/
function getExpectedFileEntryRows(path, entries) {
const basicFileEntrySetForPath =
(path == RootPath.DRIVE) ? BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET;
return TestEntryInfo.getExpectedRows(basicFileEntrySetForPath)
.concat(TestEntryInfo.getExpectedRows(entries));
}
/** /**
* Returns the title and artist text associated with the given audio track. * Returns the title and artist text associated with the given audio track.
* *
...@@ -135,7 +120,7 @@ function audioOpenTrackDownloads() { ...@@ -135,7 +120,7 @@ function audioOpenTrackDownloads() {
const track = [ENTRIES.beautiful]; const track = [ENTRIES.beautiful];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on Downloads, add an audio track to Downloads. // Open Files.App on Downloads, add an audio file to Downloads.
function() { function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next, track, []); setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next, track, []);
}, },
...@@ -184,7 +169,7 @@ function audioOpenMultipleTracksDrive() { ...@@ -184,7 +169,7 @@ function audioOpenMultipleTracksDrive() {
const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded]; const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on Drive, add the audio tracks to Drive. // Open Files.App on Drive, add the audio files to Drive.
function() { function() {
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next, [], tracks); setupAndWaitUntilReady(null, RootPath.DRIVE, this.next, [], tracks);
}, },
...@@ -255,7 +240,8 @@ function audioOpenMultipleTracksDrive() { ...@@ -255,7 +240,8 @@ function audioOpenMultipleTracksDrive() {
} }
/** /**
* Tests if the audio player play the next file after the current file. * Tests that the audio player auto-advances viz., auto-plays the next audio
* track when the current track ends.
* *
* @param {string} path Directory path to be tested. * @param {string} path Directory path to be tested.
*/ */
...@@ -263,24 +249,16 @@ function audioAutoAdvance(path) { ...@@ -263,24 +249,16 @@ function audioAutoAdvance(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add audio files to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, tracks, tracks);
}, },
// Add an additional audio file. // Open an audio file.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
},
// Wait for the file list to change.
function(result) {
chrome.test.assertTrue(result);
const expected = getExpectedFileEntryRows(path, [ENTRIES.newlyAdded]);
remoteCall.waitForFiles(appId, expected).then(this.next);
},
// Open an audio file.
function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'openFile', appId, ['Beautiful Song.ogg'], this.next); 'openFile', appId, ['Beautiful Song.ogg'], this.next);
}, },
...@@ -295,9 +273,13 @@ function audioAutoAdvance(path) { ...@@ -295,9 +273,13 @@ function audioAutoAdvance(path) {
const playFile = audioPlayingQuery('Beautiful Song.ogg'); const playFile = audioPlayingQuery('Beautiful Song.ogg');
audioPlayerApp.waitForElement(audioAppId, playFile).then(this.next); audioPlayerApp.waitForElement(audioAppId, playFile).then(this.next);
}, },
// Leap forward and check: the same file should still be playing. // Leap forward in time.
function() { function() {
audioTimeLeapForward(audioAppId); audioTimeLeapForward(audioAppId);
this.next();
},
// Check: the same file should still be playing.
function() {
const playFile = audioPlayingQuery('Beautiful Song.ogg'); const playFile = audioPlayingQuery('Beautiful Song.ogg');
audioPlayerApp.waitForElement(audioAppId, playFile).then(this.next); audioPlayerApp.waitForElement(audioAppId, playFile).then(this.next);
}, },
...@@ -321,10 +303,12 @@ function audioRepeatAllModeSingleFile(path) { ...@@ -321,10 +303,12 @@ function audioRepeatAllModeSingleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const track = [ENTRIES.beautiful];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add an audio file to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, track, track);
}, },
// Open an audio file. // Open an audio file.
function(results) { function(results) {
...@@ -382,10 +366,12 @@ function audioNoRepeatModeSingleFile(path) { ...@@ -382,10 +366,12 @@ function audioNoRepeatModeSingleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const track = [ENTRIES.beautiful];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add an audio file to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, track, track);
}, },
// Open an audio file. // Open an audio file.
function(results) { function(results) {
...@@ -435,10 +421,12 @@ function audioRepeatOneModeSingleFile(path) { ...@@ -435,10 +421,12 @@ function audioRepeatOneModeSingleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const track = [ENTRIES.beautiful];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add an audio file to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, track, track);
}, },
// Open an audio file. // Open an audio file.
function(results) { function(results) {
...@@ -503,24 +491,16 @@ function audioRepeatAllModeMultipleFile(path) { ...@@ -503,24 +491,16 @@ function audioRepeatAllModeMultipleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add audio files to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, tracks, tracks);
}, },
// Add an additional audio file. // Open an audio file.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
},
// Wait for the file list to change.
function(result) {
chrome.test.assertTrue(result);
const expected = getExpectedFileEntryRows(path, [ENTRIES.newlyAdded]);
remoteCall.waitForFiles(appId, expected).then(this.next);
},
// Open an audio file.
function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'openFile', appId, ['newly added file.ogg'], this.next); 'openFile', appId, ['newly added file.ogg'], this.next);
}, },
...@@ -583,24 +563,16 @@ function audioNoRepeatModeMultipleFile(path) { ...@@ -583,24 +563,16 @@ function audioNoRepeatModeMultipleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add audio files to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, tracks, tracks);
}, },
// Add an additional audio file. // Open an audio file.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
},
// Wait for the file list to change.
function(result) {
chrome.test.assertTrue(result);
const expected = getExpectedFileEntryRows(path, [ENTRIES.newlyAdded]);
remoteCall.waitForFiles(appId, expected).then(this.next);
},
// Open an audio file.
function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'openFile', appId, ['newly added file.ogg'], this.next); 'openFile', appId, ['newly added file.ogg'], this.next);
}, },
...@@ -646,23 +618,16 @@ function audioRepeatOneModeMultipleFile(path) { ...@@ -646,23 +618,16 @@ function audioRepeatOneModeMultipleFile(path) {
let appId; let appId;
let audioAppId; let audioAppId;
const tracks = [ENTRIES.beautiful, ENTRIES.newlyAdded];
StepsRunner.run([ StepsRunner.run([
// Open Files.App on the given (volume) path. // Open Files.App on |path|, add audio files to Downloads and Drive.
function() { function() {
setupAndWaitUntilReady(null, path, this.next); setupAndWaitUntilReady(null, path, this.next, tracks, tracks);
}, },
// Add an additional audio file. // Open an audio file.
function(results) { function(results) {
appId = results.windowId; appId = results.windowId;
addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
},
// Wait for the file list to change.
function(result) {
const expected = getExpectedFileEntryRows(path, [ENTRIES.newlyAdded]);
remoteCall.waitForFiles(appId, expected).then(this.next);
},
// Open an audio file.
function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'openFile', appId, ['newly added file.ogg'], this.next); 'openFile', appId, ['newly added file.ogg'], 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