test_library_properties.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  Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
34 
35  var library = createLibrary("test_library_properties", null, false);
36  library.clear();
37 
38  assertTrue(library.created > 0);
39  assertTrue(library.updated > 0);
40  assertTrue(library.contentSrc.schemeIs("file"));
41  assertEqual(library.getProperty(SBProperties.hidden), "0");
42 
43  var uniqueString = (new Date()).getTime();
44  library.setProperty(SBProperties.contentType, uniqueString);
45  assertEqual(library.getProperty(SBProperties.contentType), uniqueString);
46  library.setProperty(SBProperties.albumName, uniqueString);
47  assertEqual(library.getProperty(SBProperties.albumName), uniqueString);
48 
49  // Library properties should survive a clear
50  library.clear();
51 
52  library.flush();
53  library = null;
54 
55  // file copy the database file so we can open it again
56  var directory = Cc["@mozilla.org/file/directory_service;1"].
57  getService(Ci.nsIProperties).
58  get("ProfD", Ci.nsIFile);
59  directory.append("db");
60 
61  var dest = directory.clone();
62  dest.append("test_library_properties2.db");
63  if (dest.exists()) {
64  dest.remove(false);
65  }
66 
67  var src = directory.clone();
68  src.append("test_library_properties.db");
69  src.copyTo(directory, dest.leafName);
70 
71  var library2 = createLibrary("test_library_properties2", null, false);
72  assertTrue(library2.created > 0);
73  assertTrue(library2.updated > 0);
74  assertTrue(library2.contentSrc.schemeIs("file"));
75  assertEqual(library2.getProperty(SBProperties.hidden), "0");
76  assertEqual(library2.getProperty(SBProperties.contentType), uniqueString);
77  assertEqual(library2.getProperty(SBProperties.albumName), uniqueString);
78 }
79 
const Cc
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
getService(Ci.sbIFaceplateManager)
function runTest()
Test file.
return null
Definition: FeedWriter.js:1143
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
const Ci