test_localizationkey.js
Go to the documentation of this file.
1 /* vim: set sw=2 :*/
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2009 POTI, Inc.
9 // http://songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the "GPL").
13 //
14 // Software distributed under the License is distributed
15 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 // END SONGBIRD GPL
25 //
26 */
27 
28 Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
29 
34 function runTest () {
35 
36  // list of property localization keys found in SBProperties.jsm
37  var localizationKeys = {
38  ordinal: 'ordinal',
39  created: 'date_created',
40  updated: 'date_updated',
41  contentURL: 'content_url',
42  contentType: 'content_type',
43  contentLength: 'content_length',
44  hash: 'content_hash',
45  trackName: 'track_name',
46  albumName: 'album_name',
47  artistName: 'artist_name',
48  trackType: 'track_source',
49  duration: 'duration',
50  genre: 'genre',
51  year: 'year',
52  trackNumber: 'track_no',
53  discNumber: 'disc_no',
54  totalDiscs: 'total_discs',
55  totalTracks: 'total_tracks',
56  isPartOfCompilation: 'is_part_of_compilation',
57  producerName: 'producer',
58  composerName: 'composer',
59  conductorName: 'conductor',
60  lyricistName: 'lyricist',
61  lyrics: 'lyrics',
62  recordLabelName: 'record_label_name',
63  primaryImageURL: 'primary_image_url',
64  lastPlayTime: 'last_play_time',
65  playCount: 'play_count',
66  lastSkipTime: 'last_skip_time',
67  skipCount: 'skip_count',
68  bitRate: 'bitrate',
69  sampleRate: 'samplerate',
70  channels: 'channels',
71  bpm: 'bpm',
72  key: 'key',
73  language: 'language',
74  comment: 'comment',
75  copyright: 'copyright',
76  copyrightURL: 'copyright_url',
77  subtitle: 'subtitle',
78  metadataUUID: 'metadata_uuid',
79  softwareVendor: 'vendor',
80  originURL: 'origin_url',
81  destination: 'destination',
82  hidden: 'hidden',
83  columnSpec: 'column_spec',
84  defaultColumnSpec: 'default_column_spec',
85  originPage: 'origin_page',
86  artistDetailUrl: 'artist_detail_url',
87  albumDetailUrl: 'album_detail_url',
88  originPageTitle: 'origin_pagetitle',
89  downloadButton: 'download_button',
90  downloadDetails: 'download_details',
91  rating: 'rating',
92  originPageImage: 'origin_page_image',
93  artistDetailImage: 'artist_detail_image',
94  albumDetailImage: 'album_detail_image',
95  rapiScopeURL: 'rapi_scope_url',
96  rapiSiteID: 'rapi_site_id',
97  mediaListName: 'media_list_name',
98  defaultMediaPageURL: 'default_mediapage_url',
99  availability: 'availability',
100  albumArtistName: 'albumartistname',
101  cdRipStatus: 'cdrip_status',
102  shouldRip: 'shouldrip',
103  keywords: 'keywords',
104  description: 'description',
105  showName: 'showName',
106  episodeNumber: 'episodeNumber',
107  seasonNumber: 'seasonNumber',
108  playlistURL: 'playlist_url',
109  metadataHashIdentity: 'metadata_hash_identity'
110  };
111 
112  // list of properties with localization keys, but not in SBProperties.jsm
113  var specialLocalizationKeys = {
114  "http://songbirdnest.com/dummy/smartmedialists/1.0#playlist":
115  "property.dummy.playlist",
116  };
117 
118  var propMgr =
119  Components.classes["@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
120  .getService(Components.interfaces.sbIPropertyManager);
121  var info;
122 
123  // test the properties found in SBProperties.jsm
124  for (var prop in localizationKeys) {
125  info = propMgr.getPropertyInfo(SBProperties[prop]);
126  try {
127  assertEqual("property." + localizationKeys[prop],
128  info.localizationKey,
129  "Property does not have expected localization info");
130  } catch (e if e == Cr.NS_ERROR_ABORT) {
131  // keep going; this will cause the run to fail anyway
132  }
133  }
134 
135  // test the properties not in SBProperties.jsm
136  var propEnum = propMgr.propertyIDs;
137  while (propEnum.hasMore()) {
138  var propID = propEnum.getNext();
139  var propName = propID.replace(SBProperties.base, "");
140  if (propName in localizationKeys) {
141  // found in SBProperties.jsm, see list above
142  continue;
143  }
144  info = propMgr.getPropertyInfo(propID);
145  try {
146  if (propID in specialLocalizationKeys) {
147  // this is a special non-standard property, yay.
148  assertEqual(specialLocalizationKeys[propID],
149  info.localizationKey,
150  "Property does not have expected special localization info");
151  } else {
152  // property with no explicit localization key, should be default
153  assertEqual(propID, info.localizationKey,
154  "Property has unknown custom localization info");
155  }
156  } catch (e if e == Cr.NS_ERROR_ABORT) {
157  // keep going; this will cause the run to fail anyway
158  }
159  }
160 }
dataSBHighestRatedArtists SBProperties rating
Definition: tuner2.js:867
var language
Definition: Info.js:44
function assertEqual(aExpected, aActual, aMessage)
const char * propName
_hideDatepicker duration
BogusChannel prototype contentLength
function runTest()
Advanced DataRemote unit tests.
function hash(str)
Definition: sbAboutDRM.js:40
var getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('Songbird SBProperties playCount
Definition: tuner2.js:40
const Cr
var hidden