Index: gears/test/testcases/database2_tests.js =================================================================== --- gears/test/testcases/database2_tests.js (revision 1754) +++ gears/test/testcases/database2_tests.js (working copy) @@ -79,29 +79,30 @@ }); } -function testDatabaseTransaction() { - withDb(function(db) { - var method = 'Database2.transaction()'; - var inFlight; - var outOfOrder = 0; - // this tests the fact that the transaction callback is called - // asynchronously and whether the callback is invoked in a proper sequence - // if startAsync times out, the callback is not invoked at all - db.transaction(function(tx) { - inFlight = true; - outOfOrder--; - if (outOfOrder) { - assert(false, method + ' invokes callback out of sequence'); - } - completeAsync(); - }); - outOfOrder++; - if (inFlight) { - assert(false, method + ' is not called asynchronously'); - } - startAsync(); - }); -} +// TODO(dimitri.glazkov): Uncomment when functionality implemented +//function testDatabaseTransaction() { +// withDb(function(db) { +// var method = 'Database2.transaction()'; +// var inFlight; +// var outOfOrder = 0; +// // this tests the fact that the transaction callback is called +// // asynchronously and whether the callback is invoked in a proper sequence +// // if startAsync times out, the callback is not invoked at all +// db.transaction(function(tx) { +// inFlight = true; +// outOfOrder--; +// if (outOfOrder) { +// assert(false, method + ' invokes callback out of sequence'); +// } +// completeAsync(); +// }); +// outOfOrder++; +// if (inFlight) { +// assert(false, method + ' is not called asynchronously'); +// } +// startAsync(); +// }); +//} function testDatabaseSynchronousTransaction() { withDb(function(db) { @@ -155,6 +156,35 @@ }); } +// TODO(dimitri.glazkov): Add tests for type fidelity, large integers, and +// unsupported types. +// TODO(dimitri.glazkov): Rework the tests to create/drop test tables with setup +// and tear-down methods. +function testSyncExecution() { + withDb(function(db) { + db.synchronousTransaction(function(tx) { + var rs; + tx.executeSql('CREATE TABLE IF NOT EXISTS Pages(' + + ' pageId INTEGER PRIMARY KEY,' + + ' version TEXT)'); + var pageId; + rs = tx.executeSql('SELECT IFNULL(MAX(pageId) + 1, 1) AS max FROM Pages'); + assert(rs, 'Synchronous execute should return a result set'); + assert(rs.rows, 'result set must contain rows'); + assert(rs.rows.length, 'result set must contain one row'); + assert(rs.rows[0].max, + 'result set must return one non-zero int value with the key of "max"'); + pageId = rs.rows[0].max; + tx.executeSql('INSERT INTO Pages(pageId, version) ' + + 'VALUES(?,?)', [ pageId, 'test' ]); + var rs = tx.executeSql('SELECT * FROM Pages WHERE pageId = ?', + [ pageId ]); + assert(rs.rows[0].pageId == pageId, + 'result set must return the last returned value'); + }); + }); +} + function testSQLTransactionApiSig() { withDb(function(db) { var method = 'SQLTransaction.executeSql';