26 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
28 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
29 Components.utils.import(
"resource://app/jsmodules/DropHelper.jsm");
30 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
33 var
url =
"data:application/vnd.mozilla.xul+xml," +
34 "<?xml-stylesheet href='chrome://global/skin' type='text/css'?>" +
35 "<?xml-stylesheet href='chrome://songbird/content/bindings/bindings.css' type='text/css'?>" +
36 "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'/>";
43 setup:
function TestPlayQueuPlaylistDrop_setup() {
50 pqSvc =
Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
51 .getService(
Ci.sbIPlayQueueService),
52 pqList = pqSvc.mediaList;
56 function createElement(aList, aType) {
57 var playlist = document.createElementNS(
XUL_NS, aType);
58 playlist.setAttribute(
"flex",
"1");
59 document.documentElement.appendChild(playlist);
60 playlist.bind(aList.createView(),
null);
66 [ createElement(library,
"sb-playlist"),
67 createElement(pqList,
"sb-playqueue-playlist") ]);
70 run:
function TestPlayQueueDrop_run(aLibraryPlaylist,
74 for (let
i = 0, len = tests.length;
i < len;
i++) {
76 dump(
'DESC: ' + testCase.desc +
'\n');
77 testCase.run([aLibraryPlaylist, aPlayQueuePlaylist]);
84 function TestPlayQueueDrop_createItemsInLibrary(aLibrary,
aCount)
86 this._itemCounter = this._itemCounter || 0;
88 function testURIFor(index) {
89 return newURI(
'http://test.com/playqueuedrop/' + index);
92 var
start = this._itemCounter,
96 this._itemCounter +=
aCount;
97 finish = this._itemCounter - 1;
99 for (let
i = start;
i <= finish;
i++) {
103 return [ aLibrary.createMediaItem(testURIFor(
i))
for each (
i in indexes) ];
109 desc:
"dropping an enumerator of mediaitems on an empty play queue " +
110 "should add items to the queue with async queueSomeNext",
111 pre:
function (libraryPlaylist, playQueuePlaylist) {
115 this.pqSvc =
Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
116 .getService(
Ci.sbIPlayQueueService);
118 onIndexUpdated:
function (aToIndex) {
120 onQueueOperationStarted:
function () {
121 self.asyncOpStarted =
true;
123 onQueueOperationCompleted:
function () {
125 self.pqSvc.mediaList.length,
126 self.desc +
': incorrect queue length');
130 this.pqSvc.addListener(this.pqListener);
134 TestPlayQueueDrop.createItemsInLibrary(libraryPlaylist.library, 3);
136 var view = libraryPlaylist.mediaListView;
137 view.selection.selectAll();
138 var context =
new DNDUtils.MediaListViewSelectionTransferContext(view);
139 var
handle =
Cc[
"@songbirdnest.com/Songbird/DndSourceTracker;1"]
140 .getService(
Ci.sbIDndSourceTracker)
141 .registerSource(context);
143 this.stub(
DNDUtils,
'getTransferDataForFlavour',
function (type) {
144 var sourceData =
null;
145 if (type ==
"application/x-sb-transfer-media-items") {
146 sourceData = {
data: handle};
150 this.asyncOpStarted =
false;
152 getData:
function (aTransferable, aItemIndex) {
155 isDataFlavorSupported:
function (aDataFlavor) {
161 exec:
function (libraryPlaylist, playQueuePlaylist) {
162 playQueuePlaylist._dropOnTree(0,
163 Ci.sbIMediaListViewTreeViewObserver.DROP_AFTER,
168 'async play queue drop did not call async listener');
171 post:
function(libraryPlaylist) {
172 this.pqSvc.removeListener(this.pqListener);
173 this.pqSvc.clearAll();
174 libraryPlaylist.library.clear();
178 desc:
"inserting an enumerator of mediaitems between play queue rows " +
179 "should add items to the queue with async queueSomeBefore",
180 pre:
function (libraryPlaylist, playQueuePlaylist) {
184 this.pqSvc =
Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
185 .getService(
Ci.sbIPlayQueueService);
187 onIndexUpdated:
function (aToIndex) {
189 onQueueOperationStarted:
function () {
190 self.asyncOpStarted =
true;
192 onQueueOperationCompleted:
function () {
194 self.pqSvc.mediaList.length,
195 self.desc +
': incorrect queue length');
199 this.pqSvc.addListener(this.pqListener);
202 var queueLib = this.pqSvc.mediaList.library;
204 TestPlayQueueDrop.createItemsInLibrary(queueLib, 4);
205 queueItems.forEach(
function (item) {
207 self.pqSvc.queueNext(item);
212 TestPlayQueueDrop.createItemsInLibrary(libraryPlaylist.library, 3);
213 var view = libraryPlaylist.mediaListView;
214 view.selection.selectAll();
215 var context =
new DNDUtils.MediaListViewSelectionTransferContext(view);
216 var
handle =
Cc[
"@songbirdnest.com/Songbird/DndSourceTracker;1"]
217 .getService(
Ci.sbIDndSourceTracker)
218 .registerSource(context);
220 this.stub(
DNDUtils,
'getTransferDataForFlavour',
function (type) {
221 var sourceData =
null;
222 if (type ==
"application/x-sb-transfer-media-items") {
223 sourceData = {
data: handle };
227 this.asyncOpStarted =
false;
229 getData:
function (aTransferable, aItemIndex) {
230 return {
data: handle };
232 isDataFlavorSupported:
function (aDataFlavor) {
238 exec:
function (libraryPlaylist, playQueuePlaylist) {
239 playQueuePlaylist._dropOnTree(2,
240 Ci.sbIMediaListViewTreeViewObserver.DROP_BEFORE,
this.fakeSession);
244 'async play queue drop did not call async listener');
247 post:
function(libraryPlaylist) {
248 this.pqSvc.removeListener(this.pqListener);
249 this.pqSvc.clearAll();
250 libraryPlaylist.library.clear();
254 desc:
"dropping a mediaList on an empty queue should call up to the parent " +
255 "playlist binding for synchronous insertion",
256 pre:
function (libraryPlaylist, playQueuePlaylist) {
260 this.pqSvc =
Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
261 .getService(
Ci.sbIPlayQueueService);
263 onIndexUpdated:
function (aToIndex) {
265 onQueueOperationStarted:
function () {
266 doFail(
"Synchronous play queue operations should not call the async " +
267 "operations listener");
269 onQueueOperationCompleted:
function () {
270 doFail(
"Synchronous play queue operations should not call the async " +
271 "operations listener");
274 this.pqSvc.addListener(this.pqListener);
277 var library = libraryPlaylist.library;
278 var list = library.createMediaList(
"simple");
279 var items = TestPlayQueueDrop.createItemsInLibrary(library, 3);
280 items.forEach(
function (item) {
283 var context =
new DNDUtils.MediaListTransferContext(list, list);
284 var handle =
Cc[
"@songbirdnest.com/Songbird/DndSourceTracker;1"]
285 .getService(
Ci.sbIDndSourceTracker)
286 .registerSource(context);
288 this.stub(
DNDUtils,
'getTransferDataForFlavour',
function (type) {
289 var sourceData =
null;
290 if (type ===
"application/x-sb-transfer-media-list") {
291 sourceData = {
data: handle };
295 this.stub(
DNDUtils,
'getTransferData',
function () {
296 return {
data: handle };
298 this.stub(InternalDropHandler,
'isSupported',
function () {
301 this.stub(ExternalDropHandler,
'isSupported',
function () {
305 getData:
function (aTransferable, aItemIndex) {
306 return {
data: handle };
308 isDataFlavorSupported:
function (aDataFlavor) {
314 exec:
function (libraryPlaylist, playQueuePlaylist) {
315 playQueuePlaylist._dropOnTree(0,
316 Ci.sbIMediaListViewTreeViewObserver.DROP_BEFORE,
320 this.desc +
': incorrect queue length');
322 post:
function (libraryPlaylist, playQueuePlaylist) {
323 this.pqSvc.removeListener(this.pqListener);
324 this.pqSvc.clearAll();
325 libraryPlaylist.library.clear();
329 desc:
"dropping a mediaList at a specific insertion point in the queue " +
330 "should call the parent playlist binding for synchronous insertion",
331 pre:
function (libraryPlaylist, playQueuePlaylist) {
335 this.pqSvc =
Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
336 .getService(
Ci.sbIPlayQueueService);
338 onIndexUpdated:
function (aToIndex) {
340 onQueueOperationStarted:
function () {
341 doFail(
"Synchronous play queue operations should not call the async " +
342 "operations listener");
344 onQueueOperationCompleted:
function () {
345 doFail(
"Synchronous play queue operations should not call the async " +
346 "operations listener");
349 this.pqSvc.addListener(this.pqListener);
352 var queueLib = this.pqSvc.mediaList.library;
354 TestPlayQueueDrop.createItemsInLibrary(queueLib, 4);
355 queueItems.forEach(
function (item) {
357 self.pqSvc.queueNext(item);
361 var library = libraryPlaylist.library;
362 var list = library.createMediaList(
"simple");
363 var items = TestPlayQueueDrop.createItemsInLibrary(library, 3);
364 items.forEach(
function (item) {
367 var context =
new DNDUtils.MediaListTransferContext(list, list);
368 var handle =
Cc[
"@songbirdnest.com/Songbird/DndSourceTracker;1"]
369 .getService(
Ci.sbIDndSourceTracker)
370 .registerSource(context);
372 this.stub(
DNDUtils,
'getTransferDataForFlavour',
function (type) {
373 var sourceData =
null;
374 if (type ===
"application/x-sb-transfer-media-list") {
375 sourceData = {
data: handle };
379 this.stub(
DNDUtils,
'getTransferData',
function () {
380 return {
data: handle };
382 this.stub(InternalDropHandler,
'isSupported',
function () {
385 this.stub(ExternalDropHandler,
'isSupported',
function () {
391 getData:
function (aTransferable, aItemIndex) {
392 return {
data: handle };
394 isDataFlavorSupported:
function (aDataFlavor) {
400 exec:
function (libraryPlaylist, playQueuePlaylist) {
401 playQueuePlaylist._dropOnTree(2,
402 Ci.sbIMediaListViewTreeViewObserver.DROP_BEFORE,
406 this.desc +
': incorrect queue length');
408 post:
function (libraryPlaylist, playQueuePlaylist) {
409 this.pqSvc.removeListener(this.pqListener);
410 this.pqSvc.clearAll();
411 libraryPlaylist.library.clear();
function endWindowTest(e)
function TestCase(config)
const K_PLAYQUEUEDROP_TESTCASES
function beginWindowTest(url, continueFunction)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function handle(request, response)
function runTest()
Advanced DataRemote unit tests.
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
restoreHistoryPrecursor aCount
_getSelectedPageStyle s i
function continueWindowTest(fn, parameters)