summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/sql
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-09-24 08:18:47 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-09-24 08:18:47 (GMT)
commitdf68368889bcd71d935b916681c70ce178280fef (patch)
tree2a66914d79db9948ae70686b803d657ae2f4fc4a /tests/auto/declarative/sql
parent686583c37af269137898ab01af4c2b585f91baea (diff)
downloadQt-df68368889bcd71d935b916681c70ce178280fef.zip
Qt-df68368889bcd71d935b916681c70ce178280fef.tar.gz
Qt-df68368889bcd71d935b916681c70ce178280fef.tar.bz2
More tests for QmlSql, more WebKit-tested-validity.
Diffstat (limited to 'tests/auto/declarative/sql')
-rw-r--r--tests/auto/declarative/sql/data/1-creation.js (renamed from tests/auto/declarative/sql/data/test1.js)0
-rw-r--r--tests/auto/declarative/sql/data/2-selection.js (renamed from tests/auto/declarative/sql/data/test2.js)0
-rw-r--r--tests/auto/declarative/sql/data/3-iteration-item-function.js27
-rw-r--r--tests/auto/declarative/sql/data/5-iteration-iterator.js27
-rw-r--r--tests/auto/declarative/sql/data/6-iteration-efficient.js28
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp15
6 files changed, 94 insertions, 3 deletions
diff --git a/tests/auto/declarative/sql/data/test1.js b/tests/auto/declarative/sql/data/1-creation.js
index 95fa99e..95fa99e 100644
--- a/tests/auto/declarative/sql/data/test1.js
+++ b/tests/auto/declarative/sql/data/1-creation.js
diff --git a/tests/auto/declarative/sql/data/test2.js b/tests/auto/declarative/sql/data/2-selection.js
index 3acf686..3acf686 100644
--- a/tests/auto/declarative/sql/data/test2.js
+++ b/tests/auto/declarative/sql/data/2-selection.js
diff --git a/tests/auto/declarative/sql/data/3-iteration-item-function.js b/tests/auto/declarative/sql/data/3-iteration-item-function.js
new file mode 100644
index 0000000..bad9b82
--- /dev/null
+++ b/tests/auto/declarative/sql/data/3-iteration-item-function.js
@@ -0,0 +1,27 @@
+var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+var r=0;
+
+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" }
+);
+
+
+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
new file mode 100644
index 0000000..51f0504
--- /dev/null
+++ b/tests/auto/declarative/sql/data/5-iteration-iterator.js
@@ -0,0 +1,27 @@
+var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+var r=0;
+
+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" }
+);
+
+
+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
new file mode 100644
index 0000000..2222b8a
--- /dev/null
+++ b/tests/auto/declarative/sql/data/6-iteration-efficient.js
@@ -0,0 +1,28 @@
+var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+var r=0;
+
+db.transaction(
+ function(tx) {
+ tx.executeSql('SELECT * FROM Greeting', [],
+ function(tx, rs) {
+ var r1=""
+ rs.rows.forwardOnly = true;
+ 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="passed" }
+);
+
+
+function test()
+{
+ if (r == 0) r = "transaction_not_finished";
+ return r;
+}
diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp
index cb13427..10ce6d8 100644
--- a/tests/auto/declarative/sql/tst_sql.cpp
+++ b/tests/auto/declarative/sql/tst_sql.cpp
@@ -82,9 +82,14 @@ void tst_sql::testQml_data()
QTest::addColumn<QString>("jsfile"); // The input file
QTest::addColumn<QString>("result"); // The required output from the js test() function
QTest::addColumn<int>("databases"); // The number of databases that should have been created
-
- QTest::newRow("basic creation") << "data/test1.js" << "passed" << 1;
- QTest::newRow("basic select") << "data/test2.js" << "passed" << 1;
+ QTest::addColumn<bool>("qmlextension"); // Things WebKit can't do
+
+ QTest::newRow("creation") << "data/1-creation.js" << "passed" << 1 << false;
+ QTest::newRow("selection") << "data/2-selection.js" << "passed" << 1 << false;
+ QTest::newRow("iteration-item-function") << "data/3-iteration-item-function.js" << "passed" << 1 << false;
+ QTest::newRow("iteration-index") << "data/4-iteration-index.js" << "passed" << 1 << true;
+ QTest::newRow("iteration-iterator") << "data/5-iteration-iterator.js" << "passed" << 1 << true;
+ QTest::newRow("iteration-efficient") << "data/6-iteration-efficient.js" << "passed" << 1 << true;
}
void tst_sql::validateAgainstWebkit_data()
@@ -102,6 +107,10 @@ void tst_sql::validateAgainstWebkit()
QFETCH(QString, jsfile);
QFETCH(QString, result);
QFETCH(int, databases);
+ QFETCH(bool, qmlextension);
+
+ if (qmlextension) // WebKit can't do it (yet?)
+ return;
QFile f(jsfile);
QVERIFY(f.open(QIODevice::ReadOnly));