32 var
url =
"data:application/vnd.mozilla.xul+xml," +
33 "<?xml-stylesheet href='chrome://global/skin' type='text/css'?>" +
34 "<?xml-stylesheet href='chrome://songbird/content/bindings/bindings.css' type='text/css'?>" +
35 "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'/>";
46 var databaseGUID =
"test_playlist_selection";
49 const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
53 var playlist = document.createElementNS(
XUL_NS,
"sb-playlist");
54 playlist.setAttribute(
"flex",
"1");
55 document.documentElement.appendChild(playlist);
56 playlist.bind(library.createView(),
null);
67 setSort(playlist,
"created",
"a");
69 var view = playlist.mediaListView;
71 for (var
i = 0;
i < library.length;
i ++) {
72 guids.push(view.getItemByIndex(
i).guid);
77 treeView.selection.selectAll();
89 log(
"testSelectAllResort");
92 setSort(playlist,
"created",
"d");
95 treeView.selection.selectAll();
107 log(
"testSelectSome");
110 treeView.selection.clearSelection();
113 for (var
i = 0;
i < library.length;
i += 2) {
114 treeView.selection.toggleSelect(
i);
115 guids.push(playlist.mediaListView.getItemByIndex(
i).guid);
127 log(
"testSelectSomeResort");
128 setSort(playlist,
"created",
"a");
141 log(
"testSelectAllThenAdd");
144 treeView.selection.selectAll();
147 library.createMediaItem(
newURI(
"file:///foo"));
148 var view = playlist.mediaListView;
150 for (var
i = 0;
i < library.length;
i ++) {
151 guids.push(view.getItemByIndex(
i).guid);
165 log(
"testSelectRange");
168 setSort(playlist,
"created",
"a");
170 var view = playlist.mediaListView;
172 for (var
i = 1;
i < library.length - 1;
i ++) {
173 guids.push(view.getItemByIndex(
i).guid);
179 var bo = playlist.tree.boxObject.QueryInterface(
Ci.nsITreeBoxObject);
180 bo.ensureRowIsVisible(0);
183 bo.ensureRowIsVisible(library.length - 1);
187 treeView.selection.clearSelection();
194 treeView.selection.rangedSelect(1, library.length - 2,
true);
207 log(
"testSelectRangeResort");
209 setSort(playlist,
"created",
"d");
222 if (a1.length != a2.length) {
223 fail(
"compare failed, length wrong, got " + a1.length +
" expected " + a2.length);
226 for (var
i = 0;
i < a1.length;
i++) {
227 if (a1[
i] != a2[
i]) {
228 fail(
"arrays don't match at index " + i +
" '" + a1[i] +
"' != '" + a2[i] +
"'");
234 function setSort(playlist, property, direction) {
235 var view = playlist.mediaListView;
238 pa.appendProperty(
"http://songbirdnest.com/data/1.0#" + property, direction);
243 var enumerator = playlist.mediaListView.selection.selectedIndexedMediaItems;
245 while (enumerator.hasMoreElements()) {
246 selected.push(enumerator.getNext().mediaItem.guid);
252 return Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
253 .createInstance(
Ci.sbIMutablePropertyArray);
function safeSetTimeout(closure, timeout)
function testSelectRangeResort(library, playlist, previouslySelected)
function endWindowTest(e)
function setSort(playlist, property, direction)
function beginWindowTest(url, continueFunction)
function testSelectSomeResort(library, playlist, previouslySelected)
function testSelectSome(library, playlist)
function testSelectAllThenAdd(library, playlist)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function testSelectRange(library, playlist)
function getSelected(playlist)
function testSelectAllResort(library, playlist, previouslySelected)
_getSelectedPageStyle s i
function assertArraySimilar(a1, a2)
function createPropertyArray()
function continueWindowTest(fn, parameters)
function runTest()
Test file.
function testSelectAll(library, playlist)