test_statusproperty.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-2009 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 function runTest() {
26 
27  var prop = "http://songbirdnest.com/data/1.0#cdRipStatus";
28 
29  var builder =
30  Cc["@songbirdnest.com/Songbird/Properties/Builder/StatusProperty;1"]
31  .createInstance(Ci.sbIStatusPropertyBuilder);
32 
33  builder.propertyID = prop;
34  builder.labelKey = "property.cdrip_status";
35  builder.completedLabelKey = "property.cdrip_completed";
36  builder.failedLabelKey = "property.cdrip_failed";
37  var pi = builder.get();
38 
39  assertEqual(pi.type, "status");
40  assertEqual(pi.id, prop);
41 
42  assertEqual(pi.format(null), "Status");
43  assertEqual(pi.format("0|50"), "Status");
44  assertEqual(pi.format("1|50"), "");
45  assertEqual(pi.format("2|100"), "Completed");
46  assertEqual(pi.format("3|100"), "Unable to rip this CD track");
47 
48  var tvpi = pi.QueryInterface(Ci.sbITreeViewPropertyInfo);
49 
50  assertEqual(tvpi.getProgressMode(null), Ci.nsITreeView.PROGRESS_NONE);
51  assertEqual(tvpi.getProgressMode("0|0"), Ci.nsITreeView.PROGRESS_NONE);
52  assertEqual(tvpi.getProgressMode("1|0"), Ci.nsITreeView.PROGRESS_NORMAL);
53  assertEqual(tvpi.getProgressMode("2|0"), Ci.nsITreeView.PROGRESS_NONE);
54  assertEqual(tvpi.getProgressMode("3|0"), Ci.nsITreeView.PROGRESS_NONE);
55 
56  assertEqual(tvpi.getCellValue(null), "");
57  assertEqual(tvpi.getCellValue("0|50"), "");
58  assertEqual(tvpi.getCellValue("1|50"), "50");
59  assertEqual(tvpi.getCellValue("2|100"), "");
60  assertEqual(tvpi.getCellValue("3|100"), "");
61 }
62 
const Cc
function assertEqual(aExpected, aActual, aMessage)
return null
Definition: FeedWriter.js:1143
const Ci
function runTest()
Advanced DataRemote unit tests.