summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/sql/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/sql/data')
-rw-r--r--tests/auto/declarative/sql/data/1-creation.js27
-rw-r--r--tests/auto/declarative/sql/data/2-selection-bindnames.js32
-rw-r--r--tests/auto/declarative/sql/data/2-selection.js41
-rw-r--r--tests/auto/declarative/sql/data/3-iteration-item-function.js38
-rw-r--r--tests/auto/declarative/sql/data/4-iteration-index.js38
-rw-r--r--tests/auto/declarative/sql/data/5-iteration-iterator.js38
-rw-r--r--tests/auto/declarative/sql/data/6-iteration-efficient.js43
-rw-r--r--tests/auto/declarative/sql/data/7a-error.js20
8 files changed, 123 insertions, 154 deletions
diff --git a/tests/auto/declarative/sql/data/1-creation.js b/tests/auto/declarative/sql/data/1-creation.js
index 95fa99e..aab9b5d 100644
--- a/tests/auto/declarative/sql/data/1-creation.js
+++ b/tests/auto/declarative/sql/data/1-creation.js
@@ -1,20 +1,15 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r="transaction_not_finished";
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-// Asynchronous in WebKit, so must wait before calling test()
-db.transaction(
- function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)', [],
- function(tx, rs) { }, function(tx, error) { r="CREATE FAILED: "+error.message });
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ],
- function(tx, rs) { }, function(tx, error) { r="INSERT FAILED: "+error.message });
- },
- function(tx, error) { r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r=="transaction_not_finished") r="passed" }
-);
+ // Asynchronous in WebKit, so must wait before calling test()
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ r = "passed";
+ }
+ );
-
-function test()
-{
return r;
}
diff --git a/tests/auto/declarative/sql/data/2-selection-bindnames.js b/tests/auto/declarative/sql/data/2-selection-bindnames.js
index c00acc14..21f34db 100644
--- a/tests/auto/declarative/sql/data/2-selection-bindnames.js
+++ b/tests/auto/declarative/sql/data/2-selection-bindnames.js
@@ -1,24 +1,16 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('SELECT * FROM Greeting WHERE salutation=:p2 AND salutee=:p1', {':p1':'world', ':p2':'hello'},
- function(tx, rs) {
- if ( rs.rows.length != 4 ) {
- if (r==0) r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows.item(0)+rs.rows.item(1)
- }
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
-);
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM Greeting WHERE salutation=:p2 AND salutee=:p1', {':p1':'world', ':p2':'hello'});
+ if ( rs.rows.length != 4 )
+ r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows.item(0)+rs.rows.item(1)
+ else
+ r = "passed";
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/2-selection.js b/tests/auto/declarative/sql/data/2-selection.js
index 3acf686..f141d2c 100644
--- a/tests/auto/declarative/sql/data/2-selection.js
+++ b/tests/auto/declarative/sql/data/2-selection.js
@@ -1,30 +1,19 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ],
- function(tx, rs) { }, function(tx, error) { if (r==0) r="INSERT 1 FAILED: "+error.message });
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ],
- function(tx, rs) { }, function(tx, error) { if (r==0) r="INSERT 2 FAILED: "+error.message });
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ],
- function(tx, rs) { }, function(tx, error) { if (r==0) r="INSERT 3 FAILED: "+error.message });
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- if ( rs.rows.length != 4 ) { // 1 from test1, 3 from this test.
- if (r==0) r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows[0]+rs.rows[1]
- }
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
-);
+ db.transaction(
+ function(tx) {
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+ if ( rs.rows.length != 4 ) // 1 from test1, 3 from this test.
+ r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows[0]+rs.rows[1]
+ else
+ r = "passed";
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/3-iteration-item-function.js b/tests/auto/declarative/sql/data/3-iteration-item-function.js
index bad9b82..57c8a17 100644
--- a/tests/auto/declarative/sql/data/3-iteration-item-function.js
+++ b/tests/auto/declarative/sql/data/3-iteration-item-function.js
@@ -1,27 +1,19 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- var r1=""
- for(var i = 0; i < rs.rows.length; i++) {
- r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";"
- }
- if (r1 != "hello, world;hello, world;hello, world;hello, world;")
- r = "SELECTED DATA WRONG: "+r1;
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
-);
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+ var r1=""
+ for(var i = 0; i < rs.rows.length; i++)
+ r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";"
+ if (r1 != "hello, world;hello, world;hello, world;hello, world;")
+ r = "SELECTED DATA WRONG: "+r1;
+ else
+ r = "passed";
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/4-iteration-index.js b/tests/auto/declarative/sql/data/4-iteration-index.js
index 298737d..512cf8d 100644
--- a/tests/auto/declarative/sql/data/4-iteration-index.js
+++ b/tests/auto/declarative/sql/data/4-iteration-index.js
@@ -1,27 +1,19 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- var r1=""
- for(var i = 0; i < rs.rows.length; i++) {
- r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
- }
- if (r1 != "hello, world;hello, world;hello, world;hello, world;")
- r = "SELECTED DATA WRONG: "+r1;
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
-);
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+ var r1=""
+ for(var i = 0; i < rs.rows.length; i++)
+ r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
+ if (r1 != "hello, world;hello, world;hello, world;hello, world;")
+ r = "SELECTED DATA WRONG: "+r1;
+ else
+ r = "passed";
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/5-iteration-iterator.js b/tests/auto/declarative/sql/data/5-iteration-iterator.js
index 51f0504..ae4fd34 100644
--- a/tests/auto/declarative/sql/data/5-iteration-iterator.js
+++ b/tests/auto/declarative/sql/data/5-iteration-iterator.js
@@ -1,27 +1,19 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- var r1=""
- for(var i in rs.rows) {
- r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
- }
- if (r1 != "hello, world;hello, world;hello, world;hello, world;")
- r = "SELECTED DATA WRONG: "+r1;
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
-);
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM Greeting')
+ var r1=""
+ for(var i in rs.rows)
+ r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
+ if (r1 != "hello, world;hello, world;hello, world;hello, world;")
+ r = "SELECTED DATA WRONG: "+r1;
+ else
+ r = "passed";
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/6-iteration-efficient.js b/tests/auto/declarative/sql/data/6-iteration-efficient.js
index 6711fb0..fe0acfc 100644
--- a/tests/auto/declarative/sql/data/6-iteration-efficient.js
+++ b/tests/auto/declarative/sql/data/6-iteration-efficient.js
@@ -1,32 +1,29 @@
-var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
-var r=0;
-var fbefore="FORWARD WRONG"
-var fafter="FORWARD WRONG"
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
-db.transaction(
- function(tx) {
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- var r1=""
- if (!rs.rows.forwardOnly) fbefore=""
- rs.rows.forwardOnly = true;
- if (rs.rows.forwardOnly) fafter="";
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+ var r1=""
+ var fbefiore = rs.rows.forwardOnly;
+ rs.rows.forwardOnly = true;
+ var fafter = rs.rows.forwardOnly;
+ if (fbefore)
+ r = "forward wrong before";
+ else if (!fafter)
+ r = "forward wrong after";
+ else {
for(var i=0; rs.rows[i]; ++i) {
r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
}
if (r1 != "hello, world;hello, world;hello, world;hello, world;")
r = "SELECTED DATA WRONG: "+r1;
- },
- function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
- );
- },
- function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r=fbefore+"passed"+fafter }
-);
+ else
+ r = "passed";
+ }
+ }
+ );
-
-function test()
-{
- if (r == 0) r = "transaction_not_finished";
return r;
}
diff --git a/tests/auto/declarative/sql/data/7a-error.js b/tests/auto/declarative/sql/data/7a-error.js
new file mode 100644
index 0000000..65d0c03
--- /dev/null
+++ b/tests/auto/declarative/sql/data/7a-error.js
@@ -0,0 +1,20 @@
+function test() {
+ var db = openDatabaseSync("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+ var r="transaction_not_finished";
+
+ try {
+ db.transaction(
+ function(tx) {
+ var rs = tx.executeSql('SELECT * FROM NotExists');
+ r = "SHOULD NOT SUCCEED";
+ }
+ );
+ } catch (err) {
+ if (err.message == "no such table: NotExists Unable to execute statement")
+ r = "passed";
+ else
+ r = "WRONG ERROR="+err.message;
+ }
+
+ return r;
+}