29 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
30 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
38 Ci.sbICDDeviceListener,
39 Ci.sbIJobProgressListener
43 onMediaInserted:
function(cdDevice) {
45 "Expected CD device to be inserted");
48 var provider = gMLM.getProvider(
"TestProvider");
51 var job = provider.queryDisc(cdDevice.discTOC);
54 if (job.status ==
Ci.sbIJobProgress.STATUS_SUCCEEDED)
55 this.onJobProgress(job);
57 job.addJobProgressListener(
this);
60 onDeviceRemoved:
function(cdDevice) {},
61 onMediaEjected:
function(cdDevice) {},
64 onJobProgress:
function(job) {
65 if (job.status !=
Ci.sbIJobProgress.STATUS_SUCCEEDED)
71 "Expected sbIMetadataLookupJob instance. Got: " + job);
74 var numResults = job.mlNumResults;
76 "Expected at least 1 result. Got: " + numResults);
78 log(
"Got " + numResults +
" results");
80 var results = job.getMetadataResults();
81 while (results.hasMoreElements()) {
82 var a = results.getNext().QueryInterface(
Ci.sbIMetadataAlbumDetail);
83 log(
"This album has " + a.tracks.length +
" tracks");
84 var albumName = a.properties.getPropertyValue(SBProperties.albumName);
86 "Expected album name to be 'Midnight Rock Disc 1', actual " +
88 var artistName = a.properties.getPropertyValue(SBProperties.artistName);
90 "Expected artist name to be 'Various', actual was: " +
92 assertEqual(a.tracks.length, 15,
"Expected 15 tracks");
96 gMockController.ejectMedia(testListener.device,
97 Ci.sbIMockCDDeviceController.MOCK_MEDIA_DISC_MIDNIGHT_ROCK);
99 job.removeJobProgressListener(
this);
100 gMockSvc.removeListener(
this);
107 gMLM =
Cc[
"@songbirdnest.com/Songbird/MetadataLookup/manager;1"]
108 .getService(
Ci.sbIMetadataLookupManager);
109 gMockSvc =
Cc[
"@songbirdnest.com/device/cd/mock-cddevice-service;1"]
110 .getService(
Ci.sbICDDeviceService);
111 gMockController =
Cc[
"@songbirdnest.com/device/cd/mock-cddevice-service;1"]
112 .getService(
Ci.sbIMockCDDeviceController);
114 gMockSvc.registerListener(testListener);
115 var cd0 = gMockSvc.getDevice(0);
117 testListener.device = cd0;
119 gMockController.insertMedia(cd0,
120 Ci.sbIMockCDDeviceController.MOCK_MEDIA_DISC_MIDNIGHT_ROCK);
sbOSDControlService prototype QueryInterface
function assertEqual(aExpected, aActual, aMessage)