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 * Extension ID of Files.app.
12 var VIDEO_PLAYER_APP_ID = 'jcgeabjmjgoblfofpppfkcoakmfobdko';
14 var remoteCallVideoPlayer = new RemoteCall(VIDEO_PLAYER_APP_ID);
17 * Launches the video 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 video 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 remoteCallVideoPlayer.getFilesUnderVolume(
34 volumeType, selectedEntryNames);
38 return entriesPromise.then(function(urls) {
39 return remoteCallVideoPlayer.callRemoteTestUtil(
40 'openVideoPlayer', null, [urls]);
41 }).then(function(windowId) {
43 return remoteCallVideoPlayer.waitForElement(appWindow, 'body');
46 remoteCallVideoPlayer.waitForElement(
47 appWindow, '#video-player[first-video][last-video]'),
48 remoteCallVideoPlayer.waitForElement(
49 appWindow, '.play.media-button[state="playing"]'),
51 }).then(function(args) {
52 return [appWindow, args[0]];
57 * Opens video player with a single video.
58 * @param {string} volumeName Test volume name passed to the addEntries
59 * function. Either 'drive' or 'local'.
60 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
61 * @param {TestEntryInfo} entry File to be opened.
62 * @return {Promise} Promise to be fulfilled with the video player element.
64 function openSingleVideo(volumeName, volumeType, entry) {
65 var entries = [entry];
66 return launch(volumeName, volumeType, entries).then(function(args) {
67 var videoPlayer = args[1];
69 chrome.test.assertTrue('first-video' in videoPlayer.attributes);
70 chrome.test.assertTrue('last-video' in videoPlayer.attributes);
71 chrome.test.assertFalse('multiple' in videoPlayer.attributes);
72 chrome.test.assertFalse('disabled' in videoPlayer.attributes);
78 * Namespace for test cases.
82 // Ensure the test cases are loaded.
83 window.addEventListener('load', function() {
85 // Check for the guest mode.
87 chrome.test.sendMessage(
88 JSON.stringify({name: 'isInGuestMode'}), steps.shift());
90 // Obtain the test case name.
92 if (JSON.parse(result) != chrome.extension.inIncognitoContext)
94 chrome.test.sendMessage(
95 JSON.stringify({name: 'getRootPaths'}), steps.shift());
97 // Obtain the root entry paths.
99 var roots = JSON.parse(result);
100 RootPath.DOWNLOADS = roots.downloads;
101 RootPath.DRIVE = roots.drive;
102 chrome.test.sendMessage(
103 JSON.stringify({name: 'getTestName'}), steps.shift());
105 // Run the test case.
106 function(testCaseName) {
107 var targetTest = testcase[testCaseName];
109 chrome.test.fail(testCaseName + ' is not found.');
112 // Specify the name of test to the test system.
113 targetTest.generatedName = testCaseName;
114 chrome.test.runTests([function() {
115 return testPromiseAndApps(targetTest(), [remoteCallVideoPlayer]);