31 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
40 [
"track1",
"Track 1",
"Artist 1",
"Album 1",
TimeBefore],
41 [
"track2",
"Track 2",
"Artist 1",
"Album 1",
TimeBefore],
42 [
"track3",
"Track 3",
"Artist 1",
"Album 1",
TimeBefore],
43 [
"track5",
"Track 5",
"Artist 1",
"Album 1",
TimeBefore],
44 [
"track6",
"Track 6",
"Artist 1",
"Album 1",
TimeBefore],
45 [
"track7",
"Track 7",
"Artist 1",
"Album 1",
TimeBefore],
46 [
"track8",
"Track 8",
"Artist 1",
"Album 1",
TimeAfter],
47 ].forEach(
function (
data) {
48 mainLibItems[
data[0]] = {
63 ].forEach(
function (
data) {
64 mainLibLists[
data[0]] = {
67 lastModified: data[3],
74 [
"track1",
"Track 1",
"Artist 1",
"Album 1",
"track1"],
76 [
"track2",
"Track 2",
"Artist 1",
"Album 1",
null],
79 [
"track4",
"Track 4",
"Artist 1",
"Album 1",
null],
81 [
"track5b",
"Track 5",
"Artist 1",
"Album 1",
null],
84 [
"track6",
"Track 6b",
"Artist 1",
"Album 1",
null],
87 [
"track7",
"Track 7b",
"Artist 1",
"Album 1",
"track7"],
90 [
"track8",
"Track 8",
"Artist 1",
"Album 1",
"track8"],
91 ].forEach(
function (
data) {
92 deviceItems[
data[0]] = {
96 originPointsTo: mainLibItems[data[4]]
102 [
"list1",
"A list",
"list1"],
103 [
"list2",
"B list",
"list2"],
104 [
"list3",
"C list",
"list3"],
105 [
"list4",
"D list",
"list4"],
106 [
"list6",
"F list",
null],
107 ].forEach(
function (
data) {
108 deviceLists[
data[0]] = {
110 originPointsTo: mainLibLists[data[2]]
118 {change:
ADDED, source: mainLibItems[
'track3']},
119 {change:
ADDED, source: mainLibItems[
'track6']},
120 {change:
MODIFIED, source: mainLibItems[
'track8'],
121 dest: deviceItems[
'track8']},
123 {change:
MODIFIED, source: mainLibLists[
'list3'],
124 dest: deviceLists[
'list3']},
125 {change:
MODIFIED, source: mainLibLists[
'list4'],
126 dest: deviceLists[
'list4']},
127 {change:
ADDED, source: mainLibLists[
'list5']},
131 {change:
ADDED, source: deviceItems[
'track4']},
132 {change:
ADDED, source: deviceItems[
'track6']},
134 {change:
MODIFIED, source: deviceLists[
'list1'],
135 dest: mainLibLists[
'list1']},
136 {change:
ADDED, source: deviceLists[
'list6']},
143 for (var
i = 0;
i <
actual.changes.length;
i++)
145 var change =
actual.changes.queryElementAt(
i,
Ci.sbILibraryChange);
159 deviceLib.setProperty(
"http://songbirdnest.com/data/1.0#lastSyncTime",
162 for (var itemFilename in mainLibItems) {
163 var itemData = mainLibItems[itemFilename];
164 var properties = SBProperties.createArray([
165 [SBProperties.artistName, itemData.artist],
166 [SBProperties.albumName, itemData.album],
167 [SBProperties.trackName, itemData.track]]);
169 var mainItem = mainLib.createMediaItem(
170 newURI(
"file:///main/"+itemFilename),
174 mainItem.setProperty(SBProperties.updated, itemData.lastModified);
177 itemData.item = mainItem;
180 for (var listId in mainLibLists) {
181 var listData = mainLibLists[listId];
183 var type = listData.isSmart ?
"smart" :
"simple";
184 var item = mainLib.createMediaList(type);
186 if (listData.isSmart) {
191 Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
192 .getService(
Ci.sbIPropertyManager);
193 var prop = SBProperties.albumName;
194 var op = propMan.getPropertyInfo(prop).getOperator(
"=");
195 item.appendCondition(prop, op,
"Album Foo",
null,
"a");
198 item.name = listData.name;
199 item.setProperty(SBProperties.updated, listData.lastModified);
201 listData.item = item;
204 for (var itemFilename in deviceItems) {
205 var itemData = deviceItems[itemFilename];
206 var properties = SBProperties.createArray([
207 [SBProperties.artistName, itemData.artist],
208 [SBProperties.albumName, itemData.album],
209 [SBProperties.trackName, itemData.track]]);
210 if (itemData.originPointsTo) {
211 properties.appendProperty(SBProperties.originLibraryGuid, mainLib.guid);
212 properties.appendProperty(SBProperties.originItemGuid,
213 itemData.originPointsTo.item.guid);
215 var devItem = deviceLib.createMediaItem(
216 newURI(
"file:///device/"+itemFilename),
218 itemData.item = devItem;
221 for (var listId in deviceLists) {
222 var listData = deviceLists[listId];
224 var properties =
null;
225 if (listData.originPointsTo)
226 properties = SBProperties.createArray([
227 [SBProperties.originLibraryGuid, mainLib.guid],
228 [SBProperties.originItemGuid, listData.originPointsTo.item.guid]]);
229 var item = deviceLib.createMediaList(
"simple", properties);
230 item.name = listData.name;
232 listData.item = item;
239 dump(
"Dumping "+title+
" ("+changeset.changes.length +
" changes)\n");
241 for (var
i = 0;
i < changeset.changes.length;
i++)
243 var change = changeset.changes.queryElementAt(
i,
Ci.sbILibraryChange);
245 if (change.operation ==
Ci.sbIChangeOperation.ADDED) {
246 dump(
"Added: "+change.sourceItem.contentSrc.spec+
"\n");
248 else if (change.operation ==
Ci.sbIChangeOperation.MODIFIED) {
249 dump(
"Clobber: "+change.sourceItem.contentSrc.spec+
250 " --> "+change.destinationItem.contentSrc.spec+
"\n");
253 dump(
"INTERNAL ERROR\n");
260 var
sync =
Cc[
"@songbirdnest.com/Songbird/Device/DeviceLibrarySyncDiff;1"]
261 .createInstance(
Ci.sbIDeviceLibrarySyncDiff);
273 var exportChanges = {};
274 var importChanges = {};
275 sync.generateSyncLists(
Ci.sbIDeviceLibrarySyncDiff.SYNC_TYPE_AUDIO,
276 Ci.sbIDeviceLibrarySyncDiff.SYNC_TYPE_AUDIO,
var expectedImportChanges
function dumpChanges(title, changeset)
function assertEqual(aExpected, aActual, aMessage)
var expectedExportChanges
var getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('Songbird SBProperties artist
function createLibrary(databaseGuid, databaseLocation)
function newURI(aURLString)
function populateLibraries(mainLib, deviceLib)
_getSelectedPageStyle s i
function verifyChanges(actual, expected)
function runTest()
Advanced DataRemote unit tests.