Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/file_manager_browsertest/open_video_files.js |
| diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/open_video_files.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/open_video_files.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..be8cf6cee22251056364b74db4c27c9a88ef968a |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/open_video_files.js |
| @@ -0,0 +1,96 @@ |
| +// 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 Video Player. |
| + * @type {string} |
| + * @const |
| + */ |
| +var VIDEO_PLAYER_EXTENSIONS_ID = 'jcgeabjmjgoblfofpppfkcoakmfobdko'; |
| + |
| +/** |
| + * Calls a remote test util in video player. See: test_util.js. |
| + * |
| + * @param {string} func Function name. |
| + * @param {?string} filename Target window's file name, |
| + * @param {Array.<*>} args Array of arguments. |
| + * @param {function(*)=} opt_callback Callback handling the function's result. |
| + * @return {Promise} Promise to be fulfilled with the result of the remote |
| + * utility. |
| + */ |
| +function callRemoteTestUtilInVideoPlayer(func, filename, args, opt_callback) { |
| + return new Promise(function(onFulfilled) { |
| + chrome.runtime.sendMessage( |
| + VIDEO_PLAYER_EXTENSIONS_ID, { |
| + func: func, |
| + file: filename, |
| + args: args |
| + }, |
| + function() { |
| + if (opt_callback) |
| + opt_callback.apply(null, arguments); |
| + onFulfilled(arguments[0]); |
| + }); |
| + }).catch(function(err) { |
| + return Promise.resolve(false); |
|
hirono
2014/03/25 08:02:19
Maybe logging the error helps us to find out why t
yoshiki
2014/03/25 10:07:27
Done.
|
| + }); |
| +} |
| + |
| +/** |
| + * Waits until a window having the given filename appears. |
| + * @param {string} filename Filename of the requested window. |
| + * @param {Promise} promise Promise to be fulfilled with a found window's ID. |
| + */ |
| +function waitForPlaying(filename) { |
| + return repeatUntil(function() { |
| + return callRemoteTestUtilInVideoPlayer('isPlaying', |
| + filename, |
| + []). |
| + then(function(result) { |
| + if (result) |
| + return true; |
| + return pending('Window with the prefix %s is not found.', filename); |
| + }); |
| + }); |
| +} |
| + |
| +/** |
| + * Tests if the video player shows up for the selected movie and that it is |
| + * loaded successfully. |
| + * |
| + * @param {string} path Directory path to be tested. |
| + */ |
| +function videoOpen(path) { |
| + var appId; |
| + StepsRunner.run([ |
| + function() { |
| + setupAndWaitUntilReady(null, path, this.next); |
| + }, |
| + function(inAppId) { |
| + appId = inAppId; |
| + // Select the song. |
| + callRemoteTestUtil( |
| + 'openFile', appId, ['world.ogv'], this.next); |
| + }, |
| + function(result) { |
| + chrome.test.assertTrue(result); |
| + // Wait for the video player. |
| + waitForPlaying('world.ogv').then(this.next); |
| + }, |
| + function(result) { |
| + chrome.test.assertTrue(result); |
| + checkIfNoErrorsOccured(this.next); |
|
hirono
2014/03/25 08:02:19
Could you also add a error check for the video pla
yoshiki
2014/03/25 10:07:27
Done.
|
| + } |
| + ]); |
| +} |
| + |
| +testcase.videoOpenDrive = function() { |
| + videoOpen(RootPath.DRIVE); |
| +}; |
| + |
| +testcase.videoOpenDownloads = function() { |
| + videoOpen(RootPath.DOWNLOADS); |
| +}; |