diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 19 | ||||
-rw-r--r-- | tests/auto/qchar/qchar.pro | 6 | ||||
-rw-r--r-- | tests/auto/qchar/tst_qchar.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 86 | ||||
-rw-r--r-- | tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 8 |
11 files changed, 134 insertions, 15 deletions
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 4433c7a..91d1a44 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <stddef.h> +#include <exception> QT_USE_NAMESPACE @@ -285,8 +286,26 @@ void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char * allocFailer.reactivateAt(currentIndex); } +typedef void (*PVF)(); +PVF defaultTerminate; +void debugTerminate() +{ + // you can detect uncaught exceptions with a breakpoint in here + (*defaultTerminate)(); +} + +PVF defaultUnexpected; +void debugUnexpected() +{ + // you can detect unexpected exceptions with a breakpoint in here + (*defaultUnexpected)(); +} + void tst_ExceptionSafetyObjects::initTestCase() { + // set handlers for bad exception cases, you might want to step in and breakpoint the default handlers too + defaultTerminate = std::set_terminate(&debugTerminate); + defaultUnexpected = std::set_unexpected(&debugUnexpected); testMessageHandler = qInstallMsgHandler(safeMessageHandler); QVERIFY(AllocFailer::initialize()); diff --git a/tests/auto/qchar/qchar.pro b/tests/auto/qchar/qchar.pro index 0a3fcc3..a534d14 100644 --- a/tests/auto/qchar/qchar.pro +++ b/tests/auto/qchar/qchar.pro @@ -8,4 +8,8 @@ deploy.sources += NormalizationTest.txt DEPLOYMENT = deploy } -DEFINES += SRCDIR=\\\"$$PWD/\\\" +symbian*: { + DEFINES += SRCDIR="" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp index 6227c2e..5ca2255 100644 --- a/tests/auto/qchar/tst_qchar.cpp +++ b/tests/auto/qchar/tst_qchar.cpp @@ -513,10 +513,7 @@ void tst_QChar::normalization() } QFile f(SRCDIR "NormalizationTest.txt"); - if (!f.exists()) { - QFAIL("Couldn't find NormalizationTest.txt"); - return; - } + QVERIFY(f.exists()); f.open(QIODevice::ReadOnly); diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 8722a86..ee799f3 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -482,7 +482,7 @@ void tst_QFile::open_data() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly) << (bool)TRUE << QFile::NoError; - QTest::newRow("uncFile") << "//" + QtNetworkSettings::winServerName() + "/testsharewritable/test.pri" << int(QIODevice::ReadOnly) + QTest::newRow("uncFile") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" << int(QIODevice::ReadOnly) << true << QFile::NoError; #endif } @@ -554,7 +554,7 @@ void tst_QFile::size_data() QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ - QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << (qint64)34; + QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34; #endif } @@ -2475,7 +2475,7 @@ void tst_QFile::miscWithUncPathAsCurrentDir() { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString current = QDir::currentPath(); - QVERIFY(QDir::setCurrent("//" + QtNetworkSettings::winServerName() + "/testsharewritable")); + QVERIFY(QDir::setCurrent("//" + QtNetworkSettings::winServerName() + "/testshare")); QFile file("test.pri"); QVERIFY(file.exists()); QCOMPARE(int(file.size()), 34); diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3313240..5a1d20b 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -168,6 +168,7 @@ private slots: void autoFillBackground(); void initialShow(); void initialShow2(); + void itemChangeEvents(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2944,6 +2945,91 @@ void tst_QGraphicsWidget::initialShow2() QTRY_COMPARE(widget->repaints, expectedRepaintCount); } +void tst_QGraphicsWidget::itemChangeEvents() +{ + class TestGraphicsWidget : public QGraphicsWidget + { public: + TestGraphicsWidget() : QGraphicsWidget() {} + QHash<QEvent::Type, QVariant> valueDuringEvents; + bool event(QEvent *event) { + Q_UNUSED(event); + switch (event->type()) { + case QEvent::EnabledChange: { + valueDuringEvents.insert(QEvent::EnabledChange, isEnabled()); + break; + } + case QEvent::ParentAboutToChange: { + valueDuringEvents.insert(QEvent::ParentAboutToChange, qVariantFromValue(parentItem())); + break; + } + case QEvent::ParentChange: { + valueDuringEvents.insert(QEvent::ParentChange, qVariantFromValue(parentItem())); + break; + } + case QEvent::CursorChange: { + valueDuringEvents.insert(QEvent::CursorChange, int(cursor().shape())); + break; + } + case QEvent::ToolTipChange: { + valueDuringEvents.insert(QEvent::ToolTipChange, toolTip()); + break; + } + default: { + break; + } + } + return true; + } + void showEvent(QShowEvent *event) { + Q_UNUSED(event); + valueDuringEvents.insert(QEvent::Show, isVisible()); + } + void hideEvent(QHideEvent *event) { + Q_UNUSED(event); + valueDuringEvents.insert(QEvent::Hide, isVisible()); + } + }; + + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *parent = new QGraphicsWidget; + scene.addItem(parent); + view.show(); + QTest::qWaitForWindowShown(&view); + + TestGraphicsWidget *item = new TestGraphicsWidget; + item->setParentItem(parent); + // ParentAboutToChange should be triggered before the parent has changed + QTRY_COMPARE(qVariantValue<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentAboutToChange)), + static_cast<QGraphicsItem *>(0)); + // ParentChange should be triggered after the parent has changed + QTRY_COMPARE(qVariantValue<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentChange)), + static_cast<QGraphicsItem *>(parent)); + + // ShowEvent should be triggered before the item is shown + QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::Show).toBool()); + + // HideEvent should be triggered after the item is hidden + QVERIFY(item->isVisible()); + item->setVisible(false); + QVERIFY(!item->isVisible()); + QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::Hide).toBool()); + + // CursorChange should be triggered after the cursor has changed + item->setCursor(Qt::PointingHandCursor); + QTRY_COMPARE(item->valueDuringEvents.value(QEvent::CursorChange).toInt(), int(item->cursor().shape())); + + // ToolTipChange should be triggered after the tooltip has changed + item->setToolTip("tooltipText"); + QTRY_COMPARE(item->valueDuringEvents.value(QEvent::ToolTipChange).toString(), item->toolTip()); + + // EnabledChange should be triggered after the enabled state has changed + QVERIFY(item->isEnabled()); + item->setEnabled(false); + QVERIFY(!item->isEnabled()); + QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::EnabledChange).toBool()); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index ca12f2a..3a3ea79 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -506,7 +506,8 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() // Connect socket.connectToHost(QtNetworkSettings::serverName(), 143); - QCOMPARE(socket.state(), QTcpSocket::HostLookupState); + QVERIFY(socket.state() == QTcpSocket::HostLookupState || + socket.state() == QTcpSocket::ConnectingState); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) { diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index c238f59..dd497b0 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3363,7 +3363,7 @@ void tst_QNetworkReply::lastModifiedHeaderForFile() void tst_QNetworkReply::lastModifiedHeaderForHttp() { // Tue, 22 May 2007 12:04:57 GMT according to webserver - QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif"; + QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif"; QNetworkRequest request(url); QNetworkReplyPtr reply = manager.head(request); diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index 0240a0e..a679765 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -647,7 +647,8 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() // Connect socket.connectToHost(QtNetworkSettings::serverName(), 143); - QCOMPARE(socket.state(), QTcpSocket::HostLookupState); + QVERIFY(socket.state() == QTcpSocket::HostLookupState || + socket.state() == QTcpSocket::ConnectingState); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) { diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index 8a084bb..38e5387 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -181,7 +181,11 @@ void tst_QSqlTableModel::createTestTables() QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); + if(!tst_Databases::isSqlServer(db)) + QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); + else + QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50) NULL, column3 varchar(50))")); + QVERIFY_SQL( q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int)")); diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 2bfce74..0cf638b 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -1286,7 +1286,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() connect(socket, SIGNAL(readyRead()), &setReadBufferSize_task_250027_handler, SLOT(readyReadSlot())); // provoke a response by sending a request - socket->write("GET /gif/fluke.gif HTTP/1.0\n"); // this file is 27 KB + socket->write("GET /qtest/fluke.gif HTTP/1.0\n"); // this file is 27 KB socket->write("Host: "); socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); socket->write("\n"); @@ -1535,7 +1535,6 @@ void tst_QSslSocket::verifyMode() loop.exec(); QVERIFY(clientSocket.isEncrypted()); - qDebug() << server.socket->sslErrors(); QVERIFY(server.socket->sslErrors().isEmpty()); } @@ -1751,7 +1750,7 @@ void tst_QSslSocket::readFromClosedSocket() socket->waitForConnected(); socket->waitForEncrypted(); // provoke a response by sending a request - socket->write("GET /gif/fluke.gif HTTP/1.1\n"); + socket->write("GET /qtest/fluke.gif HTTP/1.1\n"); socket->write("Host: "); socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); socket->write("\n"); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 54e32218..2062e8e 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3035,6 +3035,14 @@ void tst_QTableView::spans_data() << QPoint(0, 0) << 1 << 1; + + QTest::newRow("QTBUG-9631: remove one span") + << 10 << 10 + << (SpanList() << QRect(1, 1, 2, 1) << QRect(2, 2, 2, 2) << QRect(1, 1, 1, 1)) + << false + << QPoint(1, 1) + << 1 + << 1; } void tst_QTableView::spans() |