27 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
28 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
29 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
45 var originalLibraryLength = library.length;
54 log(
'using test folder ' + testFolder.path);
61 library.enumerateAllItems({
62 onEnumerationBegin:
function(list) {
63 return Ci.sbIMediaListEnumerationListener.CONTINUE;
65 onEnumeratedItem:
function(list, item) {
66 dump(
"Found media item:" + item.contentSrc.spec +
"\n");
68 item.setProperty(SBProperties.originURL, item.contentSrc.spec);
69 return Ci.sbIMediaListEnumerationListener.CONTINUE;
71 onEnumerationEnd:
function(list, status) {
75 assertEqual(library.length, originalLibraryLength + 5);
78 var root =
newFileURI(testFolder).spec.toLowerCase();
80 map[root +
"individualmovedfile.mp3"] = root +
"dir3/individualmovedfile.mp3";
81 map[root +
"renamedfile.mp3"] = root +
"renamedfile2.mp3";
82 map[root +
"dir1/dir2/movedfile1.mp3"] = root +
"dir3/dir1/dir2/movedfile1.mp3";
83 map[root +
"dir1/dir2/movedfile2.mp3"] = root +
"dir3/dir1/dir2/movedfile2.mp3";
84 map[root +
"deletedfile.mp3"] =
null;
85 map[
"null"] = root +
"dir3/newfile.mp3";
87 var dir1 = testFolder.clone();
89 var dir3 = testFolder.clone();
91 var individualMovedFile = testFolder.clone();
92 individualMovedFile.append(
"individualMovedFile.mp3");
93 var renamedFile = testFolder.clone();
94 renamedFile.append(
"renamedFile.mp3");
95 var deletedFile = testFolder.clone();
96 deletedFile.append(
"deletedFile.mp3");
97 var newFile = dir3.clone();
98 newFile.append(
"random.txt");
101 dir1.moveTo(dir3,
null);
102 individualMovedFile.moveTo(dir3,
null);
103 renamedFile.moveTo(renamedFile.parent,
"renamedFile2.mp3");
104 deletedFile.remove(
false);
105 newFile.copyTo(newFile.parent,
"newFile.mp3");
113 library.enumerateAllItems({
114 onEnumerationBegin:
function(list) {
115 return Ci.sbIMediaListEnumerationListener.CONTINUE;
117 onEnumeratedItem:
function(list, item) {
118 var newSpec = item.getProperty(SBProperties.contentURL).toLowerCase();
119 var oldSpec = item.getProperty(SBProperties.originURL);
120 if (oldSpec) oldSpec = oldSpec.toLowerCase()
121 dump(
"Change: '" + oldSpec +
"' -> '" + newSpec +
"'\n");
123 if (oldSpec in map) {
124 if (newSpec == map[oldSpec]) {
127 dump(
"FAIL: Expected '" + map[oldSpec] +
128 "' but got '" + newSpec +
"'\n");
132 return Ci.sbIMediaListEnumerationListener.CONTINUE;
134 onEnumerationEnd:
function(list, status) {
function sleep(ms, suppressOutput)
function newAppRelativeFile(path)
function setWatchFolder(file)
function assertEqual(aExpected, aActual, aMessage)
function newFileURI(file)
Javascript wrappers for common library tasks.
function getCopyOfFolder(folder, tempName)
Copy the given folder to tempName, returning an nsIFile for the new location.
function runTest()
Advanced DataRemote unit tests.