test_propertymanager_dependencies.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 
29 function runTest () {
30  Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
31  var propMan = Cc["@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
32  .getService(Ci.sbIPropertyManager);
33 
34  // Sorting by album will sort by album->disc no->track no->track name
35  // Sorting by artist will sort by artist->album->disc no->track no->track name
36  // Sorting by albumartist will sort by albumartist->album->disc no->track no->track name
37  // Sorting by genre will sort by genre->artist->album->disc no->track no->track name
38  // Sorting by year will sort by year->artist->album->disc no->track no->track name
39  // Sorting by track number will sort by track no->artist->album->disc no
40  // Sorting by disc number will sort by disc no->artist->album->track no->track name
41 
42  // Expect track name to return album, artist
43  var deps = propMan.getDependentProperties(SBProperties.trackName);
45  [SBProperties.albumName,
46  SBProperties.artistName,
47  SBProperties.albumArtistName,
48  SBProperties.genre,
49  SBProperties.year,
50  SBProperties.discNumber]);
51 
52  // Expect album to return artist, albumartist, genre, year
53  deps = propMan.getDependentProperties(SBProperties.albumName);
55  [SBProperties.artistName,
56  SBProperties.albumArtistName,
57  SBProperties.genre,
58  SBProperties.year,
59  SBProperties.discNumber,
60  SBProperties.trackNumber]);
61 
62  // Expect artist to return genre, year
63  deps = propMan.getDependentProperties(SBProperties.artistName);
65  [SBProperties.genre,
66  SBProperties.year,
67  SBProperties.discNumber,
68  SBProperties.trackNumber]);
69 
70  // Expect contentURL to return nothing
71  deps = propMan.getDependentProperties(SBProperties.contentURL);
73 }
74 
75 
80 function assertPropertyArrayContains(aProps, aExpected) {
81  assertEqual(aProps.length, aExpected.length);
82  aProps = SBProperties.arrayToJSObject(aProps);
83  for each (var prop in aExpected) {
84  assertTrue(prop in aProps);
85  }
86 }
const Cc
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Test file.
const Ci
function assertPropertyArrayContains(aProps, aExpected)