1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* Extension ID of Files.app.
* @type {string}
* @const
*/
var VIDEO_PLAYER_APP_ID = 'jcgeabjmjgoblfofpppfkcoakmfobdko';
var remoteCallVideoPlayer = new RemoteCall(VIDEO_PLAYER_APP_ID);
/**
* Launches the video player with the given entries.
*
* @param {string} testVolumeName Test volume name passed to the addEntries
* function. Either 'drive' or 'local'.
* @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
* @param {Array<TestEntryInfo>} entries Entries to be parepared and passed to
* the application.
* @param {Array<TestEntryInfo>=} opt_selected Entries to be selected. Should
* be a sub-set of the entries argument.
* @return {Promise} Promise to be fulfilled with the video player element.
*/
function launch(testVolumeName, volumeType, entries, opt_selected) {
var entriesPromise = addEntries([testVolumeName], entries).then(function() {
var selectedEntries = opt_selected || entries;
var selectedEntryNames =
selectedEntries.map(function(entry) { return entry.nameText; });
return remoteCallVideoPlayer.getFilesUnderVolume(
volumeType, selectedEntryNames);
});
var appWindow = null;
return entriesPromise.then(function(urls) {
return remoteCallVideoPlayer.callRemoteTestUtil(
'openVideoPlayer', null, [urls, 0]);
}).then(function(windowId) {
appWindow = windowId;
return remoteCallVideoPlayer.waitForElement(appWindow, 'body');
}).then(function() {
return Promise.all([
remoteCallVideoPlayer.waitForElement(
appWindow, '#video-player[first-video][last-video]'),
remoteCallVideoPlayer.waitForElement(
appWindow, '.play.media-button[state="playing"]'),
]);
}).then(function(args) {
return [appWindow, args[0]];
});
}
/**
* Opens video player with a single video.
* @param {string} volumeName Test volume name passed to the addEntries
* function. Either 'drive' or 'local'.
* @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
* @param {TestEntryInfo} entry File to be opened.
* @return {Promise} Promise to be fulfilled with the video player element.
*/
function openSingleVideo(volumeName, volumeType, entry) {
var entries = [entry];
return launch(volumeName, volumeType, entries).then(function(args) {
var videoPlayer = args[1];
chrome.test.assertTrue('first-video' in videoPlayer.attributes);
chrome.test.assertTrue('last-video' in videoPlayer.attributes);
chrome.test.assertFalse('multiple' in videoPlayer.attributes);
chrome.test.assertFalse('disabled' in videoPlayer.attributes);
return args;
});
};
/**
* Namespace for test cases.
*/
var testcase = {};
// Ensure the test cases are loaded.
window.addEventListener('load', function() {
var steps = [
// Check for the guest mode.
function() {
chrome.test.sendMessage(
JSON.stringify({name: 'isInGuestMode'}), steps.shift());
},
// Obtain the test case name.
function(result) {
if (JSON.parse(result) != chrome.extension.inIncognitoContext)
return;
chrome.test.sendMessage(
JSON.stringify({name: 'getRootPaths'}), steps.shift());
},
// Obtain the root entry paths.
function(result) {
var roots = JSON.parse(result);
RootPath.DOWNLOADS = roots.downloads;
RootPath.DRIVE = roots.drive;
chrome.test.sendMessage(
JSON.stringify({name: 'getTestName'}), steps.shift());
},
// Run the test case.
function(testCaseName) {
var targetTest = testcase[testCaseName];
if (!targetTest) {
chrome.test.fail(testCaseName + ' is not found.');
return;
}
// Specify the name of test to the test system.
targetTest.generatedName = testCaseName;
chrome.test.runTests([function() {
return testPromiseAndApps(targetTest(), [remoteCallVideoPlayer]);
}]);
}
];
steps.shift()();
});
|