1 // Copyright 2014 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.
6 * Returns if the specified file is being played.
8 * @param {string} filename Name of audio file to be checked. This must be same
9 * as entry.name() of the audio file.
10 * @return {boolean} True if the video is playing, false otherwise.
12 test.util.sync.isPlaying = function(filename) {
13 for (var appId in window.background.appWindows) {
14 var contentWindow = window.background.appWindows[appId].contentWindow;
16 contentWindow.document.title === filename) {
17 var element = contentWindow.document.querySelector('video[src]');
18 if (element && !element.paused)
26 * Loads the mock of the cast extension.
28 * @param {Window} contentWindow Video player window to be chacked toOB.
30 test.util.sync.loadMockCastExtension = function(contentWindow) {
31 var script = contentWindow.document.createElement('script');
33 'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' +
34 'cast_extension_mock/load.js';
35 contentWindow.document.body.appendChild(script);
39 * Opens the main Files.app's window and waits until it is ready.
41 * @param {Array.<string>} urls URLs to be opened.
42 * @param {number} pos Indes in the |urls| to be played at first
43 * @param {function(string)} callback Completion callback with the new window's
46 test.util.async.openVideoPlayer = function(urls, pos, callback) {
47 openVideoPlayerWindow({items: urls, position: pos}, false).then(callback);
51 * Gets file entries just under the volume.
53 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
54 * @param {Array.<string>} names File name list.
55 * @param {function(*)} callback Callback function with results returned by the
58 test.util.async.getFilesUnderVolume = function(volumeType, names, callback) {
59 var displayRootPromise =
60 VolumeManager.getInstance().then(function(volumeManager) {
61 var volumeInfo = volumeManager.getCurrentProfileVolumeInfo(volumeType);
62 return volumeInfo.resolveDisplayRoot();
65 var retrievePromise = displayRootPromise.then(function(displayRoot) {
66 var filesPromise = names.map(function(name) {
68 displayRoot.getFile.bind(displayRoot, name, {}));
70 return Promise.all(filesPromise).then(function(aa) {
71 return util.entriesToURLs(aa);
75 retrievePromise.then(callback);
78 // Register the test utils.
79 test.util.registerRemoteTestUtils();