diff options
Diffstat (limited to 'tests')
49 files changed, 1309 insertions, 115 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 7d08866..7493d86 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -203,6 +203,7 @@ SUBDIRS += \ qmainwindow \ qmake \ qmap \ + qmath \ qmatrixnxn \ qmdiarea \ qmdisubwindow \ diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 4e60101..d58402b 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -54,10 +54,13 @@ class tst_NetworkSelfTest: public QObject { Q_OBJECT + QHostAddress cachedIpAddress; public: tst_NetworkSelfTest(); virtual ~tst_NetworkSelfTest(); + QHostAddress serverIpAddress(); + private slots: void hostTest(); void dnsResolution_data(); @@ -325,6 +328,16 @@ tst_NetworkSelfTest::~tst_NetworkSelfTest() { } +QHostAddress tst_NetworkSelfTest::serverIpAddress() +{ + if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { + // need resolving + QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName()); + cachedIpAddress = resolved.addresses().first(); + } + return cachedIpAddress; +} + void tst_NetworkSelfTest::hostTest() { // this is a localhost self-test @@ -353,14 +366,22 @@ void tst_NetworkSelfTest::dnsResolution() QHostInfo resolved = QHostInfo::fromName(hostName); QVERIFY2(resolved.error() == QHostInfo::NoError, QString("Failed to resolve hostname %1: %2").arg(hostName, resolved.errorString()).toLocal8Bit()); + QVERIFY2(resolved.addresses().size() > 0, "Got 0 addresses for server IP"); + + cachedIpAddress = resolved.addresses().first(); } void tst_NetworkSelfTest::serverReachability() { - // check that we get a proper error connecting to port 1 + // check that we get a proper error connecting to port 12346 QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), 1); + socket.connectToHost(QtNetworkSettings::serverName(), 12346); + + QTime timer; + timer.start(); socket.waitForConnected(10000); + QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); + QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); @@ -516,7 +537,18 @@ void tst_NetworkSelfTest::httpsServer() void tst_NetworkSelfTest::httpProxy() { netChat(3128, QList<Chat>() - // proxy GET + // proxy GET by IP + << Chat::send("GET http://" + serverIpAddress().toString().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Proxy-connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::DiscardUntilDisconnect + + // proxy GET by hostname + << Chat::Reconnect << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" @@ -526,7 +558,17 @@ void tst_NetworkSelfTest::httpProxy() << Chat::expect("200 ") << Chat::DiscardUntilDisconnect - // proxy CONNECT + // proxy CONNECT by IP + << Chat::Reconnect + << Chat::send("CONNECT " + serverIpAddress().toString().toLatin1() + ":21 HTTP/1.0\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::discardUntil("\r\n\r\n") + << ftpChat() + + // proxy CONNECT by hostname << Chat::Reconnect << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n" "\r\n") @@ -534,7 +576,8 @@ void tst_NetworkSelfTest::httpProxy() << Chat::discardUntil(" ") << Chat::expect("200 ") << Chat::discardUntil("\r\n\r\n") - << ftpChat()); + << ftpChat() + ); } void tst_NetworkSelfTest::httpProxyBasicAuth() @@ -591,11 +634,22 @@ static const char handshakeAuthPassword[] = "\5\1\2\1\12qsockstest\10password"; static const char handshakeOkPasswdAuth[] = "\5\2\1\0"; static const char handshakeAuthNotOk[] = "\5\377"; static const char connect1[] = "\5\1\0\1\177\0\0\1\0\25"; // Connect IPv4 127.0.0.1 port 21 +static const char connect1a[] = "\5\1\0\1"; // just "Connect to IPv4" +static const char connect1b[] = "\0\25"; // just "port 21" static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname localhost 21 +static const char connect2a[] = "\5\1\0\3"; // just "Connect to hostname" static const char connected[] = "\5\0\0"; +#define QBA(x) (QByteArray::fromRawData(x, -1 + sizeof(x))) + void tst_NetworkSelfTest::socks5Proxy() { + union { + char buf[4]; + quint32 data; + } ip4Address; + ip4Address.data = qToBigEndian(serverIpAddress().toIPv4Address()); + netChat(1080, QList<Chat>() // IP address connection << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) @@ -606,7 +660,17 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::skipBytes(6) // the server's local address and port << ftpChat() - // hostname connection + // connect by IP + << Chat::Reconnect + << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) + << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(QBA(connect1a) + QByteArray::fromRawData(ip4Address.buf, 4) + QBA(connect1b)) + << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect("\1") // IPv4 address following + << Chat::skipBytes(6) // the server's local address and port + << ftpChat() + + // connect to "localhost" by hostname << Chat::Reconnect << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) @@ -615,6 +679,16 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() + + // connect to server by its official name + << Chat::Reconnect + << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) + << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(QBA(connect2a) + char(QtNetworkSettings::serverName().size()) + QtNetworkSettings::serverName().toLatin1() + QBA(connect1b)) + << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect("\1") // IPv4 address following + << Chat::skipBytes(6) // the server's local address and port + << ftpChat() ); } diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index be2d882..4e385d5 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -184,6 +184,10 @@ public: virtual ~tst_QAbstractItemView(); void basic_tests(TestView *view); +public slots: + void initTestCase(); + void cleanupTestCase(); + private slots: void getSetCheck(); void emptyModels_data(); @@ -320,6 +324,17 @@ tst_QAbstractItemView::~tst_QAbstractItemView() { } +void tst_QAbstractItemView::initTestCase() +{ +#ifdef Q_OS_WINCE_WM + qApp->setAutoMaximizeThreshold(-1); +#endif +} + +void tst_QAbstractItemView::cleanupTestCase() +{ +} + void tst_QAbstractItemView::emptyModels_data() { QTest::addColumn<QString>("viewType"); @@ -1198,13 +1213,10 @@ void tst_QAbstractItemView::task250754_fontChange() QFont font = tree.font(); font.setPointSize(5); tree.setFont(font); - QTest::qWait(30); - QTRY_VERIFY(!tree.verticalScrollBar()->isVisible()); font.setPointSize(45); tree.setFont(font); - QTest::qWait(30); //now with the huge items, the scrollbar must be visible QTRY_VERIFY(tree.verticalScrollBar()->isVisible()); diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 69c4c92..9f2e4e7 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -2846,11 +2846,11 @@ void tst_QAccessibility::mdiSubWindowTest() { QMdiArea mdiArea; mdiArea.show(); + qApp->setActiveWindow(&mdiArea); #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(&mdiArea); - QTest::qWait(100); + QTest::qWait(150); #endif - qApp->setActiveWindow(&mdiArea); bool isSubWindowsPlacedNextToEachOther = false; const int subWindowCount = 5; diff --git a/tests/auto/qcssparser/qcssparser.pro b/tests/auto/qcssparser/qcssparser.pro index ce1281f..674064f 100644 --- a/tests/auto/qcssparser/qcssparser.pro +++ b/tests/auto/qcssparser/qcssparser.pro @@ -3,7 +3,6 @@ SOURCES += tst_qcssparser.cpp QT += xml requires(contains(QT_CONFIG,private_tests)) - !symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } @@ -11,5 +10,8 @@ requires(contains(QT_CONFIG,private_tests)) wince*|symbian: { addFiles.sources = testdata addFiles.path = . - DEPLOYMENT += addFiles + timesFont.sources = C:/Windows/Fonts/times.ttf + timesFont.path = . + DEPLOYMENT += addFiles timesFont } + diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp index c7f50d4..150f131 100644 --- a/tests/auto/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/qcssparser/tst_qcssparser.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include <QtTest/QtTest> #include <QtXml/QtXml> +#if defined(Q_OS_WINCE) +#include <QtGui/QFontDatabase> +#endif //TESTED_CLASS=QCss //TESTED_FILES=gui/text/qcssparser.cpp gui/text/qcssparser_p.h @@ -49,6 +52,11 @@ class tst_QCssParser : public QObject { Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + private slots: void scanner_data(); void scanner(); @@ -91,8 +99,33 @@ private slots: void extractBorder(); void noTextDecoration(); void quotedAndUnquotedIdentifiers(); + +private: +#if defined(Q_OS_WINCE) + int m_timesFontId; +#endif }; +void tst_QCssParser::initTestCase() +{ +#if defined(Q_OS_WINCE) + QFontDatabase fontDB; + m_timesFontId = -1; + if (!fontDB.families().contains("Times New Roman")) { + m_timesFontId = QFontDatabase::addApplicationFont("times.ttf"); + QVERIFY(m_timesFontId != -1); + } +#endif +} + +void tst_QCssParser::cleanupTestCase() +{ +#if defined(Q_OS_WINCE) + if (m_timesFontId != -1) + QFontDatabase::removeApplicationFont(m_timesFontId); +#endif +} + void tst_QCssParser::scanner_data() { QTest::addColumn<QString>("input"); diff --git a/tests/auto/qdialog/tst_qdialog.cpp b/tests/auto/qdialog/tst_qdialog.cpp index dc6878d..e95bc53 100644 --- a/tests/auto/qdialog/tst_qdialog.cpp +++ b/tests/auto/qdialog/tst_qdialog.cpp @@ -50,6 +50,8 @@ #include <QVBoxLayout> #include <QSizeGrip> +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QSize) @@ -160,8 +162,8 @@ void tst_QDialog::initTestCase() void tst_QDialog::cleanupTestCase() { if (testWidget) { - delete testWidget; - testWidget = 0; + delete testWidget; + testWidget = 0; } } @@ -585,35 +587,27 @@ void tst_QDialog::reject() TestRejectDialog dialog; dialog.show(); QTest::qWaitForWindowShown(&dialog); - QTest::qWait(100); - QVERIFY(dialog.isVisible()); + QTRY_VERIFY(dialog.isVisible()); dialog.reject(); - QTest::qWait(100); - QVERIFY(!dialog.isVisible()); + QTRY_VERIFY(!dialog.isVisible()); QCOMPARE(dialog.called, 1); dialog.show(); QTest::qWaitForWindowShown(&dialog); - QTest::qWait(100); - - QVERIFY(dialog.isVisible()); + QTRY_VERIFY(dialog.isVisible()); QVERIFY(dialog.close()); - QTest::qWait(100); - QVERIFY(!dialog.isVisible()); + QTRY_VERIFY(!dialog.isVisible()); QCOMPARE(dialog.called, 2); dialog.cancelReject = true; dialog.show(); QTest::qWaitForWindowShown(&dialog); - QTest::qWait(100); - QVERIFY(dialog.isVisible()); + QTRY_VERIFY(dialog.isVisible()); dialog.reject(); - QTest::qWait(100); - QVERIFY(dialog.isVisible()); + QTRY_VERIFY(dialog.isVisible()); QCOMPARE(dialog.called, 3); QVERIFY(!dialog.close()); - QTest::qWait(100); - QVERIFY(dialog.isVisible()); + QTRY_VERIFY(dialog.isVisible()); QCOMPARE(dialog.called, 4); } diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 2cc2558..29e4fe6 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -795,6 +795,8 @@ void tst_QFileSystemModel::sort() model->sort(0, Qt::DescendingOrder); QVERIFY(idx.column() != 0); + model->setRootPath(QDir::homePath()); + QFETCH(bool, fileDialogMode); MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel(); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index f15b249..e036e4b 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1754,6 +1754,29 @@ void tst_QGL::destroyFBOAfterContext() delete fbo; } +#ifdef QT_BUILD_INTERNAL + +class tst_QGLResource : public QObject +{ + Q_OBJECT +public: + tst_QGLResource(QObject *parent = 0) : QObject(parent) {} + ~tst_QGLResource() { ++deletions; } + + static int deletions; +}; + +int tst_QGLResource::deletions = 0; + +static void qt_shared_test_free(void *data) +{ + delete reinterpret_cast<tst_QGLResource *>(data); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_test, (qt_shared_test_free)) + +#endif + void tst_QGL::shareRegister() { #ifdef QT_BUILD_INTERNAL @@ -1775,6 +1798,12 @@ void tst_QGL::shareRegister() guard.setId(3); QVERIFY(guard.id() == 3); + // Add a resource to the first context. + tst_QGLResource *res1 = new tst_QGLResource(); + QVERIFY(!qt_shared_test()->value(glw1->context())); + qt_shared_test()->insert(glw1->context(), res1); + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + // Create another context that shares with the first. QGLWidget *glw2 = new QGLWidget(0, glw1); if (!glw2->isSharing()) { @@ -1784,6 +1813,10 @@ void tst_QGL::shareRegister() } QVERIFY(glw1->context() != glw2->context()); + // Check that the first context's resource is also on the second. + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + // Guard should still be the same. QVERIFY(guard.context() == glw1->context()); QVERIFY(guard.id() == 3); @@ -1814,6 +1847,14 @@ void tst_QGL::shareRegister() QGLSharedResourceGuard guard3(glw3->context()); guard3.setId(5); + // Add a resource to the third context. + tst_QGLResource *res3 = new tst_QGLResource(); + QVERIFY(!qt_shared_test()->value(glw3->context())); + qt_shared_test()->insert(glw3->context(), res3); + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + // First two should still be sharing, but third is in its own list. list = shareReg->shares(glw1->context()); QCOMPARE(list.size(), 2); @@ -1849,6 +1890,11 @@ void tst_QGL::shareRegister() // Delete the first context. delete glw1; + // The first context's resource should transfer to the second context. + QCOMPARE(tst_QGLResource::deletions, 0); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + // Shared guard should now be the second context, with the id the same. QVERIFY(guard.context() == glw2->context()); QVERIFY(guard.id() == 3); @@ -1859,9 +1905,11 @@ void tst_QGL::shareRegister() list = shareReg->shares(glw2->context()); QCOMPARE(list.size(), 0); - // Clean up. + // Clean up and check that the resources are properly deleted. delete glw2; + QCOMPARE(tst_QGLResource::deletions, 1); delete glw3; + QCOMPARE(tst_QGLResource::deletions, 2); // Guards should now be null and the id zero. QVERIFY(guard.context() == 0); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 9545198..e4eaf4e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6444,14 +6444,12 @@ void tst_QGraphicsItem::nestedClipping() QGraphicsView view(&scene); view.setOptimizationFlag(QGraphicsView::IndirectPainting); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QList<QGraphicsItem *> expected; expected << root << l1 << l2 << l3; - QCOMPARE(scene.drawnItems, expected); + QTRY_COMPARE(scene.drawnItems, expected); QImage image(200, 200, QImage::Format_ARGB32_Premultiplied); image.fill(0); @@ -7303,16 +7301,17 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() rect->startTrack = false; view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(12); + QTest::qWait(60); rect->startTrack = false; rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); - QTest::qWait(12); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(12); + QTest::qWait(60); } void tst_QGraphicsItem::itemSendsGeometryChanges() @@ -7631,7 +7630,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); item1->repaints = 0; item2->repaints = 0; @@ -7654,7 +7653,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); } void tst_QGraphicsItem::focusProxy() @@ -8384,7 +8383,7 @@ void tst_QGraphicsItem::ensureDirtySceneTransform() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), &view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); //We move the parent parent->move(); diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 4e46819..4f28df4 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -1370,6 +1370,8 @@ void tst_QGraphicsLinearLayout::layoutDirection() QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout; layout->setContentsMargins(1, 2, 3, 4); + layout->setSpacing(6); + RectWidget *w1 = new RectWidget; w1->setPreferredSize(20, 20); w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index e55dc9aa..8459331 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1705,7 +1705,7 @@ void tst_QGraphicsScene::hoverEvents_parentChild() view.scale(1.7, 1.7); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(50); + QTest::qWait(70); QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); mouseEvent.setScenePos(QPointF(-1000, -1000)); @@ -1726,7 +1726,7 @@ void tst_QGraphicsScene::hoverEvents_parentChild() qApp->processEvents(); // this posts updates from the scene to the view qApp->processEvents(); // which trigger a repaint here - QVERIFY(items.at(i)->isHovered); + QTRY_VERIFY(items.at(i)->isHovered); if (i < 14) QVERIFY(!items.at(i + 1)->isHovered); i += j ? 1 : -1; diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 78fb4f3..df3ebef 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -2932,18 +2932,16 @@ void tst_QGraphicsView::task239729_noViewUpdate() view = new QGraphicsView(&scene); } - view->show(); - QTest::qWaitForWindowShown(view); - QTest::qWait(150); - EventSpy spy(view->viewport(), QEvent::Paint); QCOMPARE(spy.count(), 0); - QTest::qWait(100); - QCOMPARE(spy.count(), 0); + view->show(); + QTest::qWaitForWindowShown(view); + + QTRY_COMPARE(spy.count(), 1); scene.update(); QApplication::processEvents(); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 2); delete view; } @@ -2979,6 +2977,7 @@ void tst_QGraphicsView::task245469_itemsAtPointWithClip() parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); QGraphicsView view(&scene); + view.resize(150,150); view.rotate(90); view.show(); QTest::qWaitForWindowShown(&view); diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 0b73733..26021e0 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -157,6 +157,7 @@ private slots: void shortcutsDeletion(); void painterStateProtectionOnWindowFrame(); void ensureClipping(); + void widgetSendsGeometryChanges(); void respectHFW(); // Task fixes @@ -2562,6 +2563,76 @@ void tst_QGraphicsWidget::ensureClipping() QVERIFY(scene.drawnItems.contains(childitem)); } +class ItemChangeTester : public QGraphicsWidget +{ +public: + ItemChangeTester() + { setFlag(ItemSendsGeometryChanges); clear(); } + ItemChangeTester(QGraphicsItem *parent) : QGraphicsWidget(parent) + { setFlag(ItemSendsGeometryChanges); clear(); } + + void clear() + { + changes.clear(); + values.clear(); + oldValues.clear(); + } + QList<GraphicsItemChange> changes; + QList<QVariant> values; + QList<QVariant> oldValues; +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value) + { + changes << change; + values << value; + switch (change) { + case QGraphicsItem::ItemPositionChange: + oldValues << pos(); + break; + case QGraphicsItem::ItemPositionHasChanged: + break; + default: + break; + } + return value; + } +}; + +void tst_QGraphicsWidget::widgetSendsGeometryChanges() +{ + ItemChangeTester widget; + widget.setFlags(0); + widget.clear(); + + QPointF pos(10, 10); + widget.setPos(pos); + + QCOMPARE(widget.pos(), pos); + QCOMPARE(widget.changes.size(), 0); + + widget.setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + QCOMPARE(widget.changes.size(), 2); + + widget.setPos(QPointF()); + QCOMPARE(widget.changes.size(), 4); + + QCOMPARE(widget.pos(), QPointF()); + + QRectF geometry(20, 20, 50, 50); + widget.setGeometry(geometry); + QCOMPARE(widget.changes.size(), 6); + + QCOMPARE(widget.geometry(), geometry); + + QCOMPARE(widget.changes, QList<QGraphicsItem::GraphicsItemChange>() + << QGraphicsItem::ItemFlagsChange + << QGraphicsItem::ItemFlagsHaveChanged + << QGraphicsItem::ItemPositionChange + << QGraphicsItem::ItemPositionHasChanged + << QGraphicsItem::ItemPositionChange + << QGraphicsItem::ItemPositionHasChanged); +} + class HFWWidget : public QGraphicsWidget { public: diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 6036a14..7aab6de 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -899,9 +899,21 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( } while (finishedCount != replies.length()); - // redundant - for (int i = 0; i < replies.length(); i++) + int pipelinedCount = 0; + for (int i = 0; i < replies.length(); i++) { QVERIFY(replies.at(i)->isFinished()); + QVERIFY (!(replies.at(i)->request().isPipeliningAllowed() == false + && replies.at(i)->isPipeliningUsed())); + + if (replies.at(i)->isPipeliningUsed()) + pipelinedCount++; + } + + // We allow pipelining for every 2nd,3rd,4th,6th,8th,9th,10th etc request. + // Assume that half of the requests had been pipelined. + // (this is a very relaxed condition, when last measured 79 of 100 + // requests had been pipelined) + QVERIFY(pipelinedCount >= requestCount / 2); qDebug() << "===" << stopWatch.elapsed() << "msec ==="; diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 1417e69..8368114 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3493,6 +3493,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode() testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); testWidget->setFocus(); + QApplication::setActiveWindow(testWidget); QTRY_VERIFY(testWidget->hasFocus()); QTest::keyPress(testWidget, '0'); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index d9cab02..7599ce6a06 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1617,6 +1617,8 @@ void tst_QListView::task254449_draggingItemToNegativeCoordinates() list.setModel(&model); list.setViewMode(QListView::IconMode); list.show(); + QTest::qWaitForWindowShown(&list); + class MyItemDelegate : public QStyledItemDelegate { public: @@ -1630,11 +1632,10 @@ void tst_QListView::task254449_draggingItemToNegativeCoordinates() mutable int numPaints; } delegate; - list.setItemDelegate(&delegate); - delegate.numPaints = 0; - QTest::qWaitForWindowShown(&list); //makes sure the layout is done - QTRY_VERIFY(delegate.numPaints > 0); + list.setItemDelegate(&delegate); + QApplication::processEvents(); + QTRY_VERIFY(delegate.numPaints > 0); //makes sure the layout is done const QPoint topLeft(-6, 0); list.setPositionForIndex(topLeft, index); diff --git a/tests/auto/qmath/qmath.pro b/tests/auto/qmath/qmath.pro new file mode 100644 index 0000000..03134ee --- /dev/null +++ b/tests/auto/qmath/qmath.pro @@ -0,0 +1,6 @@ +load(qttest_p4) + +QT = core + +SOURCES += tst_qmath.cpp +QT = core diff --git a/tests/auto/qmath/tst_qmath.cpp b/tests/auto/qmath/tst_qmath.cpp new file mode 100644 index 0000000..efc7cfa --- /dev/null +++ b/tests/auto/qmath/tst_qmath.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <qmath.h> + +static const qreal PI = 3.14159265358979323846264338327950288; + +class tst_QMath : public QObject +{ + Q_OBJECT +private slots: + void fastSinCos(); +}; + +void tst_QMath::fastSinCos() +{ + // Test evenly spaced angles from 0 to 2pi radians. + const int LOOP_COUNT = 100000; + for (int i = 0; i < LOOP_COUNT; ++i) { + qreal angle = i * 2 * PI / (LOOP_COUNT - 1); + QVERIFY(qAbs(qSin(angle) - qFastSin(angle)) < 1e-5); + QVERIFY(qAbs(qCos(angle) - qFastCos(angle)) < 1e-5); + } +} + +QTEST_APPLESS_MAIN(tst_QMath) + +#include "tst_qmath.moc" diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index a5b3848..068d1fa 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -1759,7 +1759,7 @@ void tst_QMdiArea::tileSubWindows() // Horizontal scroll bar. QScrollBar *hBar = workspace.horizontalScrollBar(); QCOMPARE(workspace.horizontalScrollBarPolicy(), Qt::ScrollBarAsNeeded); - QVERIFY(hBar->isVisible()); + QTRY_VERIFY(hBar->isVisible()); QCOMPARE(hBar->value(), 0); QCOMPARE(hBar->minimum(), 0); diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp index 2d70bef..b556b87 100644 --- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp @@ -1003,9 +1003,9 @@ void tst_QMdiSubWindow::setSystemMenu() mainWindow.setCentralWidget(mdiArea); mainWindow.menuBar(); mainWindow.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&mainWindow); -#endif + QTest::qWaitForWindowShown(&mainWindow); + QTest::qWait(60); + QTRY_VERIFY(subWindow->isVisible()); QPoint globalPopupPos; @@ -1650,7 +1650,7 @@ void tst_QMdiSubWindow::resizeTimer() QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget); mdiArea.show(); QTest::qWaitForWindowShown(&mdiArea); - QTest::qWait(250); + QTest::qWait(300); EventSpy timerEventSpy(subWindow, QEvent::Timer); @@ -1663,7 +1663,7 @@ void tst_QMdiSubWindow::resizeTimer() QTest::qWait(500); // Wait for timer events to occur. - QVERIFY(timerEventSpy.count() > 0); + QTRY_VERIFY(timerEventSpy.count() > 0); } void tst_QMdiSubWindow::fixedMinMaxSize() diff --git a/tests/auto/qnetworkreply/certs/server.key b/tests/auto/qnetworkreply/certs/server.key new file mode 100644 index 0000000..9d1664d --- /dev/null +++ b/tests/auto/qnetworkreply/certs/server.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ +VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1 +CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB +AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz +/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri +KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s +1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4 +VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE +oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW +A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub +K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c +VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC +AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qnetworkreply/certs/server.pem b/tests/auto/qnetworkreply/certs/server.pem new file mode 100644 index 0000000..67eb495 --- /dev/null +++ b/tests/auto/qnetworkreply/certs/server.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x +DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs +dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50 +cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe +Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w +CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE +ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN +b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY +SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd +AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM +IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv +Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV +BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB +U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u +bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR +t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ +AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp +nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8 ++JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN +XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx +kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD +-----END CERTIFICATE----- diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 578ab29..7adb67f 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -258,6 +258,7 @@ private Q_SLOTS: void httpConnectionCount(); #ifndef QT_NO_OPENSSL + void ioPostToHttpsUploadProgress(); void ignoreSslErrorsList_data(); void ignoreSslErrorsList(); void ignoreSslErrorsListWithSlot_data(); @@ -3099,6 +3100,109 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() QCOMPARE(reply->error(), QNetworkReply::ContentReSendError); } +#ifndef QT_NO_OPENSSL +class SslServer : public QTcpServer { + Q_OBJECT +public: + SslServer() : socket(0) {}; + void incomingConnection(int socketDescriptor) { + QSslSocket *serverSocket = new QSslSocket; + serverSocket->setParent(this); + + if (serverSocket->setSocketDescriptor(socketDescriptor)) { + connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot())); + serverSocket->setProtocol(QSsl::AnyProtocol); + connect(serverSocket, SIGNAL(sslErrors(const QList<QSslError>&)), serverSocket, SLOT(ignoreSslErrors())); + serverSocket->setLocalCertificate (SRCDIR "/certs/server.pem"); + serverSocket->setPrivateKey (SRCDIR "/certs/server.key"); + serverSocket->startServerEncryption(); + } else { + delete serverSocket; + } + } +signals: + void newEncryptedConnection(); +public slots: + void encryptedSlot() { + socket = (QSslSocket*) sender(); + emit newEncryptedConnection(); + } +public: + QSslSocket *socket; +}; + +// very similar to ioPostToHttpUploadProgress but for SSL +void tst_QNetworkReply::ioPostToHttpsUploadProgress() +{ + QFile sourceFile(SRCDIR "/bigfile"); + QVERIFY(sourceFile.open(QIODevice::ReadOnly)); + + // emulate a minimal https server + SslServer server; + server.listen(QHostAddress(QHostAddress::LocalHost), 0); + + // create the request + QUrl url = QUrl(QString("https://127.0.0.1:%1/").arg(server.serverPort())); + QNetworkRequest request(url); + QNetworkReplyPtr reply = manager.post(request, &sourceFile); + QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64))); + connect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), reply, SLOT(ignoreSslErrors())); + + // get the request started and the incoming socket connected + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QTcpSocket *incomingSocket = server.socket; + QVERIFY(incomingSocket); + disconnect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + + incomingSocket->setReadBufferSize(1*1024); + QTestEventLoop::instance().enterLoop(2); + // some progress should have been made + QList<QVariant> args = spy.last(); + qDebug() << "tst_QNetworkReply::ioPostToHttpsUploadProgress" + << args.at(0).toLongLong() + << sourceFile.size() + << spy.size(); + QVERIFY(!args.isEmpty()); + QVERIFY(args.at(0).toLongLong() > 0); + // FIXME this is where it messes up + + QEXPECT_FAIL("", "Either the readBufferSize of QSslSocket is broken or we do upload too much. Hm.", Abort); + QVERIFY(args.at(0).toLongLong() != sourceFile.size()); + + incomingSocket->setReadBufferSize(32*1024); + incomingSocket->read(16*1024); + QTestEventLoop::instance().enterLoop(2); + // some more progress than before + QList<QVariant> args2 = spy.last(); + QVERIFY(!args2.isEmpty()); + QVERIFY(args2.at(0).toLongLong() > args.at(0).toLongLong()); + + // set the read buffer to unlimited + incomingSocket->setReadBufferSize(0); + QTestEventLoop::instance().enterLoop(10); + // progress should be finished + QList<QVariant> args3 = spy.last(); + QVERIFY(!args3.isEmpty()); + QVERIFY(args3.at(0).toLongLong() > args2.at(0).toLongLong()); + QCOMPARE(args3.at(0).toLongLong(), args3.at(1).toLongLong()); + QCOMPARE(args3.at(0).toLongLong(), sourceFile.size()); + + // after sending this, the QNAM should emit finished() + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + incomingSocket->write("HTTP/1.0 200 OK\r\n"); + incomingSocket->write("Content-Length: 0\r\n"); + incomingSocket->write("\r\n"); + QTestEventLoop::instance().enterLoop(10); + // not timeouted -> finished() was emitted + QVERIFY(!QTestEventLoop::instance().timeout()); + + incomingSocket->close(); + server.close(); +} +#endif void tst_QNetworkReply::ioPostToHttpUploadProgress() { @@ -3889,10 +3993,14 @@ void tst_QNetworkReply::httpConnectionCount() QTime time; time.start(); - while(pendingConnectionCount != 6) { - QCoreApplication::instance()->processEvents(); - while (server.nextPendingConnection()) + while(pendingConnectionCount <= 20) { + QTestEventLoop::instance().enterLoop(1); + QTcpSocket *socket = server.nextPendingConnection(); + while (socket != 0) { pendingConnectionCount++; + socket->setParent(&server); + socket = server.nextPendingConnection(); + } // at max. wait 10 sec if (time.elapsed() > 10000) diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index acd23b0..8578d36 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -62,6 +62,7 @@ public Q_SLOTS: private slots: void construction(); void setCurrentTime(); + void stateChanged(); void clearGroup(); void propagateGroupUpdateToChildren(); void updateChildrenWithRunningGroup(); @@ -252,6 +253,112 @@ void tst_QParallelAnimationGroup::setCurrentTime() QCOMPARE(loopsForever->currentTime(), 1); } +void tst_QParallelAnimationGroup::stateChanged() +{ + //this ensures that the correct animations are started when starting the group + TestAnimation *anim1 = new TestAnimation; + TestAnimation *anim2 = new TestAnimation; + TestAnimation *anim3 = new TestAnimation; + TestAnimation *anim4 = new TestAnimation; + anim1->setDuration(1000); + anim2->setDuration(2000); + anim3->setDuration(3000); + anim4->setDuration(3000); + QParallelAnimationGroup group; + group.addAnimation(anim1); + group.addAnimation(anim2); + group.addAnimation(anim3); + group.addAnimation(anim4); + + QSignalSpy spy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy spy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy spy3(anim3, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy spy4(anim4, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + + //first; let's start forward + group.start(); + //all the animations should be started + QCOMPARE(spy1.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running); + QCOMPARE(spy2.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running); + QCOMPARE(spy3.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running); + QCOMPARE(spy4.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running); + + group.setCurrentTime(1500); //anim1 should be finished + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(spy1.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy2.count(), 1); //no change + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(2500); //anim2 should be finished + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(spy1.count(), 2); //no change + QCOMPARE(spy2.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(3500); //everything should be finished + QCOMPARE(group.state(), QAnimationGroup::Stopped); + QCOMPARE(spy1.count(), 2); //no change + QCOMPARE(spy2.count(), 2); //no change + QCOMPARE(spy3.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy4.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped); + + //cleanup + spy1.clear(); + spy2.clear(); + spy3.clear(); + spy4.clear(); + + //now let's try to reverse that + group.setDirection(QAbstractAnimation::Backward); + group.start(); + + //only anim3 and anim4 should be started + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(spy1.count(), 0); + QCOMPARE(spy2.count(), 0); + QCOMPARE(spy3.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running); + QCOMPARE(spy4.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running); + + group.setCurrentTime(1500); //anim2 should be started + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(spy1.count(), 0); //no change + QCOMPARE(spy2.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running); + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(500); //anim1 is finally also started + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(spy1.count(), 1); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running); + QCOMPARE(spy2.count(), 1); //no change + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(0); //everything should be stopped + QCOMPARE(group.state(), QAnimationGroup::Stopped); + QCOMPARE(spy1.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy2.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy3.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped); + QCOMPARE(spy4.count(), 2); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped); +} + void tst_QParallelAnimationGroup::clearGroup() { QParallelAnimationGroup group; @@ -398,7 +505,7 @@ void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim1->state(), QAnimationGroup::Running); - QTest::qWait(50); + QTest::qWait(80); QVERIFY(group.currentTime() > 0); delete anim1; @@ -564,14 +671,23 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() anim2.setEndValue(100); anim2.setDuration(100); + TestAnimation anim3; + anim3.setStartValue(0); + anim3.setEndValue(100); + anim3.setDuration(10); + QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); QSignalSpy finishedSpy1(&anim1, SIGNAL(finished())); QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); QSignalSpy finishedSpy2(&anim2, SIGNAL(finished())); + QSignalSpy stateChangedSpy3(&anim3, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy finishedSpy3(&anim3, SIGNAL(finished())); + group.addAnimation(&anim1); group.addAnimation(&anim2); + group.addAnimation(&anim3); QCOMPARE(stateChangedSpy1.count(), 0); group.start(); QCOMPARE(stateChangedSpy1.count(), 2); @@ -586,9 +702,15 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)), QAnimationGroup::Running); + QCOMPARE(stateChangedSpy3.count(), 1); + QCOMPARE(finishedSpy3.count(), 0); + QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).at(1)), + QAnimationGroup::Running); + QCOMPARE(anim1.state(), QAnimationGroup::Stopped); QCOMPARE(anim2.state(), QAnimationGroup::Running); + QCOMPARE(anim3.state(), QAnimationGroup::Running); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -596,19 +718,24 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.setLoopCount(4); stateChangedSpy1.clear(); stateChangedSpy2.clear(); + stateChangedSpy3.clear(); group.start(); QCOMPARE(stateChangedSpy1.count(), 2); QCOMPARE(stateChangedSpy2.count(), 1); + QCOMPARE(stateChangedSpy3.count(), 1); group.setCurrentTime(50); QCOMPARE(stateChangedSpy1.count(), 2); QCOMPARE(stateChangedSpy2.count(), 1); + QCOMPARE(stateChangedSpy3.count(), 2); group.setCurrentTime(150); QCOMPARE(stateChangedSpy1.count(), 4); QCOMPARE(stateChangedSpy2.count(), 3); + QCOMPARE(stateChangedSpy3.count(), 4); group.setCurrentTime(50); QCOMPARE(stateChangedSpy1.count(), 6); QCOMPARE(stateChangedSpy2.count(), 5); + QCOMPARE(stateChangedSpy3.count(), 6); } @@ -863,6 +990,23 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentTime(), currentTime); QCOMPARE(spy.count(), 1); + + group.stop(); + spy.clear(); + new TestAnimation2(500, &group); + group.start(); + QCOMPARE(spy.count(), 1); //the animation should have been started + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Running); + group.setCurrentTime(250); //end of first animation + QCOMPARE(spy.count(), 2); //the animation should have been stopped + QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Stopped); + group.pause(); + QCOMPARE(spy.count(), 2); //this shouldn't have changed + group.resume(); + QCOMPARE(spy.count(), 2); //this shouldn't have changed + + + } diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 2568b94..36c1518 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -166,6 +166,8 @@ private slots: void fromImage_crash(); void fromData(); + + void preserveDepth(); }; static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) @@ -1448,6 +1450,23 @@ void tst_QPixmap::task_246446() QVERIFY(pm.mask().isNull()); } +void tst_QPixmap::preserveDepth() +{ + QPixmap target(64, 64); + target.fill(Qt::transparent); + + QPixmap source(64, 64); + source.fill(Qt::white); + + int depth = source.depth(); + + QPainter painter(&target); + painter.setBrush(source); + painter.drawRect(target.rect()); + painter.end(); + + QCOMPARE(depth, source.depth()); +} QTEST_MAIN(tst_QPixmap) #include "tst_qpixmap.moc" diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index b487d74..9775d36 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -244,16 +244,23 @@ void tst_QPixmapCache::insert() QPixmap p2(10, 10); p2.fill(Qt::yellow); + // Calcuate estimated num of items what fits to cache + int estimatedNum = (1024 * QPixmapCache::cacheLimit()) + / ((p1.width() * p1.height() * p1.depth()) / 8); + + // Mare sure we will put enough items to reach the cache limit + const int numberOfKeys = estimatedNum + 1000; + // make sure it doesn't explode - for (int i = 0; i < 20000; ++i) + for (int i = 0; i < numberOfKeys; ++i) QPixmapCache::insert("0", p1); // ditto - for (int j = 0; j < 40000; ++j) + for (int j = 0; j < numberOfKeys; ++j) QPixmapCache::insert(QString::number(j), p1); int num = 0; - for (int k = 0; k < 40000; ++k) { + for (int k = 0; k < numberOfKeys; ++k) { if (QPixmapCache::find(QString::number(k))) ++num; } @@ -261,9 +268,6 @@ void tst_QPixmapCache::insert() if (QPixmapCache::find("0")) ++num; - int estimatedNum = (1024 * QPixmapCache::cacheLimit()) - / ((p1.width() * p1.height() * p1.depth()) / 8); - QVERIFY(num <= estimatedNum); QPixmap p3; QPixmapCache::insert("null", p3); @@ -281,11 +285,11 @@ void tst_QPixmapCache::insert() //The int part of the API // make sure it doesn't explode QList<QPixmapCache::Key> keys; - for (int i = 0; i < 40000; ++i) + for (int i = 0; i < numberOfKeys; ++i) keys.append(QPixmapCache::insert(p1)); num = 0; - for (int k = 0; k < 40000; ++k) { + for (int k = 0; k < numberOfKeys; ++k) { if (QPixmapCache::find(keys.at(k), &p2)) ++num; } @@ -393,7 +397,12 @@ void tst_QPixmapCache::clear() QPixmap p1(10, 10); p1.fill(Qt::red); - const int numberOfKeys = 40000; + // Calcuate estimated num of items what fits to cache + int estimatedNum = (1024 * QPixmapCache::cacheLimit()) + / ((p1.width() * p1.height() * p1.depth()) / 8); + + // Mare sure we will put enough items to reach the cache limit + const int numberOfKeys = estimatedNum + 1000; for (int i = 0; i < numberOfKeys; ++i) QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0); diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index d6df94b..3c05d90 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -108,6 +108,8 @@ private slots: void testActualNumCopies(); + void taskQTBUG4497_reusePrinterOnDifferentFiles(); + private: }; @@ -971,5 +973,37 @@ void tst_QPrinter::testActualNumCopies() QCOMPARE(p.actualNumCopies(), 15); } +static void printPage(QPainter *painter) +{ + painter->setPen(QPen(Qt::black, 4)); + painter->drawRect(50, 60, 70, 80); +} + +void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles() +{ + QPrinter printer; + { + + printer.setOutputFileName("out1.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + { + + printer.setOutputFileName("out2.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + QFile file1("out1.ps"); + QVERIFY(file1.open(QIODevice::ReadOnly)); + + QFile file2("out2.ps"); + QVERIFY(file2.open(QIODevice::ReadOnly)); + + QCOMPARE(file1.readAll(), file2.readAll()); +} + QTEST_MAIN(tst_QPrinter) #include "tst_qprinter.moc" diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index b193d67..a0af214 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -83,6 +83,7 @@ private slots: void argumentsObjectInNative(); void jsActivationObject(); void qobjectAsActivationObject(); + void parentContextCallee_QT2270(); }; tst_QScriptContext::tst_QScriptContext() @@ -1222,5 +1223,20 @@ void tst_QScriptContext::qobjectAsActivationObject() } } +static QScriptValue getParentContextCallee(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->parentContext()->callee(); +} + +void tst_QScriptContext::parentContextCallee_QT2270() +{ + QScriptEngine engine; + engine.globalObject().setProperty("getParentContextCallee", engine.newFunction(getParentContextCallee)); + QScriptValue fun = engine.evaluate("(function() { return getParentContextCallee(); })"); + QVERIFY(fun.isFunction()); + QScriptValue callee = fun.call(); + QVERIFY(callee.equals(fun)); +} + QTEST_MAIN(tst_QScriptContext) #include "tst_qscriptcontext.moc" diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 6b64e76..5636c54 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -87,6 +87,7 @@ private slots: void getSetPrototype(); void getSetScope(); void getSetProperty(); + void arrayElementGetterSetter(); void getSetData(); void getSetScriptClass(); void call(); @@ -2115,6 +2116,32 @@ void tst_QScriptValue::getSetProperty() QVERIFY(object.propertyFlags(foo) == 0); } +void tst_QScriptValue::arrayElementGetterSetter() +{ + QScriptEngine eng; + QScriptValue obj = eng.newObject(); + obj.setProperty(1, eng.newFunction(getterSetter), QScriptValue::PropertyGetter|QScriptValue::PropertySetter); + { + QScriptValue num(123); + obj.setProperty("x", num); + QScriptValue ret = obj.property(1); + QVERIFY(ret.isValid()); + QVERIFY(ret.equals(num)); + } + { + QScriptValue num(456); + obj.setProperty(1, num); + QScriptValue ret = obj.property(1); + QVERIFY(ret.isValid()); + QVERIFY(ret.equals(num)); + QVERIFY(ret.equals(obj.property("1"))); + } + QCOMPARE(obj.propertyFlags("1"), QScriptValue::PropertyGetter|QScriptValue::PropertySetter); + + obj.setProperty(1, QScriptValue(), QScriptValue::PropertyGetter|QScriptValue::PropertySetter); + QVERIFY(obj.propertyFlags("1") == 0); +} + void tst_QScriptValue::getSetPrototype() { QScriptEngine eng; diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp index c4ff76c..4ab3b0b 100644 --- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp @@ -764,7 +764,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() bool consumerFailed = false; while (!consumers.isEmpty()) { - consumers.first()->waitForFinished(1000); + consumers.first()->waitForFinished(2000); if (consumers.first()->state() == QProcess::Running || consumers.first()->exitStatus() != QProcess::NormalExit || consumers.first()->exitCode() != 0) { @@ -773,7 +773,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() delete consumers.takeFirst(); } QCOMPARE(consumerFailed, false); - QCOMPARE(failedProcesses, unsigned int (0)); + QCOMPARE(failedProcesses, (unsigned int)(0)); } QTEST_MAIN(tst_QSharedMemory) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index fa63c4b..58eaacb 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -308,7 +308,7 @@ extern int forwardDeclaredDestructorRunCount; void tst_QSharedPointer::forwardDeclaration1() { -#if defined(Q_CC_SUN) +#if defined(Q_CC_SUN) || defined(Q_CC_WINSCW) || defined(Q_CC_RVCT) QSKIP("This type of forward declaration is not valid with this compiler", SkipAll); #else externalForwardDeclaration(); @@ -1448,10 +1448,11 @@ void tst_QSharedPointer::threadStressTest_data() QTest::newRow("1+1") << 1 << 1; QTest::newRow("2+10") << 2 << 10; +#ifndef Q_OS_WINCE + // Windows CE cannot run this many threads QTest::newRow("5+10") << 5 << 10; QTest::newRow("5+30") << 5 << 30; -#ifndef Q_OS_WINCE QTest::newRow("100+100") << 100 << 100; #endif } diff --git a/tests/auto/qsound/qsound.pro b/tests/auto/qsound/qsound.pro index 75da2e6..c48d50d 100644 --- a/tests/auto/qsound/qsound.pro +++ b/tests/auto/qsound/qsound.pro @@ -4,4 +4,8 @@ SOURCES += tst_qsound.cpp wince*|symbian*: { deploy.sources += 4.wav DEPLOYMENT = deploy -}
\ No newline at end of file + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp index 76451e3..dd5f2ce 100644 --- a/tests/auto/qsound/tst_qsound.cpp +++ b/tests/auto/qsound/tst_qsound.cpp @@ -56,7 +56,7 @@ private slots: void tst_QSound::checkFinished() { - QSound sound("4.wav"); + QSound sound(SRCDIR"4.wav"); sound.setLoops(3); sound.play(); QTest::qWait(5000); diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 4175bef..c9c8f5e 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -157,6 +157,8 @@ private slots: void mysqlOdbc_unsignedIntegers(); void mysql_multiselect_data() { generic_data("QMYSQL"); } void mysql_multiselect(); // For task 144331 + void mysql_savepointtest_data() { generic_data("QMYSQL"); } + void mysql_savepointtest(); void accessOdbc_strings_data() { generic_data(); } void accessOdbc_strings(); @@ -2433,6 +2435,19 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() QCOMPARE(statment.count("IS NULL", Qt::CaseInsensitive), 2); } +void tst_QSqlDatabase::mysql_savepointtest() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) + QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("begin")); + QVERIFY_SQL(q, exec("insert into "+qTableName("qtest")+" VALUES (54, 'foo', 'foo', 54.54)")); + QVERIFY_SQL(q, exec("savepoint foo")); +} QTEST_MAIN(tst_QSqlDatabase) #include "tst_qsqldatabase.moc" diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index b808f7f..1516346 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -42,6 +42,9 @@ #include <QtTest/QtTest> #include <QtCore/QCoreApplication> #include <QtGui/QPushButton> +#include <QtGui/QGraphicsScene> +#include <QtGui/QGraphicsSceneEvent> +#include <QtGui/QGraphicsTextItem> #include "qstatemachine.h" #include "qstate.h" @@ -127,6 +130,7 @@ private slots: void allSourceToTargetConfigurations(); void signalTransitions(); void eventTransitions(); + void graphicsSceneEventTransitions(); void historyStates(); void startAndStop(); void targetStateWithNoParent(); @@ -2426,6 +2430,29 @@ void tst_QStateMachine::eventTransitions() } } +void tst_QStateMachine::graphicsSceneEventTransitions() +{ + QGraphicsScene scene; + QGraphicsTextItem *textItem = scene.addText("foo"); + + QStateMachine machine; + QState *s1 = new QState(&machine); + QFinalState *s2 = new QFinalState(&machine); + QEventTransition *t = new QEventTransition(textItem, QEvent::GraphicsSceneMouseMove); + t->setTargetState(s2); + s1->addTransition(t); + machine.setInitialState(s1); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QVERIFY(finishedSpy.count() == 0); + QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); + scene.sendEvent(textItem, &mouseEvent); + QTRY_COMPARE(finishedSpy.count(), 1); +} + void tst_QStateMachine::historyStates() { for (int x = 0; x < 2; ++x) { diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index e1b5a41..c95d86c 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -1294,10 +1294,17 @@ void tst_QSvgRenderer::testUseElement() p.begin(&images[i]); renderer.render(&p); p.end(); + if (i < 4 && i != 0) { QCOMPARE(images[0], images[i]); } else if (i > 4 && i < 7) { - QCOMPARE(images[4], images[i]); + if (sizeof(qreal) != sizeof(float)) + { + // These images use blending functions which due to numerical + // issues on Windows CE and likes differ in very few pixels. + // For this reason an exact comparison will fail. + QCOMPARE(images[4], images[i]); + } } else if (i > 7) { QCOMPARE(images[8], images[i]); } diff --git a/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp index 6bfab15..44986fa 100644 --- a/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp +++ b/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp @@ -42,13 +42,12 @@ #include <QtTest/QtTest> #include <qsystemsemaphore.h> - //TESTED_CLASS= //TESTED_FILES= #define EXISTING_SHARE "existing" - #define LACKYLOC "../qsharedmemory/lackey" +#define LACKYWAITTIME 10000 class tst_QSystemSemaphore : public QObject { @@ -199,12 +198,12 @@ void tst_QSystemSemaphore::basicProcesses() release.setProcessChannelMode(QProcess::ForwardedChannels); acquire.start(LACKYLOC "/lackey", acquireArguments); - acquire.waitForFinished(5000); + acquire.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state() == QProcess::Running); acquire.kill(); release.start(LACKYLOC "/lackey", releaseArguments); - acquire.waitForFinished(5000); - release.waitForFinished(5000); + acquire.waitForFinished(LACKYWAITTIME); + release.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state() == QProcess::NotRunning); } @@ -259,13 +258,13 @@ void tst_QSystemSemaphore::undo() QProcess acquire; acquire.setProcessChannelMode(QProcess::ForwardedChannels); acquire.start(LACKYLOC "/lackey", acquireArguments); - acquire.waitForFinished(1000); + acquire.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); // At process exit the kernel should auto undo acquire.start(LACKYLOC "/lackey", acquireArguments); - acquire.waitForFinished(1000); + acquire.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); } @@ -285,17 +284,17 @@ void tst_QSystemSemaphore::initialValue() release.setProcessChannelMode(QProcess::ForwardedChannels); acquire.start(LACKYLOC "/lackey", acquireArguments); - acquire.waitForFinished(10000); + acquire.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); acquire.start(LACKYLOC "/lackey", acquireArguments << "2"); - acquire.waitForFinished(1000); + acquire.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::Running); acquire.kill(); release.start(LACKYLOC "/lackey", releaseArguments); - acquire.waitForFinished(10000); - release.waitForFinished(10000); + acquire.waitForFinished(LACKYWAITTIME); + release.waitForFinished(LACKYWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); } QTEST_MAIN(tst_QSystemSemaphore) diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 09e1e87..4bf7c2e 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -164,6 +164,10 @@ private slots: void span(); void spans(); void spans_data(); + void spansAfterRowInsertion(); + void spansAfterColumnInsertion(); + void spansAfterRowRemoval(); + void spansAfterColumnRemoval(); void checkHeaderReset(); void checkHeaderMinSize(); @@ -268,6 +272,28 @@ public: return QVariant(); } + bool insertRows(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start > row_count) + return false; + + beginInsertRows(parent, start, start + count - 1); + row_count += count; + endInsertRows(); + return true; + } + + bool removeRows(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start >= row_count || row_count < count) + return false; + + beginRemoveRows(parent, start, start + count - 1); + row_count -= count; + endRemoveRows(); + return true; + } + void removeLastRow() { beginRemoveRows(QModelIndex(), row_count - 1, row_count - 1); @@ -282,6 +308,28 @@ public: endRemoveRows(); } + bool insertColumns(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start > column_count) + return false; + + beginInsertColumns(parent, start, start + count - 1); + column_count += count; + endInsertColumns(); + return true; + } + + bool removeColumns(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start >= column_count || column_count < count) + return false; + + beginRemoveColumns(parent, start, start + count - 1); + column_count -= count; + endRemoveColumns(); + return true; + } + void removeLastColumn() { beginRemoveColumns(QModelIndex(), column_count - 1, column_count - 1); @@ -2339,7 +2387,7 @@ void tst_QTableView::scrollTo() QSize forcedSize(columnWidth * 2, rowHeight * 2); view.resize(forcedSize); QTest::qWaitForWindowShown(&view); - QTest::qWait(0); + QTest::qWait(50); QTRY_COMPARE(view.size(), forcedSize); view.setModel(&model); @@ -2354,7 +2402,7 @@ void tst_QTableView::scrollTo() for (int c = 0; c < columnCount; ++c) view.setColumnWidth(c, columnWidth); - QTest::qWait(100); // ### needed to pass the test + QTest::qWait(150); // ### needed to pass the test view.horizontalScrollBar()->setValue(horizontalScroll); view.verticalScrollBar()->setValue(verticalScroll); @@ -2608,7 +2656,7 @@ void tst_QTableView::span_data() << -1 << -1 << 6 << 6 << 3 << 3 - << 3 << 3 + << 2 << 3 << true; } @@ -2797,6 +2845,149 @@ void tst_QTableView::spans() QCOMPARE(view.rowSpan(pos.x(), pos.y()), expectedRowSpan); } +void tst_QTableView::spansAfterRowInsertion() +{ + QtTestTableModel model(10, 10); + QtTestTableView view; + view.setModel(&model); + view.setSpan(3, 3, 3, 3); + view.show(); + QTest::qWait(50); + + // Insertion before the span only shifts the span. + view.model()->insertRows(0, 2); + QCOMPARE(view.rowSpan(3, 3), 1); + QCOMPARE(view.columnSpan(3, 3), 1); + QCOMPARE(view.rowSpan(5, 3), 3); + QCOMPARE(view.columnSpan(5, 3), 3); + + // Insertion happens before the given row, so it only shifts the span also. + view.model()->insertRows(5, 2); + QCOMPARE(view.rowSpan(5, 3), 1); + QCOMPARE(view.columnSpan(5, 3), 1); + QCOMPARE(view.rowSpan(7, 3), 3); + QCOMPARE(view.columnSpan(7, 3), 3); + + // Insertion inside the span expands it. + view.model()->insertRows(8, 2); + QCOMPARE(view.rowSpan(7, 3), 5); + QCOMPARE(view.columnSpan(7, 3), 3); + + // Insertion after the span does nothing to it. + view.model()->insertRows(12, 2); + QCOMPARE(view.rowSpan(7, 3), 5); + QCOMPARE(view.columnSpan(7, 3), 3); +} + +void tst_QTableView::spansAfterColumnInsertion() +{ + QtTestTableModel model(10, 10); + QtTestTableView view; + view.setModel(&model); + view.setSpan(3, 3, 3, 3); + view.show(); + QTest::qWait(50); + + // Insertion before the span only shifts the span. + view.model()->insertColumns(0, 2); + QCOMPARE(view.rowSpan(3, 3), 1); + QCOMPARE(view.columnSpan(3, 3), 1); + QCOMPARE(view.rowSpan(3, 5), 3); + QCOMPARE(view.columnSpan(3, 5), 3); + + // Insertion happens before the given column, so it only shifts the span also. + view.model()->insertColumns(5, 2); + QCOMPARE(view.rowSpan(3, 5), 1); + QCOMPARE(view.columnSpan(3, 5), 1); + QCOMPARE(view.rowSpan(3, 7), 3); + QCOMPARE(view.columnSpan(3, 7), 3); + + // Insertion inside the span expands it. + view.model()->insertColumns(8, 2); + QCOMPARE(view.rowSpan(3, 7), 3); + QCOMPARE(view.columnSpan(3, 7), 5); + + // Insertion after the span does nothing to it. + view.model()->insertColumns(12, 2); + QCOMPARE(view.rowSpan(3, 7), 3); + QCOMPARE(view.columnSpan(3, 7), 5); +} + +void tst_QTableView::spansAfterRowRemoval() +{ + QtTestTableModel model(10, 10); + QtTestTableView view; + view.setModel(&model); + + QList<QRect> spans; + spans << QRect(0, 1, 1, 2) + << QRect(1, 2, 1, 2) + << QRect(2, 2, 1, 5) + << QRect(2, 8, 1, 2) + << QRect(3, 4, 1, 2) + << QRect(4, 4, 1, 4) + << QRect(5, 6, 1, 3) + << QRect(6, 7, 1, 3); + foreach (QRect span, spans) + view.setSpan(span.top(), span.left(), span.height(), span.width()); + + view.show(); + QTest::qWait(100); + view.model()->removeRows(3, 3); + + QList<QRect> expectedSpans; + expectedSpans << QRect(0, 1, 1, 2) + << QRect(1, 2, 1, 1) + << QRect(2, 2, 1, 2) + << QRect(2, 5, 1, 2) + << QRect(3, 4, 1, 1) + << QRect(4, 3, 1, 2) + << QRect(5, 3, 1, 3) + << QRect(6, 4, 1, 3); + foreach (QRect span, expectedSpans) { + QCOMPARE(view.columnSpan(span.top(), span.left()), span.width()); + QCOMPARE(view.rowSpan(span.top(), span.left()), span.height()); + } +} + +void tst_QTableView::spansAfterColumnRemoval() +{ + QtTestTableModel model(10, 10); + QtTestTableView view; + view.setModel(&model); + + // Same set as above just swapping columns and rows. + QList<QRect> spans; + spans << QRect(0, 1, 1, 2) + << QRect(1, 2, 1, 2) + << QRect(2, 2, 1, 5) + << QRect(2, 8, 1, 2) + << QRect(3, 4, 1, 2) + << QRect(4, 4, 1, 4) + << QRect(5, 6, 1, 3) + << QRect(6, 7, 1, 3); + foreach (QRect span, spans) + view.setSpan(span.left(), span.top(), span.width(), span.height()); + + view.show(); + QTest::qWait(100); + view.model()->removeColumns(3, 3); + + QList<QRect> expectedSpans; + expectedSpans << QRect(0, 1, 1, 2) + << QRect(1, 2, 1, 1) + << QRect(2, 2, 1, 2) + << QRect(2, 5, 1, 2) + << QRect(3, 4, 1, 1) + << QRect(4, 3, 1, 2) + << QRect(5, 3, 1, 3) + << QRect(6, 4, 1, 3); + foreach (QRect span, expectedSpans) { + QCOMPARE(view.columnSpan(span.left(), span.top()), span.height()); + QCOMPARE(view.rowSpan(span.left(), span.top()), span.width()); + } +} + class Model : public QAbstractTableModel { Q_OBJECT diff --git a/tests/auto/qthreadonce/tst_qthreadonce.cpp b/tests/auto/qthreadonce/tst_qthreadonce.cpp index a539a7f..2751e9d 100644 --- a/tests/auto/qthreadonce/tst_qthreadonce.cpp +++ b/tests/auto/qthreadonce/tst_qthreadonce.cpp @@ -134,7 +134,7 @@ void tst_QThreadOnce::sameThread() void tst_QThreadOnce::multipleThreads() { -#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) +#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) || defined(Q_OS_SYMBIAN) const int NumberOfThreads = 20; #else const int NumberOfThreads = 100; diff --git a/tests/auto/qtooltip/tst_qtooltip.cpp b/tests/auto/qtooltip/tst_qtooltip.cpp index 283effa..fc76069 100644 --- a/tests/auto/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/qtooltip/tst_qtooltip.cpp @@ -66,6 +66,7 @@ private slots: // task-specific tests below me void task183679_data(); void task183679(); + void whatsThis(); void setPalette(); }; @@ -131,6 +132,27 @@ void tst_QToolTip::task183679() QCOMPARE(QToolTip::isVisible(), visible); } +#include <QWhatsThis> + +void tst_QToolTip::whatsThis() +{ + qApp->setStyleSheet( "QWidget { font-size: 72px; }" ); + QWhatsThis::showText(QPoint(0,0), "THis is text"); + QTest::qWait(400); + QWidget *whatsthis = 0; + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + if (widget->inherits("QWhatsThat")) { + whatsthis = widget; + break; + } + } + QVERIFY(whatsthis); + QVERIFY(whatsthis->isVisible()); + QVERIFY(whatsthis->height() > 100); // Test QTBUG-2416 + qApp->setStyleSheet(""); +} + + void tst_QToolTip::setPalette() { //the previous test may still have a tooltip pending for deletion diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 4a74d96..11c4543 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -468,6 +468,7 @@ void tst_QTreeWidget::editItem() QTest::ignoreMessage(QtWarningMsg, "edit: editing failed"); tree.editItem(item, col); QApplication::instance()->processEvents(); + QApplication::instance()->processEvents(); QLineEdit *editor = qFindChild<QLineEdit*>(&tree); if (editor) { QVERIFY(item->flags() & Qt::ItemIsEditable); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index fb3cf0e..8856792 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -671,6 +671,26 @@ void tst_QUrl::setUrl() } /* + The tests below are copied from kdelibs/kdecore/tests/kurltest.cpp (an old version of) + + Copyright (c) 1999-2005 Waldo Bastian <bastian@kde.org> + Copyright (c) 2000-2005 David Faure <faure@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ +/* ### File / directory specifics KURL u2( QCString("/home/dfaure/") ); @@ -2242,6 +2262,9 @@ void tst_QUrl::ipv6_2_data() QTest::newRow("[::ffff:129.144.52.38]") << QString("http://[::ffff:129.144.52.38]/cgi/test.cgi") << QString("http://[::ffff:129.144.52.38]/cgi/test.cgi"); + QTest::newRow("[::FFFF:129.144.52.38]") + << QString("http://[::FFFF:129.144.52.38]/cgi/test.cgi") + << QString("http://[::ffff:129.144.52.38]/cgi/test.cgi"); } void tst_QUrl::ipv6_2() diff --git a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp index c2bbe22..f534f3b 100644 --- a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp @@ -491,7 +491,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (thread[y].wait(exited > 0 ? 1 : 1000)) { + if (thread[y].wait(exited > 0 ? 3 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -535,7 +535,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { + if (rwthread[y].wait(exited > 0 ? 3 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -587,7 +587,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (thread[y].wait(exited > 0 ? 1 : 1000)) { + if (thread[y].wait(exited > 0 ? 3 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -633,7 +633,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { + if (rwthread[y].wait(exited > 0 ? 3 : 1000)) { thread_exited[y] = TRUE; ++exited; } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index b0a26c2..f8341c3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -8176,7 +8176,7 @@ public: static bool firstTime = true; if (firstTime) - QTimer::singleShot(70, this, SLOT(resizeMe())); + QTimer::singleShot(150, this, SLOT(resizeMe())); firstTime = false; } @@ -8193,7 +8193,7 @@ void tst_QWidget::moveInResizeEvent() testWidget.setGeometry(50, 50, 200, 200); testWidget.show(); QTest::qWaitForWindowShown(&testWidget); - QTest::qWait(120); + QTest::qWait(160); QRect expectedGeometry(100,100, 100, 100); QTRY_COMPARE(testWidget.geometry(), expectedGeometry); @@ -8674,7 +8674,7 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is bigger than the rect child.setMask(QRegion(0, 0, 1000, 1000)); - QTest::qWait(10); + QTest::qWait(100); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. QTRY_COMPARE(child.numPaintEvents, 1); @@ -8686,7 +8686,7 @@ void tst_QWidget::setClearAndResizeMask() // ...and the same applies when clearing the mask. child.clearMask(); - QTest::qWait(10); + QTest::qWait(100); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. QTRY_VERIFY(child.numPaintEvents > 0); @@ -8711,7 +8711,7 @@ void tst_QWidget::setClearAndResizeMask() // Disable the size grip on the Mac; otherwise it'll be included when grabbing the window. resizeParent.setFixedSize(resizeParent.size()); resizeChild.show(); - QTest::qWait(30); + QTest::qWait(100); resizeChild.paintedRegion = QRegion(); QTimer::singleShot(100, &resizeChild, SLOT(shrinkMask())); @@ -8990,6 +8990,9 @@ void tst_QWidget::syntheticEnterLeave() void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() { +#ifdef Q_OS_WINCE_WM + QSKIP("Windows Mobile has no proper cursor support", SkipAll); +#endif class SELParent : public QWidget { public: @@ -9024,12 +9027,11 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&parent); #endif - QTest::qWait(100); + QTest::qWait(150); QCursor::setPos(child.mapToGlobal(QPoint(100, 100))); - QTest::qWait(100); // Make sure the cursor has entered the child. - QVERIFY(child.numEnterEvents > 0); + QTRY_VERIFY(child.numEnterEvents > 0); child.hide(); child.reset(); @@ -9119,7 +9121,7 @@ void tst_QWidget::paintOutsidePaintEvent() widget.show(); QTest::qWaitForWindowShown(&widget); - QTest::qWait(20); + QTest::qWait(60); const QPixmap before = QPixmap::grabWindow(widget.winId()); @@ -9129,6 +9131,7 @@ void tst_QWidget::paintOutsidePaintEvent() painter.fillRect(child1.rect(), Qt::red); painter.end(); XSync(QX11Info::display(), false); // Flush output buffer. + QTest::qWait(60); const QPixmap after = QPixmap::grabWindow(widget.winId()); diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index 2490a65..25f0f07 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -51,6 +51,9 @@ #include <QDesktopWidget> #include <QX11Info> + +#include "../../shared/util.h" + class tst_QWindowSurface : public QObject { Q_OBJECT @@ -238,9 +241,9 @@ void tst_QWindowSurface::grabWidget() parentWidget.show(); QTest::qWaitForWindowShown(&parentWidget); - QTest::qWait(220); - - QPixmap parentPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget); + QPixmap parentPixmap; + QTRY_COMPARE((parentPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget)).size(), + QSize(300,300)); QPixmap childPixmap = childWidget.windowSurface()->grabWidget(&childWidget); QPixmap babyPixmap = babyWidget.windowSurface()->grabWidget(&babyWidget); QPixmap parentSubPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget, QRect(25, 25, 100, 100)); diff --git a/tests/auto/symbols/tst_symbols.cpp b/tests/auto/symbols/tst_symbols.cpp index 87bd63b..6103ede 100644 --- a/tests/auto/symbols/tst_symbols.cpp +++ b/tests/auto/symbols/tst_symbols.cpp @@ -100,6 +100,7 @@ void tst_Symbols::globalObjects() #ifndef Q_OS_LINUX QSKIP("Linux-specific test", SkipAll); #endif + QSKIP("Test disabled, we're not fixing these issues in this Qt version", SkipAll); // these are regexps for global objects that are allowed in Qt QStringList whitelist = QStringList() diff --git a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro index 531e48b..bcc988a 100644 --- a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro +++ b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro @@ -14,7 +14,10 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { win32:PATTERNIST_SDK = $${PATTERNIST_SDK}d else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug } -LIBS += -l$$PATTERNIST_SDK -lQtXml + +LIBS += -l$$PATTERNIST_SDK + +QT += xml INCLUDEPATH += $$QT_SOURCE_TREE/tests/auto/xmlpatternsxqts/lib/ \ $$QT_BUILD_TREE/include/QtXmlPatterns/private \ diff --git a/tests/benchmarks/qtableview/tst_qtableview.cpp b/tests/benchmarks/qtableview/tst_qtableview.cpp index deeba3f..7247a23 100644 --- a/tests/benchmarks/qtableview/tst_qtableview.cpp +++ b/tests/benchmarks/qtableview/tst_qtableview.cpp @@ -75,6 +75,50 @@ public: return QVariant(); } + bool insertRows(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start > row_count) + return false; + + beginInsertRows(parent, start, start + count - 1); + row_count += count; + endInsertRows(); + return true; + } + + bool removeRows(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start >= row_count || row_count < count) + return false; + + beginRemoveRows(parent, start, start + count - 1); + row_count -= count; + endRemoveRows(); + return true; + } + + bool insertColumns(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start > column_count) + return false; + + beginInsertColumns(parent, start, start + count - 1); + column_count += count; + endInsertColumns(); + return true; + } + + bool removeColumns(int start, int count, const QModelIndex &parent = QModelIndex()) + { + if (start < 0 || start >= column_count || column_count < count) + return false; + + beginRemoveColumns(parent, start, start + count - 1); + column_count -= count; + endRemoveColumns(); + return true; + } + int row_count; int column_count; }; @@ -99,6 +143,14 @@ private slots: void spanDraw(); void spanSelectColumn(); void spanSelectAll(); + void rowInsertion_data(); + void rowInsertion(); + void rowRemoval_data(); + void rowRemoval(); + void columnInsertion_data(); + void columnInsertion(); + void columnRemoval_data(); + void columnRemoval(); private: static inline void spanInit_helper(QTableView *); }; @@ -189,5 +241,127 @@ void tst_QTableView::spanSelectColumn() } } +typedef QVector<QRect> SpanList; +Q_DECLARE_METATYPE(SpanList) + +void spansData() +{ + QTest::addColumn<SpanList>("spans"); + + QTest::newRow("Without spans") + << SpanList(); + + QTest::newRow("With spans") + << (SpanList() + << QRect(0, 1, 1, 2) + << QRect(1, 2, 1, 2) + << QRect(2, 2, 1, 5) + << QRect(2, 8, 1, 2) + << QRect(3, 4, 1, 2) + << QRect(4, 4, 1, 4) + << QRect(5, 6, 1, 3) + << QRect(6, 7, 1, 3)); +} + +void tst_QTableView::rowInsertion_data() +{ + spansData(); +} + +void tst_QTableView::rowInsertion() +{ + QFETCH(SpanList, spans); + + QtTestTableModel model(10, 10); + QTableView view; + view.setModel(&model); + + foreach (QRect span, spans) + view.setSpan(span.top(), span.left(), span.height(), span.width()); + view.show(); + QTest::qWait(50); + + QBENCHMARK_ONCE { + view.model()->insertRows(0, 2); + view.model()->insertRows(5, 2); + view.model()->insertRows(8, 2); + view.model()->insertRows(12, 2); + } +} + +void tst_QTableView::rowRemoval_data() +{ + spansData(); +} + +void tst_QTableView::rowRemoval() +{ + QFETCH(SpanList, spans); + + QtTestTableModel model(10, 10); + QTableView view; + view.setModel(&model); + + foreach (QRect span, spans) + view.setSpan(span.top(), span.left(), span.height(), span.width()); + view.show(); + QTest::qWait(50); + + QBENCHMARK_ONCE { + view.model()->removeRows(3, 3); + } +} + +void tst_QTableView::columnInsertion_data() +{ + spansData(); +} + +void tst_QTableView::columnInsertion() +{ + QFETCH(SpanList, spans); + + QtTestTableModel model(10, 10); + QTableView view; + view.setModel(&model); + + // Same set as for rowInsertion, just swapping columns and rows. + foreach (QRect span, spans) + view.setSpan(span.left(), span.top(), span.width(), span.height()); + view.show(); + QTest::qWait(50); + + QBENCHMARK_ONCE { + view.model()->insertColumns(0, 2); + view.model()->insertColumns(5, 2); + view.model()->insertColumns(8, 2); + view.model()->insertColumns(12, 2); + } +} + +void tst_QTableView::columnRemoval_data() +{ + spansData(); +} + +void tst_QTableView::columnRemoval() +{ + QFETCH(SpanList, spans); + + QtTestTableModel model(10, 10); + QTableView view; + view.setModel(&model); + + // Same set as for rowRemoval, just swapping columns and rows. + foreach (QRect span, spans) + view.setSpan(span.left(), span.top(), span.width(), span.height()); + view.show(); + QTest::qWait(50); + + QBENCHMARK_ONCE { + view.model()->removeColumns(3, 3); + } +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" |