33 var sbIML =
Ci.sbIMediaList;
34 var
SB_NS =
"http://songbirdnest.com/data/1.0#";
36 var databaseGUID =
"test_simplemedialistnotifications";
42 var
flags = sbIML.LISTENER_FLAGS_ALL;
43 library.addListener(listener,
false, flags);
47 library.removeListener(listener);
50 flags = sbIML.LISTENER_FLAGS_ITEMADDED;
51 library.addListener(listener,
false, flags);
55 library.removeListener(listener);
58 flags = sbIML.LISTENER_FLAGS_BEFOREITEMREMOVED;
59 library.addListener(listener,
false, flags);
63 library.removeListener(listener);
66 flags = sbIML.LISTENER_FLAGS_AFTERITEMREMOVED;
67 library.addListener(listener,
false, flags);
71 library.removeListener(listener);
74 flags = sbIML.LISTENER_FLAGS_ITEMUPDATED;
75 library.addListener(listener,
false, flags);
79 library.removeListener(listener);
82 flags = sbIML.LISTENER_FLAGS_LISTCLEARED;
83 library.addListener(listener,
false, flags);
87 library.removeListener(listener);
90 flags = sbIML.LISTENER_FLAGS_BATCHBEGIN;
91 library.addListener(listener,
false, flags);
95 library.removeListener(listener);
98 flags = sbIML.LISTENER_FLAGS_BATCHEND;
99 library.addListener(listener,
false, flags);
103 library.removeListener(listener);
107 flags = sbIML.LISTENER_FLAGS_BATCHBEGIN |
108 sbIML.LISTENER_FLAGS_BATCHEND |
109 sbIML.LISTENER_FLAGS_ITEMUPDATED;
110 library.addListener(listener,
false, flags);
114 library.removeListener(listener);
118 library.addListener(listener,
false);
122 library.removeListener(listener);
127 filter.appendProperty(SB_NS +
"albumName",
null);
128 filter.appendProperty(SB_NS +
"trackNumber",
null);
129 library.addListener(listener,
false, sbIML.LISTENER_FLAGS_ALL, filter);
131 var item = library.createMediaItem(
newURI(
"http://foo.com/"));
132 item.setProperty(SB_NS +
"artistName",
"foo");
136 item.setProperty(SB_NS +
"albumName",
"foo");
140 item.setProperty(SB_NS +
"trackNumber",
"123");
146 listener.retval =
true;
147 item.setProperty(SB_NS +
"albumName",
"foo");
151 listener.retval =
false;
153 library.runInBatchMode(
function() {
156 item.setProperty(SB_NS +
"albumName",
"foo");
160 listener.retval =
true;
164 item.setProperty(SB_NS +
"albumName",
"foo");
168 listener.retval =
true;
171 item.setProperty(SB_NS +
"albumName",
"foo");
176 listener.retval =
true;
179 item.setProperty(SB_NS +
"albumName",
"foo");
183 listener.retval =
true;
186 item.setProperty(SB_NS +
"albumName",
"foo");
189 library.removeListener(listener);
194 library.runInBatchMode(
function() {});
195 var item = library.createMediaItem(
newURI(
"http://foo.com/"),
null,
true);
196 item.setProperty(
SB_NS +
"albumName",
"foo");
197 library.remove(item);
203 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_ITEMADDED) {
210 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_BEFOREITEMREMOVED) {
217 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_AFTERITEMREMOVED) {
224 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_ITEMUPDATED) {
231 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_LISTCLEARED) {
238 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_BATCHBEGIN) {
245 if (
flags &
Ci.sbIMediaList.LISTENER_FLAGS_BATCHEND) {
254 return Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
255 .createInstance(
Ci.sbIMutablePropertyArray);
function assertNotEqual(aExpected, aActual, aMessage)
sbDeviceFirmwareAutoCheckForUpdate prototype flags
function assertTrue(aTest, aMessage)
function createPropertyArray()
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Test file.
function doSomethingThatFiresAllEvents(library)
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function assertFalse(aTest, aMessage)
function assertFlagsMatch(flags, listener)
Array filter(tab.attributes, function(aAttr){return(_this.xulAttributes.indexOf(aAttr.name) >-1);}).forEach(tab.removeAttribute
function TestMediaListListener()