32 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
34 .createInstance(Components.interfaces.nsIUUIDGenerator);
38 this.wrappedJSObject =
this;
40 this.
id = gUUIDGenerator.generateUUID();
41 this.connected =
false;
43 this.connected =
true;
48 var manager = Components.classes[
"@songbirdnest.com/Songbird/DeviceManager;2"]
49 .getService(Components.interfaces.sbIDeviceManager2);
54 for (var
i = 0;
i < 1000; ++
i) {
55 var param = Math.random();
62 manager.registerDevice(device);
65 for (var
i = 0;
i < 1000; ++
i) {
66 param = Math.random();
72 var returnedDevice = manager.getDevice(device.id);
73 assertTrue(device === returnedDevice.wrappedJSObject,
74 "failed to get device:" +
75 device.id +
" / " + returnedDevice.id);
76 manager.unregisterDevice(device);
77 assertTrue(returnedDevice.wrappedJSObject.connected);
80 var devices = ArrayConverter.JSArray(manager.devices);
81 assertTrue(devices.length == params.length,
"expected devices to be registered");
82 for each (device
in devices) {
83 var index = params.indexOf(device.wrappedJSObject.param);
84 assertTrue(index >= 0,
"Looking for param " + device.wrappedJSObject.param);
85 params.splice(index, 1);
86 manager.unregisterDevice(device);
89 assertTrue(params.length == 0,
"params not empty: " + uneval(params));
90 assertTrue(manager.devices.length == 0,
"devices not unregistered");
function DummyDevice(aParam)
function assertTrue(aTest, aMessage)
function runTest()
Advanced DataRemote unit tests.
_getSelectedPageStyle s i