test_fts.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_fts", null, false);
36  library.clear();
37  library.flush();
38 
39  /* XXXAus: See bug 9488 and bug 9617
40  assertEqual(countFtsRows("foo"), 0);
41  assertEqual(countFtsRows("bar"), 0);
42  */
43  assertEqual(countFtsAllRows("foo"), 0);
44  assertEqual(countFtsAllRows("bar"), 0);
45 
46  var item = library.createMediaItem(newURI("http://example.com/zoo.mp3"));
47  item.setProperty(SBProperties.albumName, "foo");
48  library.flush();
49 
50  /* XXXAus: See bug 9488 and bug 9617
51  assertEqual(countFtsRows("foo"), 1);
52  assertEqual(countFtsRows("bar"), 0);
53  */
54  assertEqual(countFtsAllRows("foo"), 1);
55  assertEqual(countFtsAllRows("bar"), 0);
56 
57  item.setProperty(SBProperties.albumName, "bar");
58  library.flush();
59 
60  /* XXXAus: See bug 9488 and bug 9617
61  assertEqual(countFtsRows("foo"), 0);
62  assertEqual(countFtsRows("bar"), 1);
63  */
64  assertEqual(countFtsAllRows("foo"), 0);
65  assertEqual(countFtsAllRows("bar"), 1);
66 
67  item.setProperty(SBProperties.artistName, "foo");
68  library.flush();
69 
70  /* XXXAus: See bug 9488 and bug 9617
71  assertEqual(countFtsRows("foo"), 1);
72  assertEqual(countFtsRows("bar"), 1);
73  */
74  assertEqual(countFtsAllRows("foo"), 1);
75  assertEqual(countFtsAllRows("bar"), 1);
76 
77  library.remove(item);
78  library.flush();
79 
80  /* XXXAus: See bug 9488 and bug 9617
81  assertEqual(countFtsRows("foo"), 0);
82  assertEqual(countFtsRows("bar"), 0);
83  */
84  assertEqual(countFtsAllRows("foo"), 0);
85  assertEqual(countFtsAllRows("bar"), 0);
86 }
87 
88 /*
89 
90 XXXAus: Because of bug 9488, we had to disable search against specific
91  properties. See bug 9617 for more info.
92 
93 function countFtsRows(obj) {
94  var dbq = Cc["@songbirdnest.com/Songbird/DatabaseQuery;1"]
95  .createInstance(Ci.sbIDatabaseQuery);
96 
97  dbq.setDatabaseGUID("test_fts");
98  dbq.addQuery("select count(1) from resource_properties_fts where obj = '" + obj + "'");
99  dbq.execute();
100 
101  var dbr = dbq.getResultObject();
102  return parseInt(dbr.getRowCell(0, 0));
103 }
104 
105 */
106 
107 function countFtsAllRows(obj) {
108  var dbq = Cc["@songbirdnest.com/Songbird/DatabaseQuery;1"]
109  .createInstance(Ci.sbIDatabaseQuery);
110 
111  dbq.setDatabaseGUID("test_fts");
112  dbq.addQuery("select count(1) from resource_properties_fts_all where alldata match '" + obj + "'");
113  dbq.execute();
114 
115  var dbr = dbq.getResultObject();
116  return parseInt(dbr.getRowCell(0, 0));
117 }
const Cc
function countFtsAllRows(obj)
Definition: test_fts.js:107
function assertEqual(aExpected, aActual, aMessage)
return null
Definition: FeedWriter.js:1143
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
function newURI(aURLString)
const Ci
function runTest()
Test file.
Definition: test_fts.js:31