1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * Extension ID of audio player.
12 var AUDIO_PLAYER_APP_ID = 'cjbfomnbifhcdnihkgipgfcihmgjfhbf';
14 var remoteCallAudioPlayer = new RemoteCall(AUDIO_PLAYER_APP_ID);
17 * Launches the audio player with the given entries.
19 * @param {string} testVolumeName Test volume name passed to the addEntries
20 * function. Either 'drive' or 'local'.
21 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
22 * @param {Array<TestEntryInfo>} entries Entries to be parepared and passed to
24 * @param {Array<TestEntryInfo>=} opt_selected Entries to be selected. Should
25 * be a sub-set of the entries argument.
26 * @return {Promise} Promise to be fulfilled with the audio player element.
28 function launch(testVolumeName, volumeType, entries, opt_selected) {
29 var entriesPromise = addEntries([testVolumeName], entries).then(function() {
30 var selectedEntries = opt_selected || entries;
31 var selectedEntryNames =
32 selectedEntries.map(function(entry) { return entry.nameText; });
33 return remoteCallAudioPlayer.getFilesUnderVolume(
34 volumeType, selectedEntryNames);
38 return entriesPromise.then(function(urls) {
39 return remoteCallAudioPlayer.callRemoteTestUtil(
40 'openAudioPlayer', null, [urls]);
41 }).then(function(windowId) {
43 return remoteCallAudioPlayer.waitForElement(appWindow, 'body');
46 remoteCallAudioPlayer.waitForElement(
47 appWindow, 'audio-player[playing]'),
49 }).then(function(args) {
50 return [appWindow, args[0]];
55 * Namespace for test cases.
59 // Ensure the test cases are loaded.
60 window.addEventListener('load', function() {
62 // Check for the guest mode.
64 chrome.test.sendMessage(
65 JSON.stringify({name: 'isInGuestMode'}), steps.shift());
67 // Obtain the test case name.
69 if (JSON.parse(result) != chrome.extension.inIncognitoContext)
71 chrome.test.sendMessage(
72 JSON.stringify({name: 'getRootPaths'}), steps.shift());
74 // Obtain the root entry paths.
76 var roots = JSON.parse(result);
77 RootPath.DOWNLOADS = roots.downloads;
78 RootPath.DRIVE = roots.drive;
79 chrome.test.sendMessage(
80 JSON.stringify({name: 'getTestName'}), steps.shift());
83 function(testCaseName) {
84 var targetTest = testcase[testCaseName];
86 chrome.test.fail(testCaseName + ' is not found.');
89 // Specify the name of test to the test system.
90 targetTest.generatedName = testCaseName;
91 chrome.test.runTests([function() {
92 return testPromiseAndApps(targetTest(), [remoteCallAudioPlayer]);