29 Components.utils.import(
"resource://app/jsmodules/ServicePaneHelper.jsm");
31 function DBG(s) {
log(
'DBG:test_servicepanehelper: '+s); }
34 function getBadgeIDs() {
41 assertTrue(badge,
"Getting a non-existent badge doesn't create it");
42 assertEqual(badge.id,
"testBadge",
"getBadge didn't initialize badge ID");
43 assertEqual(badge.node, aRoot,
"getBadge didn't initialize badge node");
44 assertFalse(badge.visible,
"Badge isn't invisible by default");
48 badge.label =
"label";
49 badge.image =
"chrome://example/skin/image.png";
51 assertEqual(badge.label,
"label",
"Setting badge label didn't work");
52 assertEqual(badge.image,
"chrome://example/skin/image.png",
53 "Setting badge image didn't work");
58 assertEqual(badge.label,
"label",
"Re-getting badge cleared badge label");
59 assertEqual(badge.image,
"chrome://example/skin/image.png",
60 "Re-getting badge cleared badge image");
67 assertEqual(badge.id,
"testBadge",
"getBadge didn't initialize badge ID");
68 assertEqual(badge.node, aRoot,
"getBadge didn't initialize badge node");
69 assertTrue(badge.visible,
"Badge isn't invisible by default");
70 assertEqual(badge.label,
"label",
"Appending badge cleared badge label");
71 assertEqual(badge.image,
"chrome://example/skin/image.png",
72 "Appending badge cleared badge image");
75 assertTrue(badge.visible,
"Re-getting badge cleared visibility flag");
76 assertEqual(badge.label,
"label",
"Re-getting badge cleared badge label");
77 assertEqual(badge.image,
"chrome://example/skin/image.png",
78 "Re-getting badge cleared badge image");
81 assertTrue(badge2,
"Getting badge without ID doesn't create it");
82 assertTrue(badge2.id,
"getBadge didn't generate badge ID");
86 badge2.insertBefore(
"testBadge");
92 badge2.label =
"label2";
94 "Changing label of visible badge didn't persist");
95 assertEqual(badge.label,
"label",
"Label of unrelated badge was modified");
97 badge.insertBefore(badge2.id);
100 badge.visible =
false;
102 assertFalse(badge.visible,
"Badge is still visible after hiding");
103 assertEqual(badge.label,
"label",
"Hiding badge cleared badge label");
104 assertEqual(badge.image,
"chrome://example/skin/image.png",
105 "Hiding badge cleared badge image");
109 assertEqual(badge.label,
null,
"Removing badge didn't clear badge label");
110 assertEqual(badge.image,
null,
"Removing badge didn't clear badge image");
117 assertFalse(badge2.visible,
"Badge is still visible after removing");
124 let SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"]
125 .getService(
Ci.sbIServicePaneService);
131 let testRoot = SPS.createNode();
133 "created node is not a service pane node");
135 SPS.root.appendChild(testRoot);
141 SPS.root.removeChild(testRoot);
function assertNotEqual(aExpected, aActual, aMessage)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function assertArraysEqual(a1, a2)
function assertFalse(aTest, aMessage)
function serializeTree(aNode)
Common service pane helper functions.
function runTest()
Advanced DataRemote unit tests.
function testBadges(SPS, aRoot)