test_onitemupdated.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 function runTest () {
32 
33  var SB_PROP_ARTISTNAME = "http://songbirdnest.com/data/1.0#artistName";
34 
35  var library = createLibrary("test_onitemupdated", null, true);
36 
37  var listener = {
38  properties: null,
39  onItemAdded: function(list, item, index) {},
40  onBeforeItemRemoved: function(list, item, index) {},
41  onAfterItemRemoved: function(list, item, index) {},
42  onItemUpdated: function(list, item, properties) {
43  this.properties = properties;
44  },
45  onItemMoved: function(list, fromIndex, toIndex) {},
46  onBeforeListCleared: function(list, excludeLists) {},
47  onListCleared: function(list, excludeLists) {},
48  onBatchBegin: function(list) {},
49  onBatchEnd: function(list) {}
50  };
51 
52  library.addListener(listener, false);
53  var item = library.createMediaItem(newURI("http://foo.com/foo.mp3"));
54 
55  var value = "The Rolling Stones";
56  item.setProperty(SB_PROP_ARTISTNAME, value);
57 
58  // Item had no previous artist name property so the old value should be
59  // an empty string. This will change to null once we have IsVoid/SetVoid
60  var prop = listener.properties.getPropertyAt(0);
61  assertEqual(prop.id, SB_PROP_ARTISTNAME);
62  assertEqual(prop.value, null);
63 
64  item.setProperty(SB_PROP_ARTISTNAME, "The Bealtes");
65 
66  prop = listener.properties.getPropertyAt(0);
67  assertEqual(prop.id, SB_PROP_ARTISTNAME);
68  assertEqual(prop.value, value);
69 
70  library.removeListener(listener);
71 }
72 
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Test file.
return null
Definition: FeedWriter.js:1143
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
function newURI(aURLString)
countRef value
Definition: FeedWriter.js:1423