diff options
Diffstat (limited to 'tests')
19 files changed, 286 insertions, 114 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 0a55da5b7e..749c7da789 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -765,7 +765,7 @@ void tst_qmessagehandler::qMessagePattern_data() // %{time} should have a padding of 6 so if it takes less than 10 seconds to show // the first message, there should be 5 spaces - QTest::newRow("time") << "<%{time}>%{message}" << true << (QList<QByteArray>() + QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList<QByteArray>() << "< "); #ifdef __GLIBC__ diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index d5f976ed64..122427a021 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -3618,7 +3618,7 @@ class SignalArgumentChecker : public QObject Q_OBJECT public: SignalArgumentChecker(QAbstractItemModel *model, QAbstractProxyModel *proxy, QObject *parent = 0) - : QObject(parent), m_model(model), m_proxy(proxy) + : QObject(parent), m_proxy(proxy) { connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(rowsMoved(QModelIndex,int,int,QModelIndex,int))); @@ -3668,7 +3668,6 @@ private slots: } private: - QAbstractItemModel *m_model; QAbstractProxyModel *m_proxy; QPersistentModelIndex m_p1PersistentBefore; QPersistentModelIndex m_p2PersistentBefore; diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 6372fbb0e2..972205566a 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -33,14 +33,16 @@ #include <QtCore/QtCore> #include <QtTest/QtTest> #include <QtDBus/QtDBus> -#include <QtDBus/private/qdbusutil_p.h> -#include <QtDBus/private/qdbusconnection_p.h> #include "common.h" #include <limits> #include <dbus/dbus.h> +#define QT_LINKED_LIBDBUS +#include <QtDBus/private/qdbusutil_p.h> +#include <QtDBus/private/qdbusconnection_p.h> + static const char serviceName[] = "org.qtproject.autotests.qpong"; static const char objectPath[] = "/org/qtproject/qpong"; static const char *interfaceName = serviceName; diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 7a0683c3bf..1f6bcbd341 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -250,17 +250,11 @@ void tst_QWindow::resizeEventAfterResize() void tst_QWindow::positioning_data() { QTest::addColumn<int>("windowflags"); - QTest::addColumn<int>("resizecount"); - QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint) -#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 - << 4; -#else - << 3; -#endif + QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint); #ifdef Q_OS_OSX - QTest::newRow("fake") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) << 4; + QTest::newRow("fake") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); #endif } @@ -279,7 +273,6 @@ void tst_QWindow::positioning() const QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize); QFETCH(int, windowflags); - QFETCH(int, resizecount); Window window((Qt::WindowFlags)windowflags); window.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20), m_testWindowSize)); window.setFramePosition(m_availableTopLeft + QPoint(40, 40)); // Move window around before show, size must not change. @@ -290,8 +283,7 @@ void tst_QWindow::positioning() window.showNormal(); QCoreApplication::processEvents(); - QTRY_COMPARE(window.received(QEvent::Resize), 1); - QTRY_VERIFY(window.received(QEvent::Expose) > 0); + QTest::qWaitForWindowExposed(&window); QMargins originalMargins = window.frameMargins(); @@ -301,25 +293,22 @@ void tst_QWindow::positioning() QPoint originalPos = window.position(); QPoint originalFramePos = window.framePosition(); + window.reset(); window.setWindowState(Qt::WindowFullScreen); QCoreApplication::processEvents(); -#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen - // so we only expect one resize event - Q_UNUSED(resizecount); - QTRY_COMPARE(window.received(QEvent::Resize), 1); -#else - QTRY_COMPARE(window.received(QEvent::Resize), 2); + // On BB10 the window is the root window and fullscreen, so nothing is resized. +#if !defined(Q_OS_BLACKBERRY) + QTRY_VERIFY(window.received(QEvent::Resize) > 0); #endif QTest::qWait(2000); + window.reset(); window.setWindowState(Qt::WindowNoState); QCoreApplication::processEvents(); -#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen - // so we only expect one resize event - QTRY_COMPARE(window.received(QEvent::Resize), 1); -#else - QTRY_COMPARE(window.received(QEvent::Resize), resizecount); + // On BB10 the window is the root window and fullscreen, so nothing is resized. +#if !defined(Q_OS_BLACKBERRY) + QTRY_VERIFY(window.received(QEvent::Resize) > 0); #endif QTRY_COMPARE(originalPos, window.position()); @@ -329,7 +318,7 @@ void tst_QWindow::positioning() // if our positioning is actually fully respected by the window manager // test whether it correctly handles frame positioning as well if (originalPos == geometry.topLeft() && (originalMargins.top() != 0 || originalMargins.left() != 0)) { - QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().topLeft() + QPoint(40, 40); + QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().center(); window.reset(); window.setFramePosition(framePos); diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 49ff1b48fe..82050e73fd 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -1312,7 +1312,7 @@ void tst_QSslCertificate::pkcs12() #ifdef QT_NO_OPENSSL QEXPECT_FAIL("", "QTBUG-40884: WinRT API does not support pkcs12 imports", Abort); #endif - ok = QSslCertificate::importPKCS12(&f, &key, &cert, &caCerts); + ok = QSslCertificate::importPkcs12(&f, &key, &cert, &caCerts); QVERIFY(ok); f.close(); diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST new file mode 100644 index 0000000000..17b606e2be --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -0,0 +1,2 @@ +[waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth] +* diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index d5ccc194bb..af6dc6b9f4 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -385,7 +385,7 @@ public: bool wasDropped; QSqlQuery q( db ); QStringList dbtables=db.tables(); - QSqlDriver::DBMSType dbType = getDatabaseType(db); + QSqlDriver::DbmsType dbType = getDatabaseType(db); foreach(const QString &tableName, tableNames) { wasDropped = true; @@ -462,7 +462,7 @@ public: // blobSize is only used if the db doesn't have a generic blob type static QString blobTypeName( QSqlDatabase db, int blobSize = 10000 ) { - const QSqlDriver::DBMSType dbType = getDatabaseType(db); + const QSqlDriver::DbmsType dbType = getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) return "longblob"; @@ -491,7 +491,7 @@ public: static QString dateTimeTypeName(QSqlDatabase db) { - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) return QLatin1String("timestamp"); if (dbType == QSqlDriver::Oracle && getOraVersion(db) >= 9) @@ -501,7 +501,7 @@ public: static QString autoFieldName( QSqlDatabase db ) { - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) return "AUTO_INCREMENT"; if (dbType == QSqlDriver::Sybase || dbType == QSqlDriver::MSSqlServer) @@ -538,7 +538,7 @@ public: return result.toLocal8Bit(); } - static QSqlDriver::DBMSType getDatabaseType(QSqlDatabase db) + static QSqlDriver::DbmsType getDatabaseType(QSqlDatabase db) { QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver())); return d->dbmsType; diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 6faf8b7ed5..c314528065 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -234,7 +234,7 @@ struct FieldDef { // excluding the primary key field static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) { - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString tableName = qTableName("qtestfields", __FILE__, db); tst_Databases::safeDropTable(db, tableName); QSqlQuery q(db); @@ -281,7 +281,7 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db) return; const QString tableName = qTableName("qtest", __FILE__, db); QSqlQuery q(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) { // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script @@ -318,7 +318,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) if (!db.isValid()) return; - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) { QSqlQuery q(db); QVERIFY_SQL( q, exec("set client_min_messages='warning'")); @@ -485,7 +485,7 @@ void tst_QSqlDatabase::open() QVERIFY(!db.isOpenError()); } - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::SQLite && db.databaseName() == ":memory:") { // tables in in-memory databases don't survive an open/close createTestTables(db); @@ -498,7 +498,7 @@ void tst_QSqlDatabase::tables() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtest(qTableName("qtest", __FILE__, db)), qtest_view(qTableName("qtest_view", __FILE__, db)), temp_tab(qTableName("test_tab", __FILE__, db)); @@ -562,7 +562,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (testWhiteSpaceNames(db.driverName())) { const QString tableName(qTableName("qtest", __FILE__, db) + " test"); @@ -830,7 +830,7 @@ void tst_QSqlDatabase::recordPSQL() QSqlQuery q(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); const QString tableName = qTableName("qtestfields", __FILE__, db); @@ -1017,7 +1017,7 @@ void tst_QSqlDatabase::recordSQLServer() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL server specific test"); @@ -1076,7 +1076,7 @@ void tst_QSqlDatabase::transaction() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtest(qTableName("qtest", __FILE__, db)); if (!db.driver()->hasFeature(QSqlDriver::Transactions)) @@ -1124,7 +1124,7 @@ void tst_QSqlDatabase::bigIntField() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtest_bigint(qTableName("qtest_bigint", __FILE__, db)); QSqlQuery q(db); @@ -1189,7 +1189,7 @@ void tst_QSqlDatabase::caseSensivity() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); bool cs = false; if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::Sybase @@ -1222,7 +1222,7 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord() CHECK_DATABASE(db); QString fieldname("t_varchar"); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::Interbase || dbType == QSqlDriver::DB2) fieldname = fieldname.toUpper(); @@ -1405,7 +1405,7 @@ void tst_QSqlDatabase::precisionPolicy() QString query = QString("SELECT num FROM %1 WHERE id = 1").arg(tableName); QVERIFY_SQL(q, exec(query)); QVERIFY_SQL(q, next()); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::SQLite) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); QCOMPARE(q.value(0).type(), QVariant::String); @@ -1742,7 +1742,7 @@ void tst_QSqlDatabase::odbc_bindBoolean() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) QSKIP("MySql has inconsistent behaviour of bit field type across versions."); @@ -1777,7 +1777,7 @@ void tst_QSqlDatabase::odbc_testqGetString() const QString testqGetString(qTableName("testqGetString", __FILE__, db)); QSqlQuery q(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MSSqlServer) QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(MAX))")); else if(tst_Databases::isMSAccess(db)) @@ -1957,7 +1957,7 @@ void tst_QSqlDatabase::odbc_uniqueidentifier() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server (ODBC) specific test"); diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index fa0f7eaf34..7c0b4ebc88 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -71,7 +71,7 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) QSqlQuery q(db); const QString relTEST1(qTableName("relTEST1", __FILE__, db)); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); @@ -122,7 +122,7 @@ void tst_QSqlDriver::record() QSqlRecord rec = db.driver()->record(tablename); QCOMPARE(rec.count(), 4); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); // QTBUG-1363: QSqlField::length() always return -1 when using QODBC3 driver and QSqlDatabase::record() if (dbType == QSqlDriver::MSSqlServer && db.driverName().startsWith("QODBC")) QCOMPARE(rec.field(1).length(), 20); @@ -174,7 +174,7 @@ void tst_QSqlDriver::primaryIndex() QSqlIndex index = db.driver()->primaryIndex(tablename); QCOMPARE(index.count(), 1); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) QCOMPARE(index.fieldName(0), QString::fromLatin1("ID")); else diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index b4863d4a82..f5d71a75cf 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -283,7 +283,7 @@ void tst_QSqlQuery::cleanup() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" ) || QTest::currentTestFunction() == QLatin1String( "transactions" ) || QTest::currentTestFunction() == QLatin1String( "size" ) @@ -311,7 +311,7 @@ void tst_QSqlQuery::generic_data(const QString& engine) void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QStringList tablenames; // drop all the table in case a testcase failed tablenames << qtest @@ -374,7 +374,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) void tst_QSqlQuery::createTestTables( QSqlDatabase db ) { QSqlQuery q( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script @@ -426,7 +426,7 @@ void tst_QSqlQuery::char1Select() QVERIFY_SQL(q, exec("insert into " + tbl + " values ('a')")); QVERIFY_SQL(q, exec("select * from " + tbl)); QVERIFY( q.next() ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Interbase) QCOMPARE( q.value( 0 ).toString().left( 1 ), QString( "a" ) ); else @@ -441,7 +441,7 @@ void tst_QSqlQuery::char1SelectUnicode() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::DB2) QSKIP("Needs someone with more Unicode knowledge than I have to fix"); @@ -588,7 +588,7 @@ void tst_QSqlQuery::bindBool() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString tableName(qTableName("bindBool", __FILE__, db)); q.exec("DROP TABLE " + tableName); @@ -845,7 +845,7 @@ void tst_QSqlQuery::outValues() QSqlQuery q( db ); q.setForwardOnly( true ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Oracle) { QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" @@ -934,7 +934,7 @@ void tst_QSqlQuery::value() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q( db ); QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); int i = 1; @@ -1520,7 +1520,7 @@ void tst_QSqlQuery::precision() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Interbase) QSKIP("DB unable to store high precision"); @@ -1596,7 +1596,7 @@ void tst_QSqlQuery::transaction() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if ( !db.driver()->hasFeature( QSqlDriver::Transactions ) ) QSKIP( "DBMS not transaction capable"); @@ -1679,7 +1679,7 @@ void tst_QSqlQuery::joins() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtestj1(qTableName("qtestj1", __FILE__, db)), qtestj2(qTableName("qtestj2", __FILE__, db)); if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::Sybase @@ -1763,7 +1763,7 @@ void tst_QSqlQuery::prepare_bind_exec() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db)); if (dbType == QSqlDriver::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) @@ -1785,7 +1785,7 @@ void tst_QSqlQuery::prepare_bind_exec() useUnicode = false; QString createQuery; - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); @@ -2059,7 +2059,7 @@ void tst_QSqlQuery::sqlServerLongStrings() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer) QSKIP( "SQL Server specific test"); @@ -2105,7 +2105,7 @@ void tst_QSqlQuery::invalidQuery() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q( db ); QVERIFY( !q.exec() ); @@ -2442,7 +2442,7 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); // Only supported by these drivers if (dbType != QSqlDriver::PostgreSQL && dbType != QSqlDriver::Oracle @@ -2574,7 +2574,7 @@ void tst_QSqlQuery::nextResult() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if ( !db.driver()->hasFeature( QSqlDriver::MultipleResultSets ) || !db.driver()->hasFeature( QSqlDriver::BatchOperations ) ) QSKIP( "DBMS does not support multiple result sets or batch operations"); @@ -2774,7 +2774,7 @@ void tst_QSqlQuery::blobsPreparedQuery() // In PostgreSQL a BLOB is not called a BLOB, but a BYTEA! :-) // ... and in SQL Server it can be called a lot, but IMAGE will do. - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QString typeName( "BLOB" ); if (dbType == QSqlDriver::PostgreSQL) typeName = "BYTEA"; @@ -3053,7 +3053,7 @@ void tst_QSqlQuery::sqlServerReturn0() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server specific test"); @@ -3169,7 +3169,7 @@ void tst_QSqlQuery::QTBUG_18435() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer || !db.driverName().startsWith("QODBC")) QSKIP("SQL Server specific test"); @@ -3251,7 +3251,7 @@ void tst_QSqlQuery::QTBUG_6618() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::MSSqlServer) QSKIP("SQL Server specific test"); @@ -3668,7 +3668,7 @@ void tst_QSqlQuery::sqlite_constraint() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::SQLite) QSKIP("Sqlite3 specific test"); @@ -3720,7 +3720,7 @@ void tst_QSqlQuery::aggregateFunctionTypes() CHECK_DATABASE(db); QVariant::Type intType = QVariant::Int; // QPSQL uses LongLong for manipulation of integers - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::PostgreSQL) intType = QVariant::LongLong; else if (dbType == QSqlDriver::Oracle) diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp index 84e2fd57de..fc10f21904 100644 --- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -150,7 +150,7 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db) { dropTestTables(db); QSqlQuery q(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__, db) + "(id integer not null, name varchar(20), title integer, primary key (id))")); @@ -305,7 +305,7 @@ void tst_QSqlQueryModel::insertColumn() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); DBTestModel model; model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db)); @@ -409,7 +409,7 @@ void tst_QSqlQueryModel::record() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQueryModel model; model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db)); @@ -440,7 +440,7 @@ void tst_QSqlQueryModel::setHeaderData() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQueryModel model; diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index e97c391a52..a32c672370 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -143,7 +143,7 @@ void tst_QSqlRelationalTableModel::initTestCase() { foreach (const QString &dbname, dbs.dbNames) { QSqlDatabase db=QSqlDatabase::database(dbname); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Interbase) { db.exec("SET DIALECT 3"); } else if (dbType == QSqlDriver::MSSqlServer) { @@ -238,7 +238,7 @@ void tst_QSqlRelationalTableModel::setData() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); // set the values using OnRowChange Strategy { @@ -554,7 +554,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); @@ -746,7 +746,7 @@ void tst_QSqlRelationalTableModel::sort() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); @@ -912,7 +912,7 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); @@ -966,7 +966,7 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlRelationalTableModel model(0, db); model.setTable(reltest3); @@ -1088,7 +1088,7 @@ void tst_QSqlRelationalTableModel::casing() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::SQLite || dbType == QSqlDriver::MSSqlServer) QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities"); @@ -1155,7 +1155,7 @@ void tst_QSqlRelationalTableModel::escapedRelations() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); recreateTestTables(db); @@ -1266,7 +1266,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); // set the values using OnRowChange Strategy with an escaped tablename { @@ -1455,7 +1455,7 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() QFETCH_GLOBAL(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType != QSqlDriver::PostgreSQL) QSKIP("Postgresql specific test"); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index b77b883b03..f0aaa36170 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -160,7 +160,7 @@ void tst_QSqlTableModel::dropTestTables() { for (int i = 0; i < dbs.dbNames.count(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); if (dbType == QSqlDriver::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); @@ -189,7 +189,7 @@ void tst_QSqlTableModel::createTestTables() { for (int i = 0; i < dbs.dbNames.count(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)")); @@ -1699,7 +1699,7 @@ void tst_QSqlTableModel::primaryKeyOrder() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index f2a40576f6..f487e256a3 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -180,6 +180,16 @@ public: { doAutoScroll(); } }; +class GeometriesTestView : public QTableView +{ + Q_OBJECT +public: + GeometriesTestView() : QTableView(), updateGeometriesCalled(false) {} + bool updateGeometriesCalled; +protected slots: + void updateGeometries() Q_DECL_OVERRIDE { updateGeometriesCalled = true; QTableView::updateGeometries(); } +}; + class tst_QAbstractItemView : public QObject { Q_OBJECT @@ -241,6 +251,7 @@ private slots: void testFocusPolicy(); void QTBUG31411_noSelection(); void QTBUG39324_settingSameInstanceOfIndexWidget(); + void sizeHintChangeTriggersLayout(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -248,7 +259,7 @@ class MyAbstractItemDelegate : public QAbstractItemDelegate public: MyAbstractItemDelegate() : QAbstractItemDelegate() { calledVirtualDtor = false; } void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const {} - QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); } + QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return size; } QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const { openedEditor = new QWidget(parent); @@ -259,9 +270,10 @@ public: calledVirtualDtor = true; editor->deleteLater(); } - + void changeSize() { size = QSize(50, 50); emit sizeHintChanged(QModelIndex()); } mutable bool calledVirtualDtor; mutable QWidget *openedEditor; + QSize size; }; // Testing get/set functions @@ -730,6 +742,34 @@ void tst_QAbstractItemView::columnDelegate() QCOMPARE(w->metaObject()->className(), "QWidget"); } +void tst_QAbstractItemView::sizeHintChangeTriggersLayout() +{ + QStandardItemModel model(4, 4); + MyAbstractItemDelegate delegate; + MyAbstractItemDelegate rowDelegate; + MyAbstractItemDelegate columnDelegate; + + GeometriesTestView view; + view.setModel(&model); + view.setItemDelegate(&delegate); + view.setItemDelegateForRow(1, &rowDelegate); + view.setItemDelegateForColumn(2, &columnDelegate); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.updateGeometriesCalled = false; + delegate.changeSize(); + QCoreApplication::sendPostedEvents(); + QVERIFY(view.updateGeometriesCalled); + view.updateGeometriesCalled = false; + rowDelegate.changeSize(); + QCoreApplication::sendPostedEvents(); + QVERIFY(view.updateGeometriesCalled); + view.updateGeometriesCalled = false; + columnDelegate.changeSize(); + QCoreApplication::sendPostedEvents(); + QVERIFY(view.updateGeometriesCalled); +} + void tst_QAbstractItemView::selectAll() { QStandardItemModel model(4,4); diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 61ec15a135..1be3f8a4ef 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -40,6 +40,8 @@ #include <qdockwidget.h> #include <qmainwindow.h> +#include <qscreen.h> +#include <qscopedpointer.h> class Window : public QWindow @@ -65,6 +67,10 @@ public: class tst_QWindowContainer: public QObject { Q_OBJECT + +public: + tst_QWindowContainer() : m_availableGeometry(QGuiApplication::primaryScreen()->availableGeometry()) {} + private slots: void testShow(); void testPositionAndSize(); @@ -75,14 +81,22 @@ private slots: void testActivation(); void testAncestorChange(); void testDockWidget(); -}; + void cleanup(); +private: + const QRect m_availableGeometry; +}; +void tst_QWindowContainer::cleanup() +{ + QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); +} void tst_QWindowContainer::testShow() { QWidget root; - root.setGeometry(100, 100, 400, 400); + root.setWindowTitle(QTest::currentTestFunction()); + root.setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 400, 400); Window *window = new Window(); QWidget *container = QWidget::createWindowContainer(window, &root); @@ -99,14 +113,15 @@ void tst_QWindowContainer::testShow() void tst_QWindowContainer::testPositionAndSize() { QWindow *window = new QWindow(); - window->setGeometry(300, 400, 500, 600); + window->setGeometry(m_availableGeometry.x() + 300, m_availableGeometry.y() + 400, 500, 600); - QWidget *container = QWidget::createWindowContainer(window); + QScopedPointer<QWidget> container(QWidget::createWindowContainer(window)); + container->setWindowTitle(QTest::currentTestFunction()); container->setGeometry(50, 50, 200, 200); container->show(); - QVERIFY(QTest::qWaitForWindowExposed(container)); + QVERIFY(QTest::qWaitForWindowExposed(container.data())); QCOMPARE(window->x(), 0); QCOMPARE(window->y(), 0); @@ -120,11 +135,12 @@ void tst_QWindowContainer::testExposeObscure() { Window *window = new Window(); - QWidget *container = QWidget::createWindowContainer(window); - container->setGeometry(50, 50, 200, 200); + QScopedPointer<QWidget> container(QWidget::createWindowContainer(window)); + container->setWindowTitle(QTest::currentTestFunction()); + container->setGeometry(m_availableGeometry.x() + 50, m_availableGeometry.y() + 50, 200, 200); container->show(); - QVERIFY(QTest::qWaitForWindowExposed(container)); + QVERIFY(QTest::qWaitForWindowExposed(container.data())); QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->numberOfExposes > 0); @@ -173,12 +189,13 @@ void tst_QWindowContainer::testBehindTheScenesDeletion() void tst_QWindowContainer::testActivation() { QWidget root; + root.setWindowTitle(QTest::currentTestFunction()); QWindow *window = new QWindow(); QWidget *container = QWidget::createWindowContainer(window, &root); container->setGeometry(100, 100, 200, 100); - root.setGeometry(100, 100, 400, 300); + root.setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 400, 300); root.show(); root.activateWindow(); @@ -212,14 +229,15 @@ void tst_QWindowContainer::testActivation() void tst_QWindowContainer::testUnparenting() { QWindow *window = new QWindow(); - QWidget *container = QWidget::createWindowContainer(window); - container->setGeometry(100, 100, 200, 100); + QScopedPointer<QWidget> container(QWidget::createWindowContainer(window)); + container->setWindowTitle(QTest::currentTestFunction()); + container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100); window->setParent(0); container->show(); - QVERIFY(QTest::qWaitForWindowExposed(container)); + QVERIFY(QTest::qWaitForWindowExposed(container.data())); // Window should not be made visible by container.. QVERIFY(!window->isVisible()); @@ -228,10 +246,12 @@ void tst_QWindowContainer::testUnparenting() void tst_QWindowContainer::testAncestorChange() { QWidget root; + root.setWindowTitle(QStringLiteral("Root ") + QTest::currentTestFunction()); QWidget *left = new QWidget(&root); QWidget *right = new QWidget(&root); - root.setGeometry(0, 0, 200, 100); + + root.setGeometry(m_availableGeometry.x() + 50, m_availableGeometry.y() + 50, 200, 100); left->setGeometry(0, 0, 100, 100); right->setGeometry(100, 0, 100, 100); @@ -257,6 +277,7 @@ void tst_QWindowContainer::testAncestorChange() QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); QWidget *newRoot = new QWidget(&root); + newRoot->setWindowTitle(QStringLiteral("newRoot ") + QTest::currentTestFunction()); newRoot->setGeometry(50, 50, 200, 200); right->setParent(newRoot); // Root @@ -270,7 +291,8 @@ void tst_QWindowContainer::testAncestorChange() QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); newRoot->setParent(0); - newRoot->setGeometry(100, 100, 200, 200); + QScopedPointer<QWidget> newRootGuard(newRoot); + newRoot->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 200); newRoot->show(); QVERIFY(QTest::qWaitForWindowExposed(newRoot)); QCOMPARE(newRoot->windowHandle(), window->parent()); @@ -285,9 +307,11 @@ void tst_QWindowContainer::testAncestorChange() void tst_QWindowContainer::testDockWidget() { QMainWindow mainWindow; + mainWindow.setWindowTitle(QTest::currentTestFunction()); mainWindow.resize(200, 200); + mainWindow.move(m_availableGeometry.center() - QPoint(100, 100)); - QDockWidget *dock = new QDockWidget(); + QDockWidget *dock = new QDockWidget(QStringLiteral("Dock ") + QTest::currentTestFunction()); QWindow *window = new QWindow(); QWidget *container = QWidget::createWindowContainer(window); dock->setWidget(container); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 751a16c59d..15f2f88a8d 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -46,6 +46,7 @@ #include <qlabel.h> #include <qtextedit.h> #include <qstylehints.h> +#include <qdesktopwidget.h> #include <private/qmainwindowlayout_p.h> #include <private/qdockarealayout_p.h> @@ -132,6 +133,8 @@ private slots: void saveRestore_data(); void statusBar(); #endif + void contentsMargins_data(); + void contentsMargins(); void isSeparator(); #ifndef QTEST_NO_CURSOR void setCursor(); @@ -749,8 +752,41 @@ void tst_QMainWindow::statusBar() QVERIFY(indexOfSb == -1); } } + #endif +void tst_QMainWindow::contentsMargins_data() +{ + QTest::addColumn<int>("contentsMargin"); + QTest::newRow("0") << 0; + QTest::newRow("10") << 10; +} + +void tst_QMainWindow::contentsMargins() +{ + QFETCH(int, contentsMargin); + + QMainWindow mw; + const QRect availGeometry = QApplication::desktop()->availableGeometry(); + mw.menuBar()->addMenu("File"); + mw.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); + mw.resize(availGeometry.size() / 4); + mw.move((availGeometry.width() - mw.width()) / 2, + (availGeometry.height() - mw.height()) / 2); + mw.setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin); + mw.statusBar()->showMessage("Hello"); + + mw.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); + + QCOMPARE(mw.menuBar()->geometry().left(), contentsMargin); + QCOMPARE(mw.menuBar()->geometry().top(), contentsMargin); + + QCOMPARE(mw.statusBar()->geometry().left(), contentsMargin); + QCOMPARE(mw.statusBar()->geometry().bottom() + 1, mw.height() - contentsMargin); +} + void tst_QMainWindow::centralWidget() { { diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f4e2cc174e..7588950b76 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -42,6 +42,8 @@ #include <qdesktopwidget.h> #include <qaction.h> #include <qstyleoption.h> +#include <QVBoxLayout> +#include <QLabel> #include <qscreen.h> #include <qobject.h> @@ -83,6 +85,7 @@ public: private slots: void getSetCheck(); + void cleanup(); void clear(); void removeItemAt(); @@ -126,6 +129,8 @@ private slots: #endif void taskQTBUG11823_crashwithInvisibleActions(); void closeOnSecondClick(); + void cornerWidgets_data(); + void cornerWidgets(); protected slots: void onSimpleActivated( QAction*); @@ -195,6 +200,11 @@ void tst_QMenuBar::onSimpleActivated( QAction* action ) m_simpleActivatedCount++; } +void tst_QMenuBar::cleanup() +{ + QVERIFY(QApplication::topLevelWidgets().isEmpty()); +} + // Create a simple menu bar and connect its actions to onSimpleActivated(). TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb) @@ -1325,5 +1335,75 @@ void tst_QMenuBar::closeOnSecondClick() // QTBUG-32807, menu should close on 2nd QTRY_VERIFY(!fileMenu->isVisible()); } +Q_DECLARE_METATYPE(Qt::Corner) + +void tst_QMenuBar::cornerWidgets_data() +{ + QTest::addColumn<Qt::Corner>("corner"); + QTest::newRow("left") << Qt::TopLeftCorner; + QTest::newRow("right") << Qt::TopRightCorner; +} + +static QByteArray msgComparison(int v1, const char *op, int v2) +{ + QString result; + QDebug(&result) << v1 << op << v2 << "failed"; + return result.toLocal8Bit(); +} + +void tst_QMenuBar::cornerWidgets() +{ + enum { cornerWidgetWidth = 100 }; + + QFETCH(Qt::Corner, corner); + +#if defined(Q_OS_OSX) || defined(Q_OS_WINCE) + QSKIP("Test interferes with native menu bars on this platform"); +#endif + + QWidget widget; + const QString dataTag = QLatin1String(QTest::currentDataTag()); + widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + dataTag); + QVBoxLayout *layout = new QVBoxLayout(&widget); + QMenuBar *menuBar = new QMenuBar(&widget); + layout->addWidget(menuBar); + QMenu *fileMenu = menuBar->addMenu("File"); + fileMenu->addAction("Quit"); + QMenu *editMenu =menuBar->addMenu("Edit"); + editMenu->addAction("Copy"); + centerOnScreen(&widget); + + QLabel *cornerLabel = new QLabel(dataTag); + cornerLabel->setFixedWidth(cornerWidgetWidth); + menuBar->setCornerWidget(cornerLabel, corner); + QCOMPARE(menuBar->cornerWidget(corner), cornerLabel); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + + const QRect fileMenuGeometry = menuBar->actionGeometry(fileMenu->menuAction()); + const QRect editMenuGeometry = menuBar->actionGeometry(editMenu->menuAction()); + const int menuBarWidth = menuBar->width(); + switch (corner) { // QTBUG-36010 , verify corner widget geometry is correct + case Qt::TopLeftCorner: + QVERIFY2(fileMenuGeometry.left() >= cornerWidgetWidth, + msgComparison(fileMenuGeometry.left(), ">=", cornerWidgetWidth)); + QVERIFY2(menuBarWidth - editMenuGeometry.right() < cornerWidgetWidth, + msgComparison(menuBarWidth - editMenuGeometry.right(), "<", cornerWidgetWidth)); + break; + case Qt::TopRightCorner: + QVERIFY2(fileMenuGeometry.left() < cornerWidgetWidth, + msgComparison(fileMenuGeometry.left(), "<", cornerWidgetWidth)); + QVERIFY2(menuBarWidth - editMenuGeometry.right() >= cornerWidgetWidth, + msgComparison(menuBarWidth - editMenuGeometry.right(), ">=", cornerWidgetWidth)); + break; + default: + break; + } + + menuBar->setCornerWidget(0, corner); // Don't crash. + QVERIFY(!menuBar->cornerWidget(corner)); + delete cornerLabel; +} + QTEST_MAIN(tst_QMenuBar) #include "tst_qmenubar.moc" diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp index 769dbe6d47..c8375a6d28 100644 --- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp +++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp @@ -109,7 +109,7 @@ void tst_QSqlQuery::cleanup() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - const QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" ) || QTest::currentTestFunction() == QLatin1String( "transactions" ) @@ -138,7 +138,7 @@ void tst_QSqlQuery::generic_data(const QString& engine) void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QStringList tablenames; // drop all the table in case a testcase failed tablenames << qtest @@ -199,7 +199,7 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db ) { const QString qtestNull = qTableName("qtest_null", __FILE__, db); QSqlQuery q( db ); - QSqlDriver::DBMSType dbType = tst_Databases::getDatabaseType(db); + QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); if (dbType == QSqlDriver::MySqlServer) // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri index 05ecaf1444..e162d5f105 100644 --- a/tests/manual/diaglib/diaglib.pri +++ b/tests/manual/diaglib/diaglib.pri @@ -19,7 +19,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { QT += gui-private core-private contains(QT, widgets) { HEADERS += \ - $$PWD/$$PWD/qwidgetdump.h + $$PWD/qwidgetdump.h SOURCES += \ $$PWD/qwidgetdump.cpp |