test_itunes_xml_parser.js
Go to the documentation of this file.
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2009 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27  */
28 
34 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
35 
36 
42 testXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
43 testXML += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n";
44 testXML += "<plist version=\"1.0\">\n";
45 testXML += "<dict>\n";
46 testXML += " <key>Major Version</key><integer>1</integer>\n";
47 testXML += " <key>Minor Version</key><integer>1</integer>\n";
48 testXML += " <key>Application Version</key><string>8.1</string>\n";
49 testXML += " <key>Features</key><integer>5</integer>\n";
50 testXML += " <key>Show Content Ratings</key><true/>\n";
51 testXML += " <key>Music Folder</key><string>file://localhost/C:/Users/dbradley/Music/iTunes/iTunes%20Music/</string>\n";
52 testXML += " <key>Library Persistent ID</key><string>4901D1E2BA4B2D9B</string>\n";
53 testXML += " <key>Tracks</key>\n";
54 testXML += " <dict>\n";
55 testXML += " <key>60</key>\n";
56 testXML += " <dict>\n";
57 testXML += " <key>Track ID</key><integer>60</integer>\n";
58 testXML += " <key>Name</key><string>ESRB</string>\n";
59 testXML += " <key>Kind</key><string>QuickTime movie file</string>\n";
60 testXML += " <key>Size</key><integer>2306052</integer>\n";
61 testXML += " <key>Total Time</key><integer>6000</integer>\n";
62 testXML += " <key>Date Modified</key><date>2007-02-12T15:53:10Z</date>\n";
63 testXML += " <key>Date Added</key><date>2009-02-13T03:04:07Z</date>\n";
64 testXML += " <key>Artwork Count</key><integer>1</integer>\n";
65 testXML += " <key>Persistent ID</key><string>042FEFDD9488F280</string>\n";
66 testXML += " <key>Track Type</key><string>File</string>\n";
67 testXML += " <key>Has Video</key><true/>\n";
68 testXML += " <key>HD</key><false/>\n";
69 testXML += " <key>Movie</key><true/>\n";
70 testXML += " <key>Location</key><string>file://localhost/C:/Users/dbradley/Music/ESRB.mpg</string>\n";
71 testXML += " <key>File Folder Count</key><integer>-1</integer>\n";
72 testXML += " <key>Library Folder Count</key><integer>-1</integer>\n";
73 testXML += " </dict>\n";
74 testXML += " <key>62</key>\n";
75 testXML += " <dict>\n";
76 testXML += " <key>Track ID</key><integer>62</integer>\n";
77 testXML += " <key>Name</key><string>The Swarm</string>\n";
78 testXML += " <key>Artist</key><string>Noble Society</string>\n";
79 testXML += " <key>Album Artist</key><string>Various Artists</string>\n";
80 testXML += " <key>Album</key><string>The Swarm Riddim</string>\n";
81 testXML += " <key>Genre</key><string>Reggae</string>\n";
82 testXML += " <key>Kind</key><string>Purchased AAC audio file</string>\n";
83 testXML += " <key>Size</key><integer>8118815</integer>\n";
84 testXML += " <key>Total Time</key><integer>240160</integer>\n";
85 testXML += " <key>Disc Number</key><integer>1</integer>\n";
86 testXML += " <key>Disc Count</key><integer>1</integer>\n";
87 testXML += " <key>Track Number</key><integer>1</integer>\n";
88 testXML += " <key>Track Count</key><integer>13</integer>\n";
89 testXML += " <key>Year</key><integer>2007</integer>\n";
90 testXML += " <key>Date Modified</key><date>2008-01-29T08:58:06Z</date>\n";
91 testXML += " <key>Date Added</key><date>2009-02-13T03:33:07Z</date>\n";
92 testXML += " <key>Bit Rate</key><integer>256</integer>\n";;
93 testXML += " <key>Sample Rate</key><integer>44100</integer>\n";;
94 testXML += " <key>Release Date</key><date>2007-09-18T07:00:00Z</date>\n";
95 testXML += " <key>Compilation</key><true/>\n";
96 testXML += " <key>Artwork Count</key><integer>1</integer>\n";
97 testXML += " <key>Sort Album</key><string>Swarm Riddim</string>\n";
98 testXML += " <key>Sort Name</key><string>Swarm</string>\n";
99 testXML += " <key>Persistent ID</key><string>D948F4FD9537100C</string>\n";
100 testXML += " <key>Explicit</key><true/>\n";
101 testXML += " <key>Track Type</key><string>File</string>\n";
102 testXML += " <key>Purchased</key><true/>\n";
103 testXML += " <key>Location</key><string>file://localhost/C:/Users/dbradley/Music/01%20The%20Swarm.m4a</string>\n";
104 testXML += " <key>File Folder Count</key><integer>-1</integer>\n";
105 testXML += " <key>Library Folder Count</key><integer>-1</integer>\n";
106 testXML += " </dict>\n";
107 testXML += " <key>80</key>\n";
108 testXML += " <dict>\n";
109 testXML += " <key>Track ID</key><integer>80</integer>\n";
110 testXML += " <key>Name</key><string>Analog Girl</string>\n";
111 testXML += " <key>Artist</key><string>Guy Clark</string>\n";
112 testXML += " <key>Album Artist</key><string>Guy Clark</string>\n";
113 testXML += " <key>Album</key><string>Workbench Songs</string>\n";
114 testXML += " <key>Genre</key><string>2</string>\n";
115 testXML += " <key>Kind</key><string>MPEG audio file</string>\n";
116 testXML += " <key>Size</key><integer>2052686</integer>\n";
117 testXML += " <key>Total Time</key><integer>51095</integer>\n";
118 testXML += " <key>Year</key><integer>2006</integer>\n";
119 testXML += " <key>Date Modified</key><date>2009-02-13T03:29:16Z</date>\n";
120 testXML += " <key>Date Added</key><date>2009-02-13T03:33:08Z</date>\n";
121 testXML += " <key>Bit Rate</key><integer>320</integer>\n";
122 testXML += " <key>Sample Rate</key><integer>44100</integer>\n";
123 testXML += " <key>Persistent ID</key><string>D948F4FD95371018</string>\n";
124 testXML += " <key>Track Type</key><string>File</string>\n";
125 testXML += " <key>Location</key><string>file://localhost/C:/Users/dbradley/Music/Guy-Clark-Analog-Girl.mp3</string>\n";
126 testXML += " <key>File Folder Count</key><integer>-1</integer>\n";
127 testXML += " <key>Library Folder Count</key><integer>-1</integer>\n";
128 testXML += " </dict>\n";
129 testXML += " </dict>\n";
130 testXML += " <key>Playlists</key>\n";
131 testXML += " <array>\n";
132 testXML += " <dict>\n";
133 testXML += " <key>Name</key><string>Library</string>\n";
134 testXML += " <key>Master</key><true/>\n";
135 testXML += " <key>Playlist ID</key><integer>126</integer>\n";
136 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2D9C</string>\n";
137 testXML += " <key>Visible</key><false/>\n";
138 testXML += " <key>All Items</key><true/>\n";
139 testXML += " <key>Playlist Items</key>\n";
140 testXML += " <array>\n";
141 testXML += " <dict>\n";
142 testXML += " <key>Track ID</key><integer>80</integer>\n";
143 testXML += " </dict>\n";
144 testXML += " <dict>\n";
145 testXML += " <key>Track ID</key><integer>62</integer>\n";
146 testXML += " </dict>\n";
147 testXML += " <dict>\n";
148 testXML += " <key>Track ID</key><integer>60</integer>\n";
149 testXML += " </dict>\n";
150 testXML += " </array>\n";
151 testXML += " </dict>\n";
152 testXML += " <dict>\n";
153 testXML += " <key>Name</key><string>Music</string>\n";
154 testXML += " <key>Playlist ID</key><integer>194</integer>\n";
155 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA6</string>\n";
156 testXML += " <key>Distinguished Kind</key><integer>4</integer>\n";
157 testXML += " <key>Music</key><true/>\n";
158 testXML += " <key>All Items</key><true/>\n";
159 testXML += " <key>Smart Info</key>\n";
160 testXML += " <data>\n";
161 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
162 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
163 testXML += " AAAAAA==\n";
164 testXML += " </data>\n";
165 testXML += " <key>Smart Criteria</key>\n";
166 testXML += " <data>\n";
167 testXML += " U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
168 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
169 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAQAAAAAAAAAAAAAAAAAAAAAAAAA\n";
170 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAABIbEAAAAAAAAAAAAAAAAAAAAB\n";
171 testXML += " AAAAAAABIbEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
172 testXML += " </data>\n";
173 testXML += " <key>Playlist Items</key>\n";
174 testXML += " <array>\n";
175 testXML += " <dict>\n";
176 testXML += " <key>Track ID</key><integer>80</integer>\n";
177 testXML += " </dict>\n";
178 testXML += " <dict>\n";
179 testXML += " <key>Track ID</key><integer>62</integer>\n";
180 testXML += " </dict>\n";
181 testXML += " </array>\n";
182 testXML += " </dict>\n";
183 testXML += " <dict>\n";
184 testXML += " <key>Name</key><string>Movies</string>\n";
185 testXML += " <key>Playlist ID</key><integer>229</integer>\n";
186 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA7</string>\n";
187 testXML += " <key>Distinguished Kind</key><integer>2</integer>\n";
188 testXML += " <key>Movies</key><true/>\n";
189 testXML += " <key>All Items</key><true/>\n";
190 testXML += " <key>Smart Info</key>\n";
191 testXML += " <data>\n";
192 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
193 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
194 testXML += " AAAAAA==\n";
195 testXML += " </data>\n";
196 testXML += " <key>Smart Criteria</key>\n";
197 testXML += " <data>\n";
198 testXML += " U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
199 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
200 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAgAAAAAAAAAAAAAAAAAAAAAAAAA\n";
201 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAgAYAAAAAAAAAAAAAAAAAAAAB\n";
202 testXML += " AAAAAAAAAAIAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
203 testXML += " </data>\n";
204 testXML += " <key>Playlist Items</key>\n";
205 testXML += " <array>\n";
206 testXML += " <dict>\n";
207 testXML += " <key>Track ID</key><integer>60</integer>\n";
208 testXML += " </dict>\n";
209 testXML += " </array>\n";
210 testXML += " </dict>\n";
211 testXML += " <dict>\n";
212 testXML += " <key>Name</key><string>TV Shows</string>\n";
213 testXML += " <key>Playlist ID</key><integer>233</integer>\n";
214 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA8</string>\n";
215 testXML += " <key>Distinguished Kind</key><integer>3</integer>\n";
216 testXML += " <key>TV Shows</key><true/>\n";
217 testXML += " <key>All Items</key><true/>\n";
218 testXML += " <key>Smart Info</key>\n";
219 testXML += " <data>\n";
220 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
221 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
222 testXML += " AAAAAA==\n";
223 testXML += " </data>\n";
224 testXML += " <key>Smart Criteria</key>\n";
225 testXML += " <data>\n";
226 testXML += " U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
227 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
228 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAgAAAAAAAAAAAAAAAAAAAAAAAAA\n";
229 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAgEQAAAAAAAAAAAAAAAAAAAAB\n";
230 testXML += " AAAAAAAAAEAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
231 testXML += " </data>\n";
232 testXML += " </dict>\n";
233 testXML += " <dict>\n";
234 testXML += " <key>Name</key><string>Podcasts</string>\n";
235 testXML += " <key>Playlist ID</key><integer>187</integer>\n";
236 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA5</string>\n";
237 testXML += " <key>Distinguished Kind</key><integer>10</integer>\n";
238 testXML += " <key>Podcasts</key><true/>\n";
239 testXML += " <key>All Items</key><true/>\n";
240 testXML += " </dict>\n";
241 testXML += " <dict>\n";
242 testXML += " <key>Name</key><string>Audiobooks</string>\n";
243 testXML += " <key>Playlist ID</key><integer>236</integer>\n";
244 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA9</string>\n";
245 testXML += " <key>Distinguished Kind</key><integer>5</integer>\n";
246 testXML += " <key>Audiobooks</key><true/>\n";
247 testXML += " <key>All Items</key><true/>\n";
248 testXML += " <key>Smart Info</key>\n";
249 testXML += " <data>\n";
250 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
251 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
252 testXML += " AAAAAA==\n";
253 testXML += " </data>\n";
254 testXML += " <key>Smart Criteria</key>\n";
255 testXML += " <data>\n";
256 testXML += " U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
257 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
258 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAgAAAAAAAAAAAAAAAAAAAAAAAAA\n";
259 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAgAwAAAAAAAAAAAAAAAAAAAAB\n";
260 testXML += " AAAAAAAAAAgAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
261 testXML += " </data>\n";
262 testXML += " </dict>\n";
263 testXML += " <dict>\n";
264 testXML += " <key>Name</key><string>iTunes DJ</string>\n";
265 testXML += " <key>Playlist ID</key><integer>184</integer>\n";
266 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA3</string>\n";
267 testXML += " <key>Distinguished Kind</key><integer>22</integer>\n";
268 testXML += " <key>Party Shuffle</key><true/>\n";
269 testXML += " <key>All Items</key><true/>\n";
270 testXML += " </dict>\n";
271 testXML += " <dict>\n";
272 testXML += " <key>Name</key><string>Genius</string>\n";
273 testXML += " <key>Playlist ID</key><integer>245</integer>\n";
274 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DAC</string>\n";
275 testXML += " <key>Distinguished Kind</key><integer>26</integer>\n";
276 testXML += " <key>All Items</key><true/>\n";
277 testXML += " </dict>\n";
278 testXML += " <dict>\n";
279 testXML += " <key>Name</key><string>90's Music</string>\n";
280 testXML += " <key>Playlist ID</key><integer>162</integer>\n";
281 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2D9D</string>\n";
282 testXML += " <key>All Items</key><true/>\n";
283 testXML += " <key>Smart Info</key>\n";
284 testXML += " <data>\n";
285 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
286 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
287 testXML += " AAAAAA==\n";
288 testXML += " </data>\n";
289 testXML += " <key>Smart Criteria</key>\n";
290 testXML += " <data>\n";
291 testXML += " U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
292 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
293 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAEAAAAAAAAAAAAAAAAAAAAAAAAA\n";
294 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAB8YAAAAAAAAAAAAAAAAAAAAB\n";
295 testXML += " AAAAAAAAB88AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5AgAAAQAA\n";
296 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAB\n";
297 testXML += " AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA\n";
298 testXML += " AAAAAAAA\n";
299 testXML += " </data>\n";
300 testXML += " </dict>\n";
301 testXML += " <dict>\n";
302 testXML += " <key>Name</key><string>Music Videos</string>\n";
303 testXML += " <key>Playlist ID</key><integer>181</integer>\n";
304 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA2</string>\n";
305 testXML += " <key>All Items</key><true/>\n";
306 testXML += " <key>Smart Info</key>\n";
307 testXML += " <data>\n";
308 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
309 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
310 testXML += " AAAAAA==\n";
311 testXML += " </data>\n";
312 testXML += " <key>Smart Criteria</key>\n";
313 testXML += " <data>\n";
314 testXML += " U0xzdAABAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
315 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
316 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAQAAAAAAAAAAAAAAAAAAAAAAAAA\n";
317 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAB\n";
318 testXML += " AAAAAAAAACAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
319 testXML += " </data>\n";
320 testXML += " </dict>\n";
321 testXML += " <dict>\n";
322 testXML += " <key>Name</key><string>My Top Rated</string>\n";
323 testXML += " <key>Playlist ID</key><integer>165</integer>\n";
324 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2D9E</string>\n";
325 testXML += " <key>All Items</key><true/>\n";
326 testXML += " <key>Smart Info</key>\n";
327 testXML += " <data>\n";
328 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
329 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
330 testXML += " AAAAAA==\n";
331 testXML += " </data>\n";
332 testXML += " <key>Smart Criteria</key>\n";
333 testXML += " <data>\n";
334 testXML += " U0xzdAABAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
335 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
336 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkAAAAQAAAAAAAAAAAAAAAAAAAAAAAA\n";
337 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAB\n";
338 testXML += " AAAAAAAAADwAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n";
339 testXML += " </data>\n";
340 testXML += " </dict>\n";
341 testXML += " <dict>\n";
342 testXML += " <key>Name</key><string>Recently Added</string>\n";
343 testXML += " <key>Playlist ID</key><integer>174</integer>\n";
344 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA1</string>\n";
345 testXML += " <key>All Items</key><true/>\n";
346 testXML += " <key>Smart Info</key>\n";
347 testXML += " <data>\n";
348 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
349 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
350 testXML += " AAAAAA==\n";
351 testXML += " </data>\n";
352 testXML += " <key>Smart Criteria</key>\n";
353 testXML += " <data>\n";
354 testXML += " U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
355 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
356 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAIAAAAAAAAAAAAAAAAAAAAAAAAA\n";
357 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABELa4tri2uLa7//////////gAAAAAACTqA\n";
358 testXML += " La4tri2uLa4AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5AgAAAQAA\n";
359 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAB\n";
360 testXML += " AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA\n";
361 testXML += " AAAAAAAA\n";
362 testXML += " </data>\n";
363 testXML += " <key>Playlist Items</key>\n";
364 testXML += " <array>\n";
365 testXML += " </array>\n";
366 testXML += " </dict>\n";
367 testXML += " <dict>\n";
368 testXML += " <key>Name</key><string>Recently Played</string>\n";
369 testXML += " <key>Playlist ID</key><integer>171</integer>\n";
370 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2DA0</string>\n";
371 testXML += " <key>All Items</key><true/>\n";
372 testXML += " <key>Smart Info</key>\n";
373 testXML += " <data>\n";
374 testXML += " AQEAAwAAAAIAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
375 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
376 testXML += " AAAAAA==\n";
377 testXML += " </data>\n";
378 testXML += " <key>Smart Criteria</key>\n";
379 testXML += " <data>\n";
380 testXML += " U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
381 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
382 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABcAAAIAAAAAAAAAAAAAAAAAAAAAAAAA\n";
383 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABELa4tri2uLa7//////////gAAAAAACTqA\n";
384 testXML += " La4tri2uLa4AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5AgAAAQAA\n";
385 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAB\n";
386 testXML += " AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA\n";
387 testXML += " AAAAAAAA\n";
388 testXML += " </data>\n";
389 testXML += " </dict>\n";
390 testXML += " <dict>\n";
391 testXML += " <key>Name</key><string>Top 25 Most Played</string>\n";
392 testXML += " <key>Playlist ID</key><integer>168</integer>\n";
393 testXML += " <key>Playlist Persistent ID</key><string>4901D1E2BA4B2D9F</string>\n";
394 testXML += " <key>All Items</key><true/>\n";
395 testXML += " <key>Smart Info</key>\n";
396 testXML += " <data>\n";
397 testXML += " AQEBAwAAABkAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
398 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
399 testXML += " AAAAAA==\n";
400 testXML += " </data>\n";
401 testXML += " <key>Smart Criteria</key>\n";
402 testXML += " <data>\n";
403 testXML += " U0xzdAABAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
404 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
405 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADkCAAABAAAAAAAAAAAAAAAAAAAAAAAA\n";
406 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAB\n";
407 testXML += " AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAAAEAAA\n";
408 testXML += " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAA\n";
409 testXML += " AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAA\n";
410 testXML += " AAAAAAAA\n";
411 testXML += " </data>\n";
412 testXML += " </dict>\n";
413 testXML += " </array>\n";
414 testXML += "</dict>\n";
415 testXML += "</plist>\n";
416 
417 //------------------------------------------------------------------------------
418 //------------------------------------------------------------------------------
419 //
420 // iTunes importer unit tests.
421 //
422 //------------------------------------------------------------------------------
423 //------------------------------------------------------------------------------
424 
429 function stringToStream(aString) {
430  stream =
431  Cc["@mozilla.org/io/string-input-stream;1"]
432  .createInstance(Ci.nsIStringInputStream);
433  stream.setData(aString, -1);
434  return stream;
435 }
436 
437 function runTest() {
441  var listener = {
442  expectedTopLevelProperties : [ "Major Version",
443  "Minor Version",
444  "Application Version",
445  "Features",
446  "Show Content Ratings",
447  "Music Folder",
448  "Library Persistent ID" ],
449  onTopLevelProperties : function(aProperties) {
450  var length = this.expectedTopLevelProperties.length;
451  this.topLevelPropertyCount = 0;
452  for (var index =0; index < length; ++index) {
453  try {
454  if (aProperties.get(this.expectedTopLevelProperties[index]).length > 0) {
455  ++this.topLevelPropertyCount;
456  }
457  }
458  catch (e) {
459  }
460  }
461  },
462  onTrack : function(aProperties) {
463  ++this.onTrackCount;
464  },
465  onTracksComplete : function() {
466  ++this.onTracksCompleteCount;
467  },
468  onPlaylist : function(aProperties, tracks) {
469  ++this.onPlaylistCount;
470  },
471  onPlaylistsComplete : function () {
472  ++this.onPlaylistsCompleteCount;
473  assertEqual(this.topLevelPropertyCount, 7, "Top level properties do not match");
474  assertEqual(this.onTrackCount, 2, "Invalid track count");
475  assertEqual(this.onTracksCompleteCount, 1, "Invalid track complete count");
476  assertEqual(this.onPlaylistCount, 14, "Invalid playlist count");
477  assertEqual(this.onPlaylistsCompleteCount, 1, "Invalid playlist complete count");
478  assertEqual(this.onErrorCount, 0, "Invalid error count");
479  testFinished();
480  },
481  onError : function(aErrorMessage) {
482  ++this.onErrorCount;
483  fail("onError called on non-error test case");
484  },
485  onProgress : function() { /* nothing */ },
486  topLevelPropertyCount : 0,
487  onTrackCount : 0,
488  onTracksCompleteCount : 0,
489  onPlaylistCount : 0,
490  onPlaylistsCompleteCount : 0,
491  onErrorCount : 0,
492 
493  QueryInterface: XPCOMUtils.generateQI([Ci.sbIiTunesXMLParserListener])
494  };
495 
496  // Test error condition
497  var parser = Cc["@songbirdnest.com/Songbird/sbiTunesXMLParser;1"]
498  .getService(Ci.sbIiTunesXMLParser);
499  assertTrue(parser, "iTunes importer component is not available.");
500 
501  // Test normal xml data
502  parser = Cc["@songbirdnest.com/Songbird/sbiTunesXMLParser;1"]
503  .getService(Ci.sbIiTunesXMLParser);
504  assertTrue(parser, "iTunes importer component is not available.");
505  parser.parse(stringToStream(testXML), listener);
506  testPending();
507  parser = null; // drop the reference to prevent leaks
508 }
const Cc
function fail(aMessage)
function testFinished()
sbOSDControlService prototype QueryInterface
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
return null
Definition: FeedWriter.js:1143
function stringToStream(aString)
const Ci
function runTest()
Advanced DataRemote unit tests.
function testPending()