Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativesqldatabase / data / iteration.js
1 function test() {
2     var db = openDatabaseSync("QmlTestDB-iteration", "", "Test database from Qt autotests", 1000000);
3     var r="transaction_not_finished";
4
5     db.transaction(
6         function(tx) {
7             tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)');
8             tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")');
9             tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")');
10         }
11     )
12
13     db.transaction(
14         function(tx) {
15             var rs = tx.executeSql('SELECT * FROM Greeting');
16             var r1=""
17             for(var i = 0; i < rs.rows.length; i++)
18                 r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";"
19             if (r1 != "hello, world;hello, world;hello, world;hello, world;")
20             if (r1 != "Hello, world;Goodbye, cruel world;")
21                 r = "SELECTED DATA WRONG: "+r1;
22             else
23                 r = "passed";
24         }
25     );
26
27     return r;
28 }