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_tree_collate");
61 dbq.addQuery(
"drop table test_collate");
62 dbq.addQuery(
"create table test_collate (id text, ordinal text unique collate tree)");
64 dbq.waitForCompletion();
71 insert(dbq,
"4",
"......");
93 return Components.results.NS_OK;
98 dbq.addQuery(
"insert into test_collate values ('" +
id +
"', '" + ordinal +
"')");
101 dbq.addQuery(
"insert into test_collate values ('" +
id +
"', null)");
104 dbq.waitForCompletion();
109 dbq.addQuery(
"delete from test_collate");
111 dbq.waitForCompletion();
116 dbq.addQuery(
"select id from test_collate order by ordinal asc");
118 dbq.waitForCompletion();
119 var r = dbq.getResultObject();
120 var rows = r.getRowCount();
121 if (rows != a.length) {
122 fail(
"query returned " + rows +
" rows, array length is " + a.length);
125 for (var
i = 0;
i < rows;
i++) {
139 if (index == a.length) {
148 insert(dbq,
id, belowPath +
".0");
153 var below = belowPath.split(
".");
154 var above = abovePath.split(
".");
155 if (below.length == above.length) {
156 insert(dbq,
id, belowPath +
".0");
159 if (below.length > above.length) {
160 below[below.length - 1] = parseInt(below[below.length - 1]) - 1;
161 insert(dbq,
id, below.join(
"."));
164 above[above.length - 1] = parseInt(above[above.length - 1]) + 1;
165 insert(dbq,
id, above.join(
"."));
169 a.splice(index, 0,
id);
179 dbq.addQuery(
"select ordinal from test_collate order by ordinal asc limit 1 offset " + index);
181 dbq.waitForCompletion();
182 var r = dbq.getResultObject();
183 var
path = r.getRowCell(0, 0);
function assertTable(dbq, a)
function assertEqual(aExpected, aActual, aMessage)
function insertAt(dbq, a, id, index)
function getPathFromIndex(dbq, index)
function insert(dbq, id, ordinal)
function runTest()
Test file.
_getSelectedPageStyle s i