33 var dbq =
Cc[
"@songbirdnest.com/Songbird/DatabaseQuery;1"]
34 .createInstance(
Ci.sbIDatabaseQuery);
36 var
ios =
Cc[
"@mozilla.org/network/io-service;1"]
37 .createInstance(
Ci.nsIIOService);
39 var
dir =
Cc[
"@mozilla.org/file/directory_service;1"]
40 .createInstance(
Ci.nsIProperties);
42 var testdir = dir.get(
"ProfD",
Ci.nsIFile);
44 var actualdir = testdir.clone();
45 actualdir.append(
"db_tests");
47 if(!actualdir.exists())
50 actualdir.create(
Ci.nsIFile.DIRECTORY_TYPE, 0700);
57 var
uri = ios.newFileURI(actualdir);
58 dbq.databaseLocation =
uri;
60 dbq.setDatabaseGUID(
"test_rollinglimit");
61 dbq.addQuery(
"drop table test_rollinglimit");
62 dbq.addQuery(
"create table test_rollinglimit (size integer, name text)");
69 insert(dbq,
"4",
"maggie");
75 dbq.rollingLimitColumnIndex = 0;
76 dbq.addQuery(
"select size, name from test_rollinglimit order by name");
79 var r = dbq.getResultObject();
80 var rows = r.getRowCount();
88 dbq.rollingLimit = 100;
89 dbq.rollingLimitColumnIndex = 0;
90 dbq.addQuery(
"select size, name from test_rollinglimit order by name");
93 var r = dbq.getResultObject();
94 var rows = r.getRowCount();
100 dbq.rollingLimitColumnIndex = 0;
101 dbq.addQuery(
"select size, name from test_rollinglimit order by name desc");
104 var r = dbq.getResultObject();
105 var rows = r.getRowCount();
113 dbq.addQuery(
"insert into test_rollinglimit values ('" + size +
"', '" +
name +
"')");
function runTest()
Test file.
function assertEqual(aExpected, aActual, aMessage)
function insert(dbq, size, name)