Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / ui / file_manager / video_player / js / test_util.js
blob787d74fadaa2c7d844f19dffa0f16a72e438d011
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.
5 /**
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;
15 if (contentWindow &&
16 contentWindow.document.title === filename) {
17 var element = contentWindow.document.querySelector('video[src]');
18 if (element && !element.paused)
19 return true;
22 return false;
25 /**
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');
32 script.src =
33 'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' +
34 'cast_extension_mock/load.js';
35 contentWindow.document.body.appendChild(script);
38 /**
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 {function(string)} callback Completion callback with the new window's
43 * App ID.
45 test.util.async.openVideoPlayer = function(urls, callback) {
46 openVideoPlayerWindow(urls).then(callback);
49 // Register the test utils.
50 test.util.registerRemoteTestUtils();