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

Side by Side Diff: ui/file_manager/video_player/js/background.js

Issue 485013003: Video Player: Add a test to open a single video file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 // Stores the app windows OLNY for test purpose. 7 // Stores the app windows OLNY for test purpose.
8 // We SHOULD NOT use it as it is except for test, since the files which have 8 // We SHOULD NOT use it as it is except for test, since the files which have
9 // the same name will be overridden each other. 9 // the same name will be overridden each other.
10 var appWindowsForTest = {}; 10 var appWindowsForTest = {};
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } else { 60 } else {
61 // TODO(yoshiki): handle error in a smarter way. 61 // TODO(yoshiki): handle error in a smarter way.
62 open('', 'error'); // Empty URL shows the error message. 62 open('', 'error'); // Empty URL shows the error message.
63 } 63 }
64 fulfill(); 64 fulfill();
65 }.wrap()); 65 }.wrap());
66 } 66 }
67 67
68 /** 68 /**
69 * Opens player window. 69 * Opens player window.
70 * @param {Array.<Object>} videos List of videos to play. 70 * @param {Array.<Object>} videos List of videos to play.
hirono 2014/08/20 04:14:06 nit: @return
yoshiki 2014/08/20 04:26:21 Done.
71 */ 71 */
72 function open(videos) { 72 function open(videos) {
73 chrome.app.window.create('video_player.html', { 73 return new Promise(function(fulfill, reject) {
74 id: 'video', 74 chrome.app.window.create('video_player.html', {
75 frame: 'none', 75 id: 'video',
76 singleton: false, 76 frame: 'none',
77 minWidth: 480, 77 singleton: false,
78 minHeight: 270 78 minWidth: 480,
79 }, 79 minHeight: 270
80 function(createdWindow) { 80 },
81 fulfill);
82 }).then(function(createdWindow) {
81 // Stores the window for test purpose. 83 // Stores the window for test purpose.
82 appWindowsForTest[videos[0].entry.name] = createdWindow; 84 appWindowsForTest[videos[0].entry.name] = createdWindow;
83 85
84 createdWindow.setIcon('images/icon/video-player-64.png'); 86 createdWindow.setIcon('images/icon/video-player-64.png');
85 createdWindow.contentWindow.videos = videos; 87 createdWindow.contentWindow.videos = videos;
86 chrome.runtime.sendMessage({ready: true}, function() {}); 88 chrome.runtime.sendMessage({ready: true}, function() {});
87 }.wrap()); 89 }).catch(function(error) {
90 console.error('Launch failed', error.stack || error);
hirono 2014/08/20 04:14:06 How about doing: return Promise.reject(error) ? It
yoshiki 2014/08/20 04:26:21 Done.
91 });
88 } 92 }
93
94 // If is is run in the browser test, wait for the test resources are installed
95 // as a component extension, and then load the test resources.
96 if (chrome.test) {
97 window.testExtensionId = 'ljoplibgfehghmibaoaepfagnmbbfiga';
98 chrome.runtime.onMessageExternal.addListener(function(message) {
99 if (message.name !== 'testResourceLoaded')
100 return;
101 var script = document.createElement('script');
102 script.src =
103 'chrome-extension://' + window.testExtensionId +
104 '/common/test_loader.js';
105 document.documentElement.appendChild(script);
106 });
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698