Bug 441233 Missing focus events in Thunderbird account wizard dialog r=surkov.alexander
[wine-gecko.git] / storage / test / unit / test_storage_fulltextindex.js
blobe8542aa8f4130c49cffdb5049e5500203ee90cd3
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is Storage Test Code.
16 * The Initial Developer of the Original Code is
17 * Mozilla Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2008
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Myk Melez <myk@mozilla.org> (Original Author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 // This file tests support for the fts3 (full-text index) module.
40 // Example statements in these tests are taken from the Full Text Index page
41 // on the SQLite wiki: http://www.sqlite.org/cvstrac/wiki?p=FullTextIndex
43 function test_table_creation()
45 var msc = getOpenedDatabase(true);
47 msc.executeSimpleSQL(
48 "CREATE VIRTUAL TABLE recipe USING fts3(name, ingredients)");
50 do_check_true(msc.tableExists("recipe"));
53 function test_insertion()
55 var msc = getOpenedDatabase(true);
57 msc.executeSimpleSQL("INSERT INTO recipe (name, ingredients) VALUES " +
58 "('broccoli stew', 'broccoli peppers cheese tomatoes')");
59 msc.executeSimpleSQL("INSERT INTO recipe (name, ingredients) VALUES " +
60 "('pumpkin stew', 'pumpkin onions garlic celery')");
61 msc.executeSimpleSQL("INSERT INTO recipe (name, ingredients) VALUES " +
62 "('broccoli pie', 'broccoli cheese onions flour')");
63 msc.executeSimpleSQL("INSERT INTO recipe (name, ingredients) VALUES " +
64 "('pumpkin pie', 'pumpkin sugar flour butter')");
66 var stmt = msc.createStatement("SELECT COUNT(*) FROM recipe");
67 stmt.executeStep();
69 do_check_eq(stmt.getInt32(0), 4);
71 stmt.reset();
72 stmt.finalize();
75 function test_selection()
77 var msc = getOpenedDatabase(true);
79 var stmt = msc.createStatement(
80 "SELECT rowid, name, ingredients FROM recipe WHERE name MATCH 'pie'");
82 do_check_true(stmt.executeStep());
83 do_check_eq(stmt.getInt32(0), 3);
84 do_check_eq(stmt.getString(1), "broccoli pie");
85 do_check_eq(stmt.getString(2), "broccoli cheese onions flour");
87 do_check_true(stmt.executeStep());
88 do_check_eq(stmt.getInt32(0), 4);
89 do_check_eq(stmt.getString(1), "pumpkin pie");
90 do_check_eq(stmt.getString(2), "pumpkin sugar flour butter");
92 do_check_false(stmt.executeStep());
94 stmt.reset();
95 stmt.finalize();
98 var tests = [test_table_creation, test_insertion, test_selection];
100 function run_test()
102 // It's extra important to start from scratch, since these tests won't work
103 // with an existing shared cache connection, so we do it even though the last
104 // test probably did it already.
105 cleanup();
107 try {
108 for (var i = 0; i < tests.length; i++) {
109 tests[i]();
112 // It's extra important to clean up afterwards, since later tests that use
113 // a shared cache connection will not be able to read the database we create,
114 // so we do this in a finally block to ensure it happens even if some of our
115 // tests fail.
116 finally {
117 cleanup();