33 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
34 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
44 var view = list.createView();
48 [SBProperties.artistName, [
"AC/DC"]]
52 for (var
i = 0;
i < view.length;
i++) {
53 var viewItem = view.getItemByIndex(
i);
54 var listIndex = view.getUnfilteredIndex(
i);
60 var item1 = library.createMediaItem(
newURI(
"file:///foo/1.mp3"));
61 item1.setProperty(SBProperties.artistName,
"The Fall");
63 var item2 = library.createMediaItem(
newURI(
"file:///foo/2.mp3"));
64 item2.setProperty(SBProperties.artistName,
"The Dirtbombs");
66 var item3 = library.createMediaItem(
newURI(
"file:///foo/3.mp3"));
67 item3.setProperty(SBProperties.artistName,
"The Dirtbombs");
69 var item4 = library.createMediaItem(
newURI(
"file:///foo/4.mp3"));
70 item4.setProperty(SBProperties.artistName,
"Air");
72 list = library.createMediaList(
"simple");
78 view = list.createView();
79 for (var
i = 0;
i < view.length;
i++) {
80 var viewItem = view.getItemByIndex(
i);
81 var listIndex = view.getUnfilteredIndex(
i);
87 [SBProperties.artistName, [
"The Dirtbombs"]]
91 for (var
i = 0;
i < view.length;
i++) {
92 var viewItem = view.getItemByIndex(
i);
93 var listIndex = view.getUnfilteredIndex(
i);
98 var item = library.getItemByGuid(
"3E59BD68-AD99-11DB-9321-C22AB7121F49");
101 view = library.createView();
108 [SBProperties.artistName, [
"AC/DC"]]
116 view = list.createView();
123 [SBProperties.artistName, [
"The Dirtbombs"]]
132 view.getIndexForItem(item1);
133 fail(
"NS_ERROR_NOT_AVAILABLE expected");
140 view = library.createView();
141 view.setSort(SBProperties.createArray([
142 [SBProperties.artistName,
"a"]
147 for (var
i = 0;
i < view.length;
i++) {
148 items.push(view.getItemByIndex(
i));
149 uids.push(view.getViewItemUIDForIndex(
i));
152 view.setSort(SBProperties.createArray([
153 [SBProperties.trackName,
"a"]
156 for (var
i = 0;
i < uids.length;
i++) {
157 var index = view.getIndexForViewItemUID(uids[
i]);
158 var item = view.getItemByIndex(index);
162 view = list.createView();
163 view.setSort(SBProperties.createArray([
164 [SBProperties.artistName,
"a"]
169 for (var
i = 0;
i < view.length;
i++) {
170 items.push(view.getItemByIndex(
i));
171 uids.push(view.getViewItemUIDForIndex(
i));
174 view.setSort(SBProperties.createArray([
175 [SBProperties.artistName,
"d"]
178 for (var
i = 0;
i < uids.length;
i++) {
179 var index = view.getIndexForViewItemUID(uids[
i]);
180 var item = view.getItemByIndex(index);
185 view.getViewItemUIDForIndex(100000);
186 fail(
"NS_ERROR_INVALID_ARG expected");
193 view.getIndexForViewItemUID(
"foo");
194 fail(
"'foo' is not a valid viewItemUID, NS_ERROR_NOT_AVAILABLE expected");
201 var uid = view.getViewItemUIDForIndex(2);
202 var listIndex = view.getUnfilteredIndex(2);
203 view.mediaList.removeByIndex(listIndex);
204 view.getIndexForViewItemUID(uid);
213 for (let
i = 0;
i < view.length;
i++) {
214 view.getItemByIndex(
i);
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
Javascript wrappers for common library tasks.
_getSelectedPageStyle s i