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.
8 * Launches the video player with the given entries.
10 * @param {string} testVolumeName Test volume name passed to the addEntries
11 * function. Either 'drive' or 'local'.
12 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
13 * @param {Array.<TestEntryInfo>} entries Entries to be parepared and passed to
15 * @param {Array.<TestEntryInfo>=} opt_selected Entries to be selected. Should
16 * be a sub-set of the entries argument.
17 * @return {Promise} Promise to be fulfilled with the video player element.
19 function launch(testVolumeName, volumeType, entries, opt_selected) {
20 var entriesPromise = addEntries([testVolumeName], entries).then(function() {
21 var selectedEntries = opt_selected || entries;
22 return getFilesUnderVolume(
24 selectedEntries.map(function(entry) { return entry.nameText; }));
28 return entriesPromise.then(function(entries) {
29 return open(entries.map(function(entry) {
30 return {entry: entry, title: entry.name, url: entry.toURL()};
32 appWindow = appWindowsForTest[entries[0].name];
35 return waitForElement(appWindow, 'body').then(function() {
36 var script = document.createElement('script');
38 'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' +
39 'video_player/test_helper_on_ui_page.js';
40 appWindow.contentWindow.document.body.appendChild(script);
44 waitForElement(appWindow, '#video-player[first-video][last-video]'),
45 waitForElement(appWindow, '.play.media-button[state="playing"]'),
46 ]).then(function(args) {
47 return [appWindow, args[0]];
53 * Loads the mock cast extension to the content page.
54 * @param {AppWindow} appWindow The target video player window.
56 function loadMockCastExtesntion(appWindow) {
57 var script = document.createElement('script');
59 'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' +
60 'cast_extension_mock/load.js';
61 appWindow.contentWindow.document.body.appendChild(script);