Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: chrome/test/data/extensions/api_test/file_manager_browsertest/open_video_files.js

Issue 209853011: [VideoPlayer] Browser tests for new separated video player app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+};

Powered by Google App Engine
This is Rietveld 408576698