32 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
34 .createInstance(Components.interfaces.nsIUUIDGenerator);
38 this.wrappedJSObject =
this;
40 this.
id = gUUIDGenerator.generateUUID();
44 var manager = Components.classes[
"@songbirdnest.com/Songbird/DeviceManager;2"]
45 .getService(Components.interfaces.sbIDeviceManager2);
49 var defaultControllers = ArrayConverter.JSArray(manager.controllers);
50 var defaultControllerCount = defaultControllers.length;
52 for each (defaultController
in defaultControllers) {
53 defaultController.QueryInterface(Components.interfaces.sbIDeviceController);
54 params.push(defaultController.name);
58 for (var
i = 0;
i < 1000; ++
i) {
60 var param = (params.length * 65537 + 7) % 3000;
61 params.push(
"" + param);
67 manager.registerController(controller);
70 for (var
i = 0;
i < 1000; ++
i) {
72 var param = (params.length * 65537 + 7) % 3000;
73 params.push(
"" + param);
78 var returnedController = manager.getController(controller.id);
79 assertTrue(controller === returnedController.wrappedJSObject,
80 "failed to get controller:" +
81 controller.name +
" / " + returnedController.name);
82 manager.unregisterController(controller);
85 var controllers = ArrayConverter.JSArray(manager.controllers);
86 assertTrue(controllers.length == params.length,
"expected controllers to be registered");
87 for each (controller
in controllers) {
88 controller.QueryInterface(Components.interfaces.sbIDeviceController);
89 var index = params.indexOf(controller.name);
90 assertTrue(index >= 0,
"Looking for param " + controller.name +
"\n" + uneval(params));
91 params.splice(index, 1);
92 manager.unregisterController(controller);
94 assertTrue(params.length == 0,
"params not empty: " + uneval(params));
95 assertTrue(manager.controllers.length == 0,
"devices not unregistered");
function runTest()
Advanced DataRemote unit tests.
function assertTrue(aTest, aMessage)
function DummyController(aParam)
_getSelectedPageStyle s i