test_sbcddevice.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 function runTest()
32 {
33  var deviceName = "CD Rip";
34  var sbDevice = sbCreateDevice(deviceName, sbMakeInstantJunk());
35  assertTrue(sbDevice);
36  assertEqual(sbDevice.name, deviceName);
37 
38  var deviceManager = Cc["@songbirdnest.com/Songbird/DeviceManager;2"]
39  .getService(Ci.sbIDeviceManager2);
40 
41  function onDeviceEvent(aEvent) {
42  switch (aEvent.type) {
43  case Ci.sbIDeviceEvent.EVENT_DEVICE_READY:
44  if (sbDevice.currentStatus.currentState !=
45  Ci.sbIDevice.STATE_DISCONNECTED) {
46  sbDevice.disconnect();
47  }
48  break;
49  case Ci.sbIDeviceEvent.EVENT_DEVICE_REMOVED:
50  deviceManager.removeEventListener(onDeviceEvent);
51  sbDevice.removeEventListener(onDeviceEvent);
52  testFinished();
53  break;
54  }
55  }
56  deviceManager.QueryInterface(Ci.sbIDeviceEventTarget)
57  .addEventListener(onDeviceEvent);
58  sbDevice.QueryInterface(Ci.sbIDeviceEventTarget)
59  .addEventListener(onDeviceEvent);
60  testPending();
61 }
function sbCreateDevice(deviceName, toc)
const Cc
function testFinished()
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function sbMakeInstantJunk()
function runTest()
Advanced DataRemote unit tests.
const Ci
function testPending()