diff options
author | axis <qt-info@nokia.com> | 2009-06-29 12:25:09 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-06-29 12:25:09 (GMT) |
commit | 1a8c89e9eaec05e9f38eae4fbc007d8344015de3 (patch) | |
tree | d87e517cfab9443926841b3ef92ca715a717f54a /tests/auto/qsqlquery | |
parent | 78166d5235a5045fdc887febe01d789cac333bb3 (diff) | |
parent | b6171cfbe3b1453a2c46f78db0df4819e4e5e54f (diff) | |
download | Qt-1a8c89e9eaec05e9f38eae4fbc007d8344015de3.zip Qt-1a8c89e9eaec05e9f38eae4fbc007d8344015de3.tar.gz Qt-1a8c89e9eaec05e9f38eae4fbc007d8344015de3.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
.gitignore
src/gui/dialogs/qfiledialog_p.h
src/gui/painting/qpaintengine_raster.cpp
src/gui/text/qfontdatabase.cpp
tests/auto/network-settings.h
tests/auto/qitemdelegate/tst_qitemdelegate.cpp
Diffstat (limited to 'tests/auto/qsqlquery')
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 113 |
1 files changed, 99 insertions, 14 deletions
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 7f97972..ed19e91 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -175,16 +175,20 @@ private slots: void emptyTableNavigate(); #ifdef NOT_READY_YET + void task_229811(); + void task_229811_data() { generic_data(); } + void task_234422_data() { generic_data(); } + void task_234422(); +#endif void task_217003_data() { generic_data(); } void task_217003(); -#endif + void task_250026_data() { generic_data("QODBC"); } void task_250026(); void task_205701_data() { generic_data("QMYSQL"); } void task_205701(); - private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -296,9 +300,8 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) tablenames << qTableName( "qtest_lockedtable" ); -#ifdef NOT_READY_YET tablenames << qTableName( "Planet" ); -#endif + tablenames << qTableName( "task_250026" ); tst_Databases::safeDropTables( db, tablenames ); @@ -2655,7 +2658,6 @@ void tst_QSqlQuery::emptyTableNavigate() } } -#ifdef NOT_READY_YET void tst_QSqlQuery::task_217003() { QFETCH( QString, dbName ); @@ -2682,7 +2684,6 @@ void tst_QSqlQuery::task_217003() QVERIFY_SQL( q, seek( 1 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Venus" ) ); } -#endif void tst_QSqlQuery::task_250026() { @@ -2715,12 +2716,12 @@ void tst_QSqlQuery::task_250026() void tst_QSqlQuery::task_205701() { - QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); - qsdb.setHostName("test"); - qsdb.setDatabaseName("test"); - qsdb.setUserName("test"); - qsdb.setPassword("test"); - qsdb.open(); + QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); + qsdb.setHostName("test"); + qsdb.setDatabaseName("test"); + qsdb.setUserName("test"); + qsdb.setPassword("test"); + qsdb.open(); // { QSqlQuery query(qsdb); @@ -2728,6 +2729,90 @@ void tst_QSqlQuery::task_205701() QSqlDatabase::removeDatabase("atest"); } +#ifdef NOT_READY_YET +// For task: 229811 +void tst_QSqlQuery::task_229811() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (!db.driverName().startsWith( "QODBC" )) return; + + QSqlQuery q( db ); + + QString tableName = qTableName( "task_229811" ); + + if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) { + qDebug() << "Warning" << q.lastError(); + } + + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Albert')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Beehive')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Alimony')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Bohemian')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('AllStars')" ) ); + + + QString stmt = "SELECT * FROM " + tableName + " WHERE Word LIKE :name"; + QVERIFY_SQL(q,prepare(stmt)); + q.bindValue(":name", "A%"); + QVERIFY_SQL(q,exec()); + + QVERIFY(q.isActive()); + QVERIFY(q.isSelect()); + QVERIFY(q.first()); + + QSqlRecord rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Albert")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Alimony")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(),QString("AllStars")); + + q.exec("DROP TABLE " + tableName ); +} + +void tst_QSqlQuery::task_234422() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + QSqlQuery query(db); + QStringList m_airlines; + QStringList m_countries; + + m_airlines << "Lufthansa" << "SAS" << "United" << "KLM" << "Aeroflot"; + m_countries << "DE" << "SE" << "US" << "NL" << "RU"; + + QString tableName = qTableName( "task_234422" ); + + query.exec("DROP TABLE " + tableName); + QVERIFY_SQL(query,exec("CREATE TABLE " + tableName + " (id int primary key, " + "name varchar(20), homecountry varchar(2))")); + for (int i = 0; i < m_airlines.count(); ++i) { + QVERIFY(query.exec(QString("INSERT INTO " + tableName + " values(%1, '%2', '%3')") + .arg(i).arg(m_airlines[i], m_countries[i]))); + } + + QVERIFY_SQL(query, exec("SELECT name FROM " + tableName)); + QVERIFY(query.isSelect()); + QVERIFY(query.first()); + QVERIFY(query.next()); + QCOMPARE(query.at(), 1); + + QSqlQuery query2(query); + + QVERIFY_SQL(query2,exec()); + QVERIFY(query2.first()); + QCOMPARE(query2.at(), 0); + QCOMPARE(query.at(), 1); +} + +#endif QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" |