diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-18 03:25:37 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-18 03:25:37 (GMT) |
commit | e2dbda508f2a65e1ca8c31df6339b1bbec14e933 (patch) | |
tree | f40af8a17bc07005af529abe82c46e4e953585cc /tests/auto | |
parent | 4ba2513ca6fa42c37c45a573b4643b5e1d97db3b (diff) | |
parent | 9614a2775df27602b1d1bb0946feb4bb593cbf39 (diff) | |
download | Qt-e2dbda508f2a65e1ca8c31df6339b1bbec14e933.zip Qt-e2dbda508f2a65e1ca8c31df6339b1bbec14e933.tar.gz Qt-e2dbda508f2a65e1ca8c31df6339b1bbec14e933.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/repeater/data/itemlist.qml | 49 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/1-creation.js | 27 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/2-selection-bindnames.js | 32 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/2-selection.js | 41 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/3-iteration-item-function.js | 38 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/4-iteration-index.js | 38 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/5-iteration-iterator.js | 38 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/6-iteration-efficient.js | 43 | ||||
-rw-r--r-- | tests/auto/declarative/sql/data/7a-error.js | 20 | ||||
-rw-r--r-- | tests/auto/declarative/sql/tst_sql.cpp | 20 |
10 files changed, 184 insertions, 162 deletions
diff --git a/tests/auto/declarative/repeater/data/itemlist.qml b/tests/auto/declarative/repeater/data/itemlist.qml new file mode 100644 index 0000000..8d28bf8 --- /dev/null +++ b/tests/auto/declarative/repeater/data/itemlist.qml @@ -0,0 +1,49 @@ +// This example demonstrates placing items in a view using +// a VisualItemModel + +import Qt 4.6 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + + function checkProperties() { + testObject.error = false; + if (testObject.useModel && view.model != itemModel) { + print("model property incorrect"); + testObject.error = true; + } + } + + VisualItemModel { + id: itemModel + objectName: "itemModel" + Rectangle { + objectName: "item1" + height: view.height; width: view.width; color: "#FFFEF0" + Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item2" + height: view.height; width: view.width; color: "#F0FFF7" + Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item3" + height: view.height; width: view.width; color: "#F4F0FF" + Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + } + + Column { + objectName: "container" + Repeater { + id: view + objectName: "repeater" + anchors.fill: parent + anchors.bottomMargin: 30 + model: testObject.useModel ? itemModel : 0 + } + } +} 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; +} diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp index 973d7b1..cbd14ab 100644 --- a/tests/auto/declarative/sql/tst_sql.cpp +++ b/tests/auto/declarative/sql/tst_sql.cpp @@ -144,20 +144,23 @@ void tst_sql::testQml_data() QTest::newRow("iteration-index") << "data/4-iteration-index.js" << "passed" << 1 << true; // Some HTML5 documents say to use rows by index, others by item() function QTest::newRow("iteration-iterator") << "data/5-iteration-iterator.js" << "passed" << 1 << true; // As with previous, WebKit doesn't give an array QTest::newRow("iteration-efficient") << "data/6-iteration-efficient.js" << "passed" << 1 << true; // It's very inefficient to find the total number of results, here is a solution + QTest::newRow("error-a") << "data/7a-error.js" << "passed" << 1 << false; } void tst_sql::validateAgainstWebkit_data() { - 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::addColumn<bool>("qmlextension"); // Things WebKit can't do + QTest::newRow("creation") << "data/1-creation.js" << "passed" << 1 << false; } void tst_sql::validateAgainstWebkit() { // Validates tests against WebKit (HTML5) support. // - // WebKit SQL is asynchronous, so tests are divided into code plus a test() - // function which is executed "later" (via QTRY_). - // + QFETCH(QString, jsfile); QFETCH(QString, result); QFETCH(int, databases); @@ -174,14 +177,15 @@ void tst_sql::validateAgainstWebkit() webpage.settings()->setOfflineStoragePath(dbDir()); webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - webpage.mainFrame()->evaluateJavaScript(js); - QTest::qWait(200); // WebKit db access is asynchronous - QTRY_COMPARE(webpage.mainFrame()->evaluateJavaScript("test()").toString(),result); - QTest::qWait(200); // WebKit crashes if you quit it too fast + QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); + QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); + /* + QTest::qWait(100); // WebKit crashes if you quit it too fast QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); QList<QWebDatabase> dbs = origin.databases(); QCOMPARE(dbs.count(), databases); + */ } void tst_sql::testQml() |