diff options
Diffstat (limited to 'tests')
4 files changed, 153 insertions, 5 deletions
diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index a40bcc0..1990c0d 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -69,6 +69,8 @@ public: void expandObjectById(const QByteArray& objectName, quint64 objectId); void setProperty(const QByteArray& id, qint64 objectId, const QString &property, const QString &value); void activateFrame(int frameId); + void startCoverageCompleted(); + void startCoverageRun(); // info from last exec JSAgentWatchData exec_data; @@ -94,6 +96,11 @@ signals: void stopped(); void expanded(); void watchTriggered(); + void coverageScriptLoaded(); + void coverageFuncEntered(); + void coverageFuncExited(); + void coveragePosChanged(); + void coverageCompleted(); protected: virtual void statusChanged(Status status); @@ -156,6 +163,9 @@ private slots: void setProperty4(); void activateFrame2(); void verifyQMLOptimizerDisabled(); + void testCoverageCompleted(); + void testCoverageRun(); + }; @@ -280,6 +290,28 @@ void QJSDebugClient::activateFrame(int frameId) sendMessage(reply); } +void QJSDebugClient::startCoverageRun() +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd = "COVERAGE"; + bool enabled = true; + rs << cmd + << enabled; + sendMessage(reply); +} + +void QJSDebugClient::startCoverageCompleted() +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd = "COVERAGE"; + bool enabled = false; + rs << cmd + << enabled; + sendMessage(reply); +} + void QJSDebugClient::statusChanged(Status /*status*/) { emit statusHasChanged(); @@ -317,6 +349,30 @@ void QJSDebugClient::messageReceived(const QByteArray &data) stream >> ping; QCOMPARE(ping, m_ping); emit pong(); + } else if (command == "COVERAGE") { + qint64 time; + int messageType; + qint64 scriptId; + QString program; + QString fileName; + int baseLineNumber; + int lineNumber; + int columnNumber; + QString returnValue; + + stream >> time >> messageType >> scriptId >> program >> fileName >> baseLineNumber + >> lineNumber >> columnNumber >> returnValue; + if (messageType == CoverageComplete) { + emit coverageCompleted(); + } else if (messageType == CoverageScriptLoad) { + emit coverageScriptLoaded(); + } else if (messageType == CoveragePosChange) { + emit coveragePosChanged(); + } else if (messageType == CoverageFuncEntry) { + emit coverageFuncEntered(); + } else if (messageType == CoverageFuncExit) { + emit coverageFuncExited(); + } } else { QFAIL("Unknown message :" + command); } @@ -1336,6 +1392,51 @@ void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled() QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped()))); } + +void tst_QDeclarativeDebugJS::testCoverageCompleted() +{ + QJSDebugProcess process; + process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + QVERIFY(process.waitForStarted()); + + QDeclarativeDebugConnection connection; + connection.connectToHost("127.0.0.1", 3771); + QVERIFY(connection.waitForConnected()); + + QJSDebugClient client(&connection); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + if (client.status() == QJSDebugClient::Unavailable) + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + QCOMPARE(client.status(), QJSDebugClient::Enabled); + + client.startCoverageCompleted(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageCompleted()))); +} + +void tst_QDeclarativeDebugJS::testCoverageRun() +{ + QJSDebugProcess process; + process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + QVERIFY(process.waitForStarted()); + + QDeclarativeDebugConnection connection; + connection.connectToHost("127.0.0.1", 3771); + QVERIFY(connection.waitForConnected()); + + QJSDebugClient client(&connection); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + if (client.status() == QJSDebugClient::Unavailable) + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + QCOMPARE(client.status(), QJSDebugClient::Enabled); + + client.startCoverageRun(); + client.startCoverageCompleted(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageScriptLoaded()))); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coveragePosChanged()))); + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncEntered()))); + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncExited()))); +} + QTEST_MAIN(tst_QDeclarativeDebugJS) #include "tst_qdeclarativedebugjs.moc" diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml index a3e92fe..8359ad1 100644 --- a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml @@ -1,7 +1,7 @@ import QtQuick 1.0 Flickable { - width: 100; height: 100 + width: 100; height: 200 contentWidth: column.width; contentHeight: column.height Column { diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index b077fdc..4d4c30b 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -78,10 +78,12 @@ private slots: void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); void wheel(); + void flickVelocity(); private: QDeclarativeEngine engine; + void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration); template<typename T> T *findItem(QGraphicsObject *parent, const QString &objectName); }; @@ -480,6 +482,51 @@ void tst_qdeclarativeflickable::wheel() delete canvas; } +void tst_qdeclarativeflickable::flickVelocity() +{ +#ifdef Q_WS_MAC + QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll); +#endif + + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject()); + QVERIFY(flickable != 0); + + // flick up + flick(canvas, QPoint(20,190), QPoint(20, 50), 200); + QVERIFY(flickable->verticalVelocity() > 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + // flick down + flick(canvas, QPoint(20,10), QPoint(20, 140), 200); + QVERIFY(flickable->verticalVelocity() < 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + delete canvas; +} + +void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration) +{ + const int pointCount = 5; + QPoint diff = to - from; + + // send press, five equally spaced moves, and release. + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from)); + + for (int i = 0; i < pointCount; ++i) { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::qWait(duration/pointCount); + QCoreApplication::processEvents(); + } + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); +} template<typename T> T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index e3f7980..4342ff3 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -450,12 +450,12 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // Confirm items positioned correctly - for (int i = 6; i < 18; ++i) { + for (int i = 3; i < 15; ++i) { QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), 60+(i/3)*60.0); } // Remove currentIndex @@ -476,7 +476,7 @@ void tst_QDeclarativeGridView::removed() if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); + QTRY_VERIFY(item->y() == 60+(i/3)*60); } // remove item outside current view. |