31 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
34 var
file = Components.classes[
"@mozilla.org/file/directory_service;1"]
35 .getService(Components.interfaces.nsIProperties)
36 .get(
"TmpD", Components.interfaces.nsIFile);
37 var oldFile = file.clone();
38 var spec =
"http://0/not/a/valid/file.mp3";
39 var
uri = Components.classes[
"@mozilla.org/network/io-service;1"]
40 .getService(Components.interfaces.nsIIOService)
42 var item = aLibrary.createMediaItem(uri);
44 var
artist =
"Some Artist *", album =
"Some Album /";
46 item.setProperty(SBProperties.artistName, artist);
47 item.setProperty(SBProperties.albumName, album)
49 var result = aUtils.GetOrganizedPath(file, item);
51 var platform = Components.classes[
"@mozilla.org/xre/runtime;1"]
52 .getService(Components.interfaces.nsIXULRuntime)
55 if (platform ==
"WINNT")
56 badchars = /[\/:\*\?\\\
"<>\|]/g;
57 else if (platform == "Darwin
")
61 artist = artist.replace(badchars, '_');
62 album = album.replace(badchars, '_');
64 assertEqual(result.leafName, "file.mp3
");
65 assertEqual(result.parent.leafName, album);
66 assertEqual(result.parent.parent.leafName, artist);
67 assertTrue(result.parent.parent.parent.equals(oldFile));
71 var utils = Components.classes["@songbirdnest.com/Songbird/
Device/DeviceTester/
Utils;1
"]
72 .createInstance(Components.interfaces.sbIDeviceDeviceTesterUtils);
74 var libraryFile = Components.classes["@mozilla.org/file/directory_service;1
"]
75 .getService(Components.interfaces.nsIProperties)
76 .get("ProfD
", Components.interfaces.nsIFile);
77 libraryFile.append("db
");
78 libraryFile.append("test_devicedevice.db
");
80 Components.classes["@songbirdnest.com/Songbird/Library/LocalDatabase/LibraryFactory;1
"]
81 .getService(Components.interfaces.sbILibraryFactory);
82 var hashBag = Components.classes["@mozilla.org/
hash-
property-bag;1
"]
83 .createInstance(Components.interfaces.nsIWritablePropertyBag2);
84 hashBag.setPropertyAsInterface("databaseFile
", libraryFile);
85 var library = libraryFactory.createLibrary(hashBag);
88 sbIDeviceDeviceTesterUtils_GetOrganizedPath(utils, library);
var getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('Songbird SBProperties artist
function sbIDeviceDeviceTesterUtils_GetOrganizedPath(aUtils, aLibrary)