diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 20 | ||||
-rw-r--r-- | tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 295 | ||||
-rw-r--r-- | tests/auto/qprocess/tst_qprocess.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 194 | ||||
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 95 | ||||
-rw-r--r-- | tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 167 | ||||
-rw-r--r-- | tests/auto/qsqlthread/tst_qsqlthread.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qtextstream/tst_qtextstream.cpp | 4 |
10 files changed, 535 insertions, 300 deletions
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index c06485d..2d91186 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -89,7 +89,7 @@ private slots: void unicode(); void precision_data() { generic_data(); } void precision(); - void insertORA_data(); + void insertORA_data() { generic_data("QOCI"); } void insertORA(); void batchInsert_data() { generic_data(); } void batchInsert(); @@ -101,7 +101,7 @@ private slots: void insertFieldNameContainsWS(); // For task 117996 private: - void generic_data(); + void generic_data(const QString &engine=QString()); void createTestTables( QSqlDatabase db ); void dropTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -117,10 +117,14 @@ tst_Q3SqlCursor::~tst_Q3SqlCursor() { } -void tst_Q3SqlCursor::generic_data() +void tst_Q3SqlCursor::generic_data(const QString &engine) { - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) @@ -429,12 +433,6 @@ static QString dumpUtf8( const QString& str ) return res; } -void tst_Q3SqlCursor::insertORA_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_Q3SqlCursor::insertORA() { QFETCH( QString, dbName ); diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp index a8c5940..9ab74f0 100644 --- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp +++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp @@ -76,7 +76,7 @@ private slots: void _exec(); private: - void generic_data(); + void generic_data(const QString &engine=QString()); void createTestTables( QSqlDatabase db ); void dropTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -92,10 +92,14 @@ tst_Q3SqlSelectCursor::~tst_Q3SqlSelectCursor() { } -void tst_Q3SqlSelectCursor::generic_data() +void tst_Q3SqlSelectCursor::generic_data(const QString& engine) { - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db ) diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 9010db4..36a4b45 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -286,8 +286,263 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("expiration3") << "a=b; expires=Wednesday, 09-Nov-1999 23:12:40 GMT " << cookie; QTest::newRow("expiration-utc") << "a=b;expires=Wednesday, 09-Nov-1999 23:12:40 UTC" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("time-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 0), Qt::UTC)); + QTest::newRow("time-1") << "a=b;expires=14 Apr 89 03:20:12" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-2") << "a=b;expires=14 Apr 89 03:20:12.88" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-3") << "a=b;expires=14 Apr 89 03:20:12.88am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-4") << "a=b;expires=14 Apr 89 03:20:12.88pm" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-5") << "a=b;expires=14 Apr 89 03:20:12.88 Am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-6") << "a=b;expires=14 Apr 89 03:20:12.88 PM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-7") << "a=b;expires=14 Apr 89 3:20:12.88 PM" << cookie; + + // normal months + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-1") << "a=b;expires=Jan 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 2, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-2") << "a=b;expires=Feb 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-3") << "a=b;expires=mar 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-4") << "a=b;expires=Apr 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 5, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-5") << "a=b;expires=May 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 6, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-6") << "a=b;expires=Jun 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 7, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-7") << "a=b;expires=Jul 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 8, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-8") << "a=b;expires=Aug 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 9, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-9") << "a=b;expires=Sep 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 10, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-10") << "a=b;expires=Oct 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 11, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-11") << "a=b;expires=Nov 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-12") << "a=b;expires=Dec 1 89 1:1" << cookie; + + // extra months + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-13") << "a=b;expires=December 1 89 1:1" << cookie; + QTest::newRow("months-14") << "a=b;expires=1 89 1:1 Dec" << cookie; + //cookie.setExpirationDate(QDateTime()); + //QTest::newRow("months-15") << "a=b;expires=1 89 1:1 De" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-16") << "a=b;expires=2024 29 Feb 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-17") << "a=b;expires=Fri, 29-Feb-2024 01:01:00 GMT" << cookie; + QTest::newRow("months-18") << "a=b;expires=2024 29 Feb 1:1 GMT" << cookie; + + // normal offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-0") << "a=b;expires=Jan 1 89 8:0 PST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-1") << "a=b;expires=Jan 1 89 8:0 PDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-2") << "a=b;expires=Jan 1 89 7:0 MST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-3") << "a=b;expires=Jan 1 89 7:0 MDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-4") << "a=b;expires=Jan 1 89 6:0 CST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-5") << "a=b;expires=Jan 1 89 6:0 CDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-6") << "a=b;expires=Jan 1 89 5:0 EST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-7") << "a=b;expires=Jan 1 89 5:0 EDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-8") << "a=b;expires=Jan 1 89 4:0 AST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-9") << "a=b;expires=Jan 1 89 3:0 NST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-10") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-11") << "a=b;expires=Jan 1 89 0:0 BST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-12") << "a=b;expires=Jan 1 89 23:0 MET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-13") << "a=b;expires=Jan 1 89 22:0 EET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST" << cookie; + + // extra offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15") << "a=b;expires=Jan 1 89 0:0 GMT+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15b") << "a=b;expires=Jan 1 89 1:0 GMT-1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-16") << "a=b;expires=Jan 1 89 0:0 GMT+01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 5), Qt::UTC)); + QTest::newRow("zoneoffset-17") << "a=b;expires=Jan 1 89 0:0 GMT+0105" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-18") << "a=b;expires=Jan 1 89 0:0 GMT+015" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19") << "a=b;expires=Jan 1 89 0:0 GM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19b") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + + // offsets from gmt + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-20") << "a=b;expires=Jan 1 89 0:0 +1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-21") << "a=b;expires=Jan 1 89 0:0 +01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("zoneoffset-22") << "a=b;expires=Jan 1 89 0:0 +0101" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-23") << "a=b;expires=Jan 1 89 1:0 -1" << cookie; + + // Y2k + cookie.setExpirationDate(QDateTime(QDate(2000, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-0") << "a=b;expires=Jan 1 00 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-1") << "a=b;expires=Jan 1 70 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1971, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-2") << "a=b;expires=Jan 1 71 0:0" << cookie; + + // Day, month, year + cookie.setExpirationDate(QDateTime(QDate(2013, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("date-0") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-1") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-2") << "a=b;expires=1/2/13 0:0" << cookie; + QTest::newRow("date-3") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-4") << "a=b;expires=Jan 2, 13 0:0" << cookie; + QTest::newRow("date-5") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-6") << "a=b;expires=1/2/13 0:0" << cookie; + + // Known Year, determine month and day + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownyear-1") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownyear-2") << "a=b;expires=1995/1/13 0:0" << cookie; + QTest::newRow("knownyear-3") << "a=b;expires=1995/13/1 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-4") << "a=b;expires=1/2/95 0:0" << cookie; + QTest::newRow("knownyear-5") << "a=b;expires=95/1/2 0:0" << cookie; + + // Known Year, Known day, determining month + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownYD-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownYD-1") << "a=b;expires=1/13/95 0:0" << cookie; + QTest::newRow("knownYD-2") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownYD-3") << "a=b;expires=95/1/13 0:0" << cookie; + + // Month comes before Year + cookie.setExpirationDate(QDateTime(QDate(2021, 03, 26), QTime(0, 0), Qt::UTC)); + QTest::newRow("month-0") << "a=b;expires=26/03/21 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2015, 12, 30), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-1") << "a=b;expires=wed 16:25pm December 2015 30" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 11), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-2") << "a=b;expires=16:25 11 31 11" << cookie; + + // The very ambiguous cases + // Matching Firefox's behavior of guessing month, day, year in those cases + cookie.setExpirationDate(QDateTime(QDate(2013, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-0") << "a=b;expires=10/2/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2013, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-1") << "a=b;expires=2/10/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2010, 2, 3), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-2") << "a=b;expires=2/3/10 0:0" << cookie; + + // FYI If you try these in Firefox it wont set a cookie for the following two string + // because 03 is turned into the year at which point it is expired + cookie.setExpirationDate(QDateTime(QDate(2003, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-3") << "a=b;expires=2/10/3 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2003, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-4") << "a=b;expires=10/2/3 0:0" << cookie; + + // These are the cookies that firefox's source says it can parse + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-1") << "a=b;expires=14 Apr 89 03:20 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 33, 0), Qt::UTC)); + QTest::newRow("firefox-2") << "a=b;expires=Fri, 17 Mar 89 4:01:33" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 0, 0), Qt::UTC)); + QTest::newRow("firefox-3") << "a=b;expires=Fri, 17 Mar 89 4:01 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(16-8, 12, 0, 0), Qt::UTC)); + QTest::newRow("firefox-4") << "a=b;expires=Mon Jan 16 16:12 PDT 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(17, 42, 0, 0), Qt::UTC)); + QTest::newRow("firefox-5") << "a=b;expires=Mon Jan 16 16:12 +0130 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1992, 5, 6), QTime(16-9, 41, 0, 0), Qt::UTC)); + QTest::newRow("firefox-6") << "a=b;expires=6 May 1992 16:41-JST (Wednesday)" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(10, 59, 12, 82), Qt::UTC)); + QTest::newRow("firefox-7") << "a=b;expires=22-AUG-1993 10:59:12.82" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(22, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-8") << "a=b;expires=22-AUG-1993 10:59pm" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-9") << "a=b;expires=22-AUG-1993 12:59am" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-10") << "a=b;expires=22-AUG-1993 12:59 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 8, 4), QTime(15, 54, 0, 0), Qt::UTC)); + QTest::newRow("firefox-11") << "a=b;expires=Friday, August 04, 1995 3:54 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 21), QTime(16, 24, 34, 0), Qt::UTC)); + QTest::newRow("firefox-12") << "a=b;expires=06/21/95 04:24:34 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 20), QTime(21, 7, 0, 0), Qt::UTC)); + QTest::newRow("firefox-13") << "a=b;expires=20/06/95 21:07" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 8), QTime(19-5, 32, 48, 0), Qt::UTC)); + QTest::newRow("firefox-14") << "a=b;expires=95-06-08 19:32:48 EDT" << cookie; + + // Edge cases caught by fuzzing + // These are about the default cause creates dates that don't exits + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 25), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-0") << "a=b; expires=30 -000002 1:1 25;" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-1") << "a=b; expires=31 11 20 1:1;" << cookie; + + // April only has 30 days + cookie.setExpirationDate(QDateTime(QDate(2031, 4, 30), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-2") << "a=b; expires=31 30 4 1:1" << cookie; + + // 9 must be the month so 31 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2031, 9, 21), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-3") << "a=b; expires=31 21 9 1:1" << cookie; + + // Year is known, then fallback to defaults of filling in month and day + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 1), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-4") << "a=b; expires=31 11 01 1:1" << cookie; + + // 2 must be the month so 30 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-5") << "a=b; expires=30 02 20 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2021, 12, 22), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-6") << "a=b; expires=2021 12 22 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2029, 2, 23), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-7") << "a=b; expires=29 23 Feb 1:1" << cookie; + + // 11 and 6 don't have 31 days + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 06), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-8") << "a=b; expires=31 11 06 1:1" << cookie; + // two-digit years: // from 70 until 99, we assume 20th century + cookie.setExpirationDate(QDateTime(QDate(1999, 11, 9), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit1") << "a=b; expires=Wednesday, 09-Nov-99 23:12:40 GMT " << cookie; cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit2") << "a=b; expires=Thursday, 01-Jan-70 23:12:40 GMT " << cookie; @@ -315,6 +570,9 @@ void tst_QNetworkCookie::parseSingleCookie_data() cookie.setExpirationDate(QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59), Qt::UTC)); QTest::newRow("network2") << "__siteid=1; expires=Fri, 31-Dec-9999 23:59:59 GMT; path=/" << cookie; + cookie = QNetworkCookie("YM.LC", "v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed"); + cookie.setPath("/"); + cookie.setDomain("mail.yahoo.com"); QTest::newRow("network3") << "YM.LC=v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed; path=/; domain=mail.yahoo.com" << cookie; cookie = QNetworkCookie("__ac", "c2hhdXNtYW46U2FTYW80Wm8%3D"); @@ -330,13 +588,22 @@ void tst_QNetworkCookie::parseSingleCookie() QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toLatin1()); - QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); - QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort); + //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); QCOMPARE(result.count(), 1); + QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort); QCOMPARE(result.at(0), expectedCookie); result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); QCOMPARE(result.count(), 1); + + // Drop any millisecond information, if there's any + QDateTime dt = expectedCookie.expirationDate(); + if (dt.isValid()) { + QTime t = dt.time(); + dt.setTime(t.addMSecs(-t.msec())); + expectedCookie.setExpirationDate(dt); + } + QCOMPARE(result.at(0), expectedCookie); } @@ -358,9 +625,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() // reason: malformed NAME=VALUE pair QTest::newRow("invalid-05") << "foo" << list; QTest::newRow("invalid-06") << "=b" << list; - QTest::newRow("invalid-08") << "a=b,foo" << list; QTest::newRow("invalid-09") << "foo,a=b" << list; - QTest::newRow("invalid-10") << "a=b,=b" << list; QTest::newRow("invalid-11") << ";path=/" << list; // reason: malformed expiration date string @@ -369,8 +634,6 @@ void tst_QNetworkCookie::parseMultipleCookies_data() QTest::newRow("invalid-14") << "a=b;expires=foobar, abc" << list; QTest::newRow("invalid-15") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list; QTest::newRow("invalid-16") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; - QTest::newRow("invalid-17") << "a=b,c=d;expires=" << list; - QTest::newRow("invalid-18") << "a=b, c=d; expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; QNetworkCookie cookie; cookie.setName("a"); @@ -417,6 +680,26 @@ void tst_QNetworkCookie::parseMultipleCookies_data() list << cookie; QTest::newRow("network1") << "id=51706646077999719 bb=\"K14144t\"_AAQ\"ototrK_A_ttot44AQ4KwoRQtoto| adv=; Domain=.bluestreak.com; expires=Tuesday 05-Dec-2017 09:11:07 GMT; path=/;" << list; + QNetworkCookie cookieA; + cookieA.setName("a"); + cookieA.setValue("b"); + + QNetworkCookie cookieB; + cookieB.setName("c"); + cookieB.setValue("d"); + + // NewLine + cookieA.setExpirationDate(QDateTime(QDate(2009, 3, 10), QTime(7, 0, 0, 0), Qt::UTC)); + cookieB.setExpirationDate(QDateTime(QDate(2009, 3, 20), QTime(7, 0, 0, 0), Qt::UTC)); + list = QList<QNetworkCookie>() << cookieA << cookieB; + QTest::newRow("real-0") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + QTest::newRow("real-1") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\n\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + QTest::newRow("real-2") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + + // Match firefox's behavior + cookieA.setPath("/foo"); + list = QList<QNetworkCookie>() << cookieA << cookieB; + QTest::newRow("real-3") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue; path=/foo\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; } void tst_QNetworkCookie::parseMultipleCookies() diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index ebfe33a..ef78c2e 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -141,6 +141,8 @@ private slots: void switchReadChannels(); void setWorkingDirectory(); void startFinishStartFinish(); + void invalidProgramString_data(); + void invalidProgramString(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2106,5 +2108,29 @@ void tst_QProcess::startFinishStartFinish() } } +//----------------------------------------------------------------------------- +void tst_QProcess::invalidProgramString_data() +{ + QTest::addColumn<QString>("programString"); + QTest::newRow("null string") << QString(); + QTest::newRow("empty string") << QString(""); + QTest::newRow("only blank string") << QString(" "); +} + +void tst_QProcess::invalidProgramString() +{ + QFETCH(QString, programString); + QProcess process; + + qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); + QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError))); + + process.start(programString); + QCOMPARE(process.error(), QProcess::FailedToStart); + QCOMPARE(spy.count(), 1); + + QVERIFY(!QProcess::startDetached(programString)); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 349db65..e10a0ca 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -93,28 +93,28 @@ private slots: void addDatabase(); //database specific tests - void recordMySQL_data(); + void recordMySQL_data() { generic_data("QMYSQL"); } void recordMySQL(); - void recordPSQL_data(); + void recordPSQL_data() { generic_data("QPSQL"); } void recordPSQL(); - void recordOCI_data(); + void recordOCI_data() { generic_data("QOCI"); } void recordOCI(); - void recordTDS_data(); + void recordTDS_data() { generic_data("QTDS"); } void recordTDS(); - void recordDB2_data(); + void recordDB2_data() { generic_data("QDB2"); } void recordDB2(); - void recordSQLite_data(); + void recordSQLite_data() { generic_data("QSQLITE"); } void recordSQLite(); - void recordAccess_data(); + void recordAccess_data() { generic_data("QODBC"); } void recordAccess(); - void recordSQLServer_data(); + void recordSQLServer_data() { generic_data("QODBC"); } void recordSQLServer(); - void recordIBase_data(); + void recordIBase_data() {generic_data("QIBASE"); } void recordIBase(); - void eventNotificationIBase_data() { generic_data(); } + void eventNotificationIBase_data() { generic_data("QIBASE"); } void eventNotificationIBase(); - void eventNotificationPSQL_data() { generic_data(); } + void eventNotificationPSQL_data() { generic_data("QPSQL"); } void eventNotificationPSQL(); //database specific 64 bit integer test @@ -141,59 +141,61 @@ private slots: void precisionPolicy_data() { generic_data(); } void precisionPolicy(); - void db2_valueCacheUpdate_data() { generic_data(); } + void db2_valueCacheUpdate_data() { generic_data("QDB2"); } void db2_valueCacheUpdate(); - void psql_schemas_data(); + void psql_schemas_data() { generic_data("QPSQL"); } void psql_schemas(); - void psql_escapedIdentifiers_data(){ psql_schemas_data(); } + void psql_escapedIdentifiers_data() { generic_data("QPSQL"); } void psql_escapedIdentifiers(); - void psql_escapeBytea_data() { generic_data(); } + void psql_escapeBytea_data() { generic_data("QPSQL"); } void psql_escapeBytea(); + void bug_249059_data() { generic_data("QPSQL"); } + void bug_249059(); void mysqlOdbc_unsignedIntegers_data() { generic_data(); } void mysqlOdbc_unsignedIntegers(); - void mysql_multiselect_data() { generic_data(); } + void mysql_multiselect_data() { generic_data("QMYSQL"); } void mysql_multiselect(); // For task 144331 void accessOdbc_strings_data() { generic_data(); } void accessOdbc_strings(); - void ibase_numericFields_data() { generic_data(); } + void ibase_numericFields_data() { generic_data("QIBASE"); } void ibase_numericFields(); // For task 125053 - void ibase_fetchBlobs_data() { generic_data(); } + void ibase_fetchBlobs_data() { generic_data("QIBASE"); } void ibase_fetchBlobs(); // For task 143471 - void ibase_useCustomCharset_data() { generic_data(); } + void ibase_useCustomCharset_data() { generic_data("QIBASE"); } void ibase_useCustomCharset(); // For task 134608 - void ibase_procWithoutReturnValues_data() { generic_data(); } // For task 165423 + void ibase_procWithoutReturnValues_data() { generic_data("QIBASE"); } // For task 165423 void ibase_procWithoutReturnValues(); - void ibase_procWithReturnValues_data() { generic_data(); } // For task 177530 + void ibase_procWithReturnValues_data() { generic_data("QIBASE"); } // For task 177530 void ibase_procWithReturnValues(); - void odbc_reopenDatabase_data() { generic_data(); } + void odbc_reopenDatabase_data() { generic_data("QODBC"); } void odbc_reopenDatabase(); - void odbc_uniqueidentifier_data() { generic_data(); } + void odbc_uniqueidentifier_data() { generic_data("QODBC"); } void odbc_uniqueidentifier(); // For task 141822 - void odbc_uintfield_data() { generic_data(); } + void odbc_uintfield_data() { generic_data("QODBC"); } void odbc_uintfield(); - void odbc_bindBoolean_data() { generic_data(); } + void odbc_bindBoolean_data() { generic_data("QODBC"); } void odbc_bindBoolean(); - void oci_serverDetach_data() { generic_data(); } + void oci_serverDetach_data() { generic_data("QOCI"); } void oci_serverDetach(); // For task 154518 - void oci_xmltypeSupport_data() { generic_data(); } + void oci_xmltypeSupport_data() { generic_data("QOCI"); } void oci_xmltypeSupport(); - void oci_fieldLength_data() { generic_data(); } + void oci_fieldLength_data() { generic_data("QOCI"); } void oci_fieldLength(); - void sqlite_bindAndFetchUInt_data() { generic_data(); } + void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE3"); } void sqlite_bindAndFetchUInt(); private: void createTestTables(QSqlDatabase db); void dropTestTables(QSqlDatabase db); void populateTestTables(QSqlDatabase db); - void generic_data(); + void generic_data(const QString &engine=QString()); #ifdef QT3_SUPPORT void testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf); @@ -337,7 +339,8 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("qtestBindBool") << qTableName("qtest_sqlguid") << qTableName("uint_table") - << qTableName("uint_test"); + << qTableName("uint_test") + << qTableName("bug_249059"); QSqlQuery q(0, db); if (db.driverName().startsWith("QPSQL")) @@ -394,70 +397,14 @@ void tst_QSqlDatabase::cleanup() { } -void tst_QSqlDatabase::recordOCI_data() +void tst_QSqlDatabase::generic_data(const QString& engine) { - if (dbs.fillTestTable("QOCI") == 0) - QSKIP("No Oracle database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordPSQL_data() -{ - if (dbs.fillTestTable("QPSQL") == 0) - QSKIP("No PostgreSQL database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordMySQL_data() -{ - if (dbs.fillTestTable("QMYSQL") == 0) - QSKIP("No MySQL database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordTDS_data() -{ - if (dbs.fillTestTable("QTDS") == 0) - QSKIP("No TDS database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordDB2_data() -{ - if (dbs.fillTestTable("QDB2") == 0) - QSKIP("No DB2 database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordSQLite_data() -{ - if (dbs.fillTestTable("QSQLITE") == 0) - QSKIP("No SQLite database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordAccess_data() -{ - if (dbs.fillTestTable("QODBC") == 0) - QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordSQLServer_data() -{ - if (dbs.fillTestTable("QODBC") == 0) - QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordIBase_data() -{ - if (dbs.fillTestTable("QIBASE") == 0) - QSKIP("No Interbase database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::psql_schemas_data() -{ - if (dbs.fillTestTable("QPSQL") == 0) - QSKIP("No Postgres database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::generic_data() -{ - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlDatabase::addDatabase() @@ -885,7 +832,6 @@ void tst_QSqlDatabase::recordTDS() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QTDS"); static const FieldDef fieldDefs[] = { FieldDef("tinyint", QVariant::Int, 255), @@ -934,7 +880,6 @@ void tst_QSqlDatabase::recordOCI() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); // runtime check for Oracle version since V8 doesn't support TIMESTAMPs if (tst_Databases::getOraVersion(db) >= 9) { @@ -1010,7 +955,6 @@ void tst_QSqlDatabase::recordPSQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); FieldDef byteadef; if (db.driver()->hasFeature(QSqlDriver::BLOB)) @@ -1095,7 +1039,6 @@ void tst_QSqlDatabase::recordMySQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QMYSQL"); FieldDef bin10, varbin10; int major = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt(); @@ -1174,7 +1117,6 @@ void tst_QSqlDatabase::recordDB2() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QDB2"); static const FieldDef fieldDefs[] = { FieldDef("char(20)", QVariant::String, QString("Blah1")), @@ -1220,7 +1162,6 @@ void tst_QSqlDatabase::recordIBase() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); static const FieldDef fieldDefs[] = { FieldDef("char(20)", QVariant::String, QString("Blah1"), false), @@ -1251,7 +1192,6 @@ void tst_QSqlDatabase::recordSQLite() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); static const FieldDef fieldDefs[] = { // The affinity of these fields are TEXT so SQLite should give us strings, not ints or doubles. @@ -1594,7 +1534,6 @@ void tst_QSqlDatabase::psql_escapeBytea() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); const char dta[4] = {'\x71', '\x14', '\x32', '\x81'}; QByteArray ba(dta, 4); @@ -1621,6 +1560,38 @@ void tst_QSqlDatabase::psql_escapeBytea() QCOMPARE(i, 4); } +void tst_QSqlDatabase::bug_249059() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QString tableName = qTableName("bug_249059"); + QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName))); + + QSqlQuery iq(db); + QVERIFY_SQL(iq, prepare(QString("INSERT INTO %1 VALUES (?, ?)").arg(tableName))); + iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 -5:00"))); + iq.bindValue(1, QVariant(QString("04:05:06.789 -5:00"))); + QVERIFY_SQL(iq, exec()); + iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 +5:00"))); + iq.bindValue(1, QVariant(QString("04:05:06.789 +5:00"))); + QVERIFY_SQL(iq, exec()); + + QVERIFY_SQL(q, exec(QString("SELECT dt, t FROM %1").arg(tableName))); + QVERIFY_SQL(q, next()); + QDateTime dt1=q.value(0).toDateTime(); + QTime t1=q.value(1).toTime(); + QVERIFY_SQL(q, next()); + QDateTime dt2=q.value(0).toDateTime(); + QTime t2=q.value(1).toTime(); + + // These will fail when timezone support is added, when that's the case, set the second record to 14:05:06.789 and it should work correctly + QCOMPARE(dt1, dt2); + QCOMPARE(t1, t2); +} + // This test should be rewritten to work with Oracle as well - or the Oracle driver // should be fixed to make this test pass (handle overflows) void tst_QSqlDatabase::precisionPolicy() @@ -1767,7 +1738,6 @@ void tst_QSqlDatabase::ibase_numericFields() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QSqlQuery q(db); QString tableName = qTableName("numericfields"); @@ -1841,7 +1811,6 @@ void tst_QSqlDatabase::ibase_fetchBlobs() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString tableName = qTableName("qtest_ibaseblobs"); QSqlQuery q(db); @@ -1874,7 +1843,6 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QSqlQuery q(db); QString procName = qTableName("qtest_proc1"); @@ -1955,11 +1923,6 @@ void tst_QSqlDatabase::odbc_reopenDatabase() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - if (!tst_Databases::isSqlServer(db)) { - QSKIP("SQL Server (ODBC) specific test", SkipSingle); - return; - } - QSqlQuery q(db); QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); QVERIFY_SQL(q, next()); @@ -1974,7 +1937,6 @@ void tst_QSqlDatabase::odbc_bindBoolean() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QODBC"); QSqlQuery q(db); QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)")); @@ -2003,7 +1965,6 @@ void tst_QSqlDatabase::mysql_multiselect() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QMYSQL"); QSqlQuery q(db); QVERIFY_SQL(q, exec("select version()")); @@ -2025,7 +1986,6 @@ void tst_QSqlDatabase::ibase_useCustomCharset() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString nonlatin1string("��"); db.close(); @@ -2049,7 +2009,6 @@ void tst_QSqlDatabase::oci_serverDetach() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); for (int i = 0; i < 2; i++) { db.close(); @@ -2070,7 +2029,6 @@ void tst_QSqlDatabase::oci_xmltypeSupport() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); QString tableName = qTableName("qtest_xmltype"); QString xml("<?xml version=\"1.0\"?><TABLE_NAME>MY_TABLE</TABLE_NAME>"); @@ -2099,7 +2057,6 @@ void tst_QSqlDatabase::oci_fieldLength() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); QString tableName = qTableName("qtest"); QSqlQuery q(db); @@ -2164,7 +2121,6 @@ void tst_QSqlDatabase::odbc_uintfield() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QODBC"); QString tableName = qTableName("uint_table"); unsigned int val = 4294967295U; @@ -2226,7 +2182,6 @@ void tst_QSqlDatabase::eventNotificationIBase() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString procedureName = qTableName("posteventProc"); QSqlDriver *driver=db.driver(); @@ -2256,7 +2211,6 @@ void tst_QSqlDatabase::eventNotificationPSQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); QSqlQuery query(db); QString procedureName = qTableName("posteventProc"); @@ -2277,7 +2231,6 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE3"); QSqlQuery q(db); QString tableName = qTableName("uint_test"); @@ -2299,7 +2252,6 @@ void tst_QSqlDatabase::db2_valueCacheUpdate() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QDB2"); QString tableName = qTableName("qtest"); QSqlQuery q(db); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 684d6ac..8d77589 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -93,7 +93,7 @@ private slots: void transaction(); void record_data() { generic_data(); } void record(); - void record_sqlite_data() { generic_data(); } + void record_sqlite_data() { generic_data("QSQLITE"); } void record_sqlite(); void finish_data() { generic_data(); } void finish(); @@ -107,13 +107,13 @@ private slots: void forwardOnly(); // bug specific tests - void bitField_data(); + void bitField_data() {generic_data("QTDS"); } void bitField(); - void nullBlob_data(); + void nullBlob_data() { generic_data("QOCI"); } void nullBlob(); void blob_data() { generic_data(); } void blob(); - void rawField_data(); + void rawField_data() { generic_data("QOCI"); } void rawField(); void precision_data() { generic_data(); } void precision(); @@ -129,19 +129,19 @@ private slots: void char1SelectUnicode(); void synonyms_data() { generic_data(); } void synonyms(); - void oraOutValues_data(); + void oraOutValues_data() { generic_data("QOCI"); } void oraOutValues(); - void mysqlOutValues_data(); + void mysqlOutValues_data() { generic_data("QMYSQL"); } void mysqlOutValues(); - void oraClob_data() { oraOutValues_data(); } + void oraClob_data() { generic_data("QOCI"); } void oraClob(); - void oraLong_data() { oraOutValues_data(); } + void oraLong_data() { generic_data("QOCI"); } void oraLong(); - void outValuesDB2_data(); + void outValuesDB2_data() { generic_data("QDB2"); } void outValuesDB2(); - void storedProceduresIBase_data(); + void storedProceduresIBase_data() {generic_data("QIBASE"); } void storedProceduresIBase(); - void oraRowId_data(); + void oraRowId_data() { generic_data("QOCI"); } void oraRowId(); void prepare_bind_exec_data() { generic_data(); } void prepare_bind_exec(); @@ -175,13 +175,13 @@ private slots: void emptyTableNavigate(); #ifdef NOT_READY_YET - void bug217003_data() { generic_data(); } - void bug217003(); + void task_217003_data() { generic_data(); } + void task_217003(); #endif private: // returns all database connections - void generic_data(); + void generic_data(const QString &engine=QString()); void dropTestTables( QSqlDatabase db ); void createTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -247,28 +247,14 @@ void tst_QSqlQuery::cleanup() } } -void tst_QSqlQuery::bitField_data() +void tst_QSqlQuery::generic_data(const QString& engine) { - if ( dbs.fillTestTable( "QTDS" ) == 0 ) - QSKIP( "No TDS database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::nullBlob_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::rawField_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::generic_data() -{ - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) @@ -421,12 +407,6 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP( "Database not unicode capable", SkipSingle ); } -void tst_QSqlQuery::oraRowId_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::oraRowId() { QFETCH( QString, dbName ); @@ -461,12 +441,6 @@ void tst_QSqlQuery::oraRowId() QCOMPARE( q.value( 0 ).toString(), QString( "b" ) ); } -void tst_QSqlQuery::mysqlOutValues_data() -{ - if ( dbs.fillTestTable( "QMYSQL" ) == 0 ) - QSKIP( "No MySQL database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::mysqlOutValues() { QFETCH( QString, dbName ); @@ -517,12 +491,6 @@ void tst_QSqlQuery::mysqlOutValues() QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); } -void tst_QSqlQuery::oraOutValues_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::oraOutValues() { QFETCH( QString, dbName ); @@ -670,18 +638,11 @@ void tst_QSqlQuery::oraClob() QVERIFY( q.value( 1 ).toByteArray() == loong.toLatin1() ); } -void tst_QSqlQuery::storedProceduresIBase_data() -{ - if ( dbs.fillTestTable( "QIBASE" ) == 0 ) - QSKIP( "No Interbase database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::storedProceduresIBase() { QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QIBASE" ); QSqlQuery q( db ); q.exec( "drop procedure " + qTableName( "TESTPROC" ) ); @@ -713,12 +674,6 @@ void tst_QSqlQuery::storedProceduresIBase() q.exec( "drop procedure " + qTableName( "TestProc" ) ); } -void tst_QSqlQuery::outValuesDB2_data() -{ - if ( dbs.fillTestTable( "QDB2" ) == 0 ) - QSKIP( "No DB2 database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::outValuesDB2() { QFETCH( QString, dbName ); @@ -1355,7 +1310,6 @@ void tst_QSqlQuery::nullBlob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_nullblob" ) + " (id int primary key, bb blob)" ) ); @@ -1385,7 +1339,6 @@ void tst_QSqlQuery::rawField() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); q.setForwardOnly( true ); @@ -2103,7 +2056,6 @@ void tst_QSqlQuery::record_sqlite() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QSQLITE" ); QSqlQuery q( db ); @@ -2131,7 +2083,6 @@ void tst_QSqlQuery::oraLong() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); @@ -2158,7 +2109,7 @@ void tst_QSqlQuery::execErrorRecovery() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int primary key)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int not null primary key)" ) ); QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr" ) + " values (?)" ) ); q.addBindValue( 1 ); @@ -2698,7 +2649,7 @@ void tst_QSqlQuery::emptyTableNavigate() } #ifdef NOT_READY_YET -void tst_QSqlQuery::bug217003() +void tst_QSqlQuery::task_217003() { QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index 63202f8..88b5770 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -95,7 +95,7 @@ private slots: void setQueryWithNoRowsInResultSet(); private: - void generic_data(); + void generic_data(const QString &engine=QString()); void dropTestTables(QSqlDatabase db); void createTestTables(QSqlDatabase db); void populateTestTables(QSqlDatabase db); @@ -202,10 +202,14 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); } -void tst_QSqlQueryModel::generic_data() +void tst_QSqlQueryModel::generic_data(const QString& engine) { - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlQueryModel::init() diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index 6015d1c..d4affe4 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -66,38 +66,59 @@ public: tst_Databases dbs; public slots: - void initTestCase_data(); void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); private slots: + void select_data() { generic_data(); } void select(); + void submitAll_data() { generic_data(); } void submitAll(); - void setRecord_data(); + void setRecord_data() { generic_data(); } void setRecord(); + void insertRow_data() { generic_data(); } void insertRow(); + void insertRecord_data() { generic_data(); } void insertRecord(); + void insertMultiRecords_data() { generic_data(); } void insertMultiRecords(); + void removeRow_data() { generic_data(); } void removeRow(); + void removeRows_data() { generic_data(); } void removeRows(); + void removeInsertedRow_data() { generic_data(); } void removeInsertedRow(); + void setFilter_data() { generic_data(); } void setFilter(); + void setInvalidFilter_data() { generic_data(); } void setInvalidFilter(); + void emptyTable_data() { generic_data(); } void emptyTable(); + void tablesAndSchemas_data() { generic_data("QPSQL"); } void tablesAndSchemas(); + void whitespaceInIdentifiers_data() { generic_data(); } void whitespaceInIdentifiers(); + void primaryKeyOrder_data() { generic_data("QSQLITE"); } void primaryKeyOrder(); + void sqlite_bigTable_data() { generic_data("QSQLITE"); } void sqlite_bigTable(); // bug specific tests + void insertRecordBeforeSelect_data() { generic_data(); } void insertRecordBeforeSelect(); + void submitAllOnInvalidTable_data() { generic_data(); } void submitAllOnInvalidTable(); + void insertRecordsInLoop_data() { generic_data(); } void insertRecordsInLoop(); + void sqlite_attachedDatabase_data() { generic_data("QSQLITE"); } void sqlite_attachedDatabase(); // For task 130799 + +private: + void generic_data(const QString& engine=QString()); }; tst_QSqlTableModel::tst_QSqlTableModel() @@ -121,7 +142,8 @@ void tst_QSqlTableModel::dropTestTables() << qTableName("test2") << qTableName("test3") << qTableName("emptytable") - << qTableName("bigtable"); + << qTableName("bigtable") + << qTableName("foo"); if (testWhiteSpaceNames(db.driverName())) tableNames << qTableName("qtestw hitespace"); @@ -160,16 +182,16 @@ void tst_QSqlTableModel::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL( q, exec("delete from " + qTableName("test"))); + q.exec("delete from " + qTableName("test")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); - QVERIFY_SQL( q, exec("delete from " + qTableName("test2"))); + q.exec("delete from " + qTableName("test2")); QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); - QVERIFY_SQL( q, exec("delete from " + qTableName("test3"))); + q.exec("delete from " + qTableName("test3")); QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(1, 'foo', 'bar')")); QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(2, 'baz', 'joe')")); } @@ -182,11 +204,13 @@ void tst_QSqlTableModel::recreateTestTables() repopulateTestTables(); } -void tst_QSqlTableModel::initTestCase_data() +void tst_QSqlTableModel::generic_data(const QString &engine) { - if (dbs.fillTestTable() == 0) { - qWarning("NO DATABASES"); - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); } } @@ -212,7 +236,7 @@ void tst_QSqlTableModel::cleanup() void tst_QSqlTableModel::select() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -245,58 +269,51 @@ void tst_QSqlTableModel::select() QCOMPARE(model.data(model.index(3, 3)), QVariant()); } -void tst_QSqlTableModel::setRecord_data() -{ - QTest::addColumn<uint>("submitpolicy"); - QTest::newRow("OnFieldChange") << (uint)QSqlTableModel::OnFieldChange; - QTest::newRow("OnRowChange") << (uint)QSqlTableModel::OnRowChange; - QTest::newRow("OnManualSubmit") << (uint)QSqlTableModel::OnManualSubmit; -} - void tst_QSqlTableModel::setRecord() { - // This needs to be tested with ODBC, which requires a manual change to qsqldatabase\tst_databases.h - // to ensure an ODBC db is added - - QFETCH_GLOBAL(QString, dbName); - QFETCH(uint, submitpolicy); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlTableModel model(0, db); - model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); - model.setTable(qTableName("test3")); - model.setSort(0, Qt::AscendingOrder); - QVERIFY_SQL(model, select()); + QList<QSqlTableModel::EditStrategy> policies = QList<QSqlTableModel::EditStrategy>() << QSqlTableModel::OnFieldChange << QSqlTableModel::OnRowChange << QSqlTableModel::OnManualSubmit; + + foreach( QSqlTableModel::EditStrategy submitpolicy, policies) { + + QSqlTableModel model(0, db); + model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); + model.setTable(qTableName("test3")); + model.setSort(0, Qt::AscendingOrder); + QVERIFY_SQL(model, select()); - for (int i = 0; i < model.rowCount(); ++i) { - QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); - - QSqlRecord rec = model.record(i); - rec.setValue(1, rec.value(1).toString() + 'X'); - rec.setValue(2, rec.value(2).toString() + 'X'); - QVERIFY(model.setRecord(i, rec)); - - if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) - QVERIFY(model.submitAll()); - else { - // dataChanged() is not emitted when submitAll() is called - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(0).count(), 2); - QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1)); - QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1)); + for (int i = 0; i < model.rowCount(); ++i) { + QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + + QSqlRecord rec = model.record(i); + rec.setValue(1, rec.value(1).toString() + 'X'); + rec.setValue(2, rec.value(2).toString() + 'X'); + QVERIFY(model.setRecord(i, rec)); + + if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) + QVERIFY(model.submitAll()); + else { + // dataChanged() is not emitted when submitAll() is called + QCOMPARE(spy.count(), 2); + QCOMPARE(spy.at(0).count(), 2); + QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1)); + QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1)); + } } - } - QCOMPARE(model.data(model.index(0, 1)).toString(), QString("fooX")); - QCOMPARE(model.data(model.index(0, 2)).toString(), QString("barX")); - QCOMPARE(model.data(model.index(1, 1)).toString(), QString("bazX")); - QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joeX")); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("fooX")); + QCOMPARE(model.data(model.index(0, 2)).toString(), QString("barX")); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("bazX")); + QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joeX")); + } } void tst_QSqlTableModel::insertRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -321,7 +338,7 @@ void tst_QSqlTableModel::insertRow() void tst_QSqlTableModel::insertRecord() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -354,7 +371,7 @@ void tst_QSqlTableModel::insertRecord() void tst_QSqlTableModel::insertMultiRecords() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -403,7 +420,7 @@ void tst_QSqlTableModel::insertMultiRecords() void tst_QSqlTableModel::submitAll() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -438,7 +455,7 @@ void tst_QSqlTableModel::submitAll() void tst_QSqlTableModel::removeRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -484,7 +501,7 @@ void tst_QSqlTableModel::removeRow() void tst_QSqlTableModel::removeRows() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -533,7 +550,7 @@ void tst_QSqlTableModel::removeRows() void tst_QSqlTableModel::removeInsertedRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -565,7 +582,7 @@ void tst_QSqlTableModel::removeInsertedRow() void tst_QSqlTableModel::emptyTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -584,12 +601,10 @@ void tst_QSqlTableModel::emptyTable() void tst_QSqlTableModel::tablesAndSchemas() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); - QSqlQuery q(db); q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); QVERIFY_SQL( q, exec("create schema " + qTableName("testschema"))); @@ -607,7 +622,7 @@ void tst_QSqlTableModel::tablesAndSchemas() void tst_QSqlTableModel::whitespaceInIdentifiers() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -623,16 +638,16 @@ void tst_QSqlTableModel::whitespaceInIdentifiers() void tst_QSqlTableModel::primaryKeyOrder() { - QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "primaryKeyOrderTest"); - db.setDatabaseName(":memory:"); - QVERIFY_SQL(db, open()); + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table foo(a varchar(20), id int primary key, b varchar(20))")); + QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))")); QSqlTableModel model(0, db); - model.setTable("foo"); + model.setTable(qTableName("foo")); QSqlIndex pk = model.primaryKey(); QCOMPARE(pk.count(), 1); @@ -652,7 +667,7 @@ void tst_QSqlTableModel::primaryKeyOrder() void tst_QSqlTableModel::setInvalidFilter() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -671,7 +686,7 @@ void tst_QSqlTableModel::setInvalidFilter() void tst_QSqlTableModel::setFilter() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -724,12 +739,10 @@ void tst_QSqlTableModel::setFilter() void tst_QSqlTableModel::sqlite_bigTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); - bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions); if (hasTransactions) QVERIFY(db.transaction()); QSqlQuery q(db); @@ -763,7 +776,7 @@ void tst_QSqlTableModel::sqlite_bigTable() // had first been called. void tst_QSqlTableModel::insertRecordBeforeSelect() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -796,7 +809,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() // are inserted and submitted on a non-existing table. void tst_QSqlTableModel::submitAllOnInvalidTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -828,7 +841,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable() // For task 147575: the rowsRemoved signal emitted from the model was lying void tst_QSqlTableModel::insertRecordsInLoop() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -866,12 +879,10 @@ void tst_QSqlTableModel::insertRecordsInLoop() void tst_QSqlTableModel::sqlite_attachedDatabase() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); - QSqlDatabase attachedDb = QSqlDatabase::cloneDatabase(db, db.driverName() + QLatin1String("attached")); attachedDb.setDatabaseName(db.databaseName()+QLatin1String("attached.dat")); QVERIFY_SQL(attachedDb, open()); diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp index 94e0f98..d871be4 100644 --- a/tests/auto/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp @@ -286,10 +286,14 @@ tst_QSqlThread::~tst_QSqlThread() { } -void tst_QSqlThread::generic_data() +void tst_QSqlThread::generic_data(const QString& engine) { - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlThread::dropTestTables() diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index a60433a..5a6cce8 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -60,6 +60,8 @@ #include <QTextCodec> #include <QProcess> +#include "../network-settings.h" + static const char *TestFileName = "testfile"; Q_DECLARE_METATYPE(qlonglong) @@ -1229,7 +1231,7 @@ void tst_QTextStream::stillOpenWhenAtEnd() QSKIP("Qt/CE: Cannot test network on emulator", SkipAll); #endif QTcpSocket socket; - socket.connectToHost("imap.troll.no", 143); + socket.connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket.waitForReadyRead(5000)); QTextStream stream2(&socket); |