test_sbcdread.js
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 //------------------------------------------------------------------------------
26 //
27 // Mock CD device test
28 //
29 //------------------------------------------------------------------------------
30 
31 
32 function runTest()
33 {
34  var deviceName = "TestCD";
35  var sbDevice = sbCreateDevice(deviceName, sbMakeInstantJunk());
36  assertTrue(sbDevice);
37 
38  var deviceManager = Cc["@songbirdnest.com/Songbird/DeviceManager;2"]
39  .getService(Ci.sbIDeviceManager2);
40 
41  var props = Cc["@mozilla.org/hash-property-bag;1"]
42  .createInstance(Ci.nsIWritablePropertyBag2);
43 
44  // XXX TODO finish out once we have the CD Addon working
45  // sbDevice.submitRequest(Ci.sbIDevice.REQUEST_READ,
46 
47  function onDeviceEvent(aEvent) {
48  switch (aEvent.type) {
49  case Ci.sbIDeviceEvent.EVENT_DEVICE_READY:
50  if (sbDevice.currentStatus.currentState !=
51  Ci.sbIDevice.STATE_DISCONNECTED) {
52  sbDevice.disconnect();
53  }
54  break;
55  case Ci.sbIDeviceEvent.EVENT_DEVICE_REMOVED:
56  deviceManager.removeEventListener(onDeviceEvent);
57  sbDevice.removeEventListener(onDeviceEvent);
58  testFinished();
59  break;
60  }
61  }
62  deviceManager.QueryInterface(Ci.sbIDeviceEventTarget)
63  .addEventListener(onDeviceEvent);
64  sbDevice.QueryInterface(Ci.sbIDeviceEventTarget)
65  .addEventListener(onDeviceEvent);
66  testPending();
67 }
function sbCreateDevice(deviceName, toc)
const Cc
function testFinished()
function assertTrue(aTest, aMessage)
function sbMakeInstantJunk()
const Ci
function runTest()
Advanced DataRemote unit tests.
function testPending()