diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-03 15:28:51 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-06-04 17:02:55 +0200 |
commit | 11a11d1280b1634628b9c4a92a0fc420ee8a3a81 (patch) | |
tree | b48d9608ef3f08123cdeea605068342131b32b44 /tests/auto | |
parent | 52e07d564b65ed6ce26955a676c7692ad67686c1 (diff) | |
parent | fea26bb2941c3f24c4a5f3ad5efc1b85e0123ff3 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
The merge conflict is about the removal of "d1" from the register
set on ARM, but that was already done in dev in commit ddb33ee9ba9e1344caa9be5dbf4b534c3ede692e
The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675eab163b22dcc4e8ded80ed04d06369b
was reverted to what it was before, per Laszlo's advice.
Conflicts:
src/qml/jit/qv4isel_masm.cpp
Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
Diffstat (limited to 'tests/auto')
8 files changed, 356 insertions, 158 deletions
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro index 4c4342a6a5..303e78db75 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -6,11 +6,7 @@ PUBLICTESTS += \ qqmlinspector \ qqmlprofilerservice \ qpacketprotocol \ -# qv4profilerservice \ -# qdebugmessageservice \ qqmlenginedebuginspectorintegrationtest \ - qqmlinspector \ - qqmlprofilerservice \ qqmlenginecontrol PRIVATETESTS += \ diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index a918e23a05..5fd985f6d5 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -136,7 +136,9 @@ public: { } - QList<QQmlProfilerData> traceMessages; + QList<QQmlProfilerData> synchronousMessages; + QList<QQmlProfilerData> asynchronousMessages; + QList<QQmlProfilerData> pixmapMessages; void setTraceState(bool enabled) { QByteArray message; @@ -171,6 +173,7 @@ private: QQmlProfilerClient *m_client; void connect(bool block, const QString &testFile); + void checkTraceReceived(); private slots: void cleanup(); @@ -305,7 +308,17 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message) break; } QVERIFY(stream.atEnd()); - traceMessages.append(data); + if (data.messageType == QQmlProfilerClient::PixmapCacheEvent) + pixmapMessages.append(data); + else if (data.messageType == QQmlProfilerClient::SceneGraphFrame || + (data.messageType == QQmlProfilerClient::Event && + (data.detailType == QQmlProfilerClient::FramePaint || + data.detailType == QQmlProfilerClient::AnimationFrame || + data.detailType == QQmlProfilerClient::Mouse || + data.detailType == QQmlProfilerClient::Key))) + asynchronousMessages.append(data); + else + synchronousMessages.append(data); } void tst_QQmlProfilerService::connect(bool block, const QString &testFile) @@ -331,9 +344,44 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) m_connection->connectToHost(QLatin1String("127.0.0.1"), port); } +void tst_QQmlProfilerService::checkTraceReceived() +{ + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); + QVERIFY(m_client->synchronousMessages.count()); + + // must start with "StartTrace" + QCOMPARE(m_client->synchronousMessages.first().messageType, (int)QQmlProfilerClient::Event); + QCOMPARE(m_client->synchronousMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->synchronousMessages.last().messageType, (int)QQmlProfilerClient::Event); + QCOMPARE(m_client->synchronousMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); +} + void tst_QQmlProfilerService::cleanup() { if (QTest::currentTestFailed()) { + qDebug() << "Synchronous Messages:" << m_client->synchronousMessages.count(); + int i = 0; + foreach (const QQmlProfilerData &data, m_client->synchronousMessages) { + qDebug() << i++ << data.time << data.messageType << data.detailType << data.detailData + << data.line << data.column; + } + qDebug() << " "; + qDebug() << "Asynchronous Messages:" << m_client->asynchronousMessages.count(); + i = 0; + foreach (const QQmlProfilerData &data, m_client->asynchronousMessages) { + qDebug() << i++ << data.time << data.messageType << data.detailType << data.detailData + << data.framerate << data.animationcount << data.line << data.column; + } + qDebug() << " "; + qDebug() << "Pixmap Cache Messages:" << m_client->pixmapMessages.count(); + i = 0; + foreach (const QQmlProfilerData &data, m_client->pixmapMessages) { + qDebug() << i++ << data.time << data.messageType << data.detailType << data.detailData + << data.line << data.column; + } + qDebug() << " "; qDebug() << "Process State:" << (m_process ? m_process->state() : QLatin1String("null")); qDebug() << "Application Output:" << (m_process ? m_process->output() : QLatin1String("null")); qDebug() << "Connection State:" << (m_connection ? m_connection->stateString() : QLatin1String("null")); @@ -355,16 +403,7 @@ void tst_QQmlProfilerService::blockingConnectWithTraceEnabled() m_client->setTraceState(true); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - - QVERIFY(m_client->traceMessages.count()); - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); } void tst_QQmlProfilerService::blockingConnectWithTraceDisabled() @@ -376,17 +415,7 @@ void tst_QQmlProfilerService::blockingConnectWithTraceDisabled() m_client->setTraceState(false); m_client->setTraceState(true); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - - QVERIFY(m_client->traceMessages.count()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); } void tst_QQmlProfilerService::nonBlockingConnect() @@ -397,16 +426,7 @@ void tst_QQmlProfilerService::nonBlockingConnect() m_client->setTraceState(true); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY(m_client->traceMessages.count()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); } void tst_QQmlProfilerService::pixmapCacheData() @@ -424,35 +444,27 @@ void tst_QQmlProfilerService::pixmapCacheData() m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY2(m_client->traceMessages.count() >= 20, - QString::number(m_client->traceMessages.count()).toUtf8().constData()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); + checkTraceReceived(); + QVERIFY2(m_client->pixmapMessages.count() >= 4, + QString::number(m_client->pixmapMessages.count()).toUtf8().constData()); // image starting to load - QCOMPARE(m_client->traceMessages[16].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->traceMessages[16].detailType, (int)QQmlProfilerClient::PixmapLoadingStarted); + QCOMPARE(m_client->pixmapMessages[0].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->pixmapMessages[0].detailType, (int)QQmlProfilerClient::PixmapLoadingStarted); // image size - QCOMPARE(m_client->traceMessages[17].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->traceMessages[17].detailType, (int)QQmlProfilerClient::PixmapSizeKnown); - QCOMPARE(m_client->traceMessages[17].line, 2); // width - QCOMPARE(m_client->traceMessages[17].column, 2); // height + QCOMPARE(m_client->pixmapMessages[1].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->pixmapMessages[1].detailType, (int)QQmlProfilerClient::PixmapSizeKnown); + QCOMPARE(m_client->pixmapMessages[1].line, 2); // width + QCOMPARE(m_client->pixmapMessages[1].column, 2); // height // image loaded - QCOMPARE(m_client->traceMessages[18].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->traceMessages[18].detailType, (int)QQmlProfilerClient::PixmapLoadingFinished); + QCOMPARE(m_client->pixmapMessages[2].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->pixmapMessages[2].detailType, (int)QQmlProfilerClient::PixmapLoadingFinished); // cache size - QCOMPARE(m_client->traceMessages[19].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->traceMessages[19].detailType, (int)QQmlProfilerClient::PixmapCacheCountChanged); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + QCOMPARE(m_client->pixmapMessages[3].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->pixmapMessages[3].detailType, (int)QQmlProfilerClient::PixmapCacheCountChanged); } @@ -468,8 +480,7 @@ void tst_QQmlProfilerService::scenegraphData() QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY(m_client->traceMessages.count()); + checkTraceReceived(); // check that at least one frame was rendered // there should be a SGPolishAndSync + SGRendererFrame + SGRenderLoopFrame sequence @@ -477,7 +488,7 @@ void tst_QQmlProfilerService::scenegraphData() // // since the rendering happens in a different thread, there could be other unrelated events interleaved int loopcheck = 0; - foreach (const QQmlProfilerData &msg, m_client->traceMessages) { + foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.messageType == QQmlProfilerClient::SceneGraphFrame) { if (loopcheck == 0 && msg.detailType == QQmlProfilerClient::SceneGraphContextFrame) loopcheck = 1; @@ -498,17 +509,7 @@ void tst_QQmlProfilerService::profileOnExit() m_client->setTraceState(true); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY2(m_client->traceMessages.count() >= 2, - QString::number(m_client->traceMessages.count()).toUtf8().constData()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); } void tst_QQmlProfilerService::controlFromJS() @@ -518,17 +519,7 @@ void tst_QQmlProfilerService::controlFromJS() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY2(m_client->traceMessages.count() >= 2, - QString::number(m_client->traceMessages.count()).toUtf8().constData()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); } void tst_QQmlProfilerService::signalSourceLocation() @@ -541,32 +532,24 @@ void tst_QQmlProfilerService::signalSourceLocation() while (!(m_process->output().contains(QLatin1String("500")))) QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - - QVERIFY2(m_client->traceMessages.count() >= 20, - QString::number(m_client->traceMessages.count()).toUtf8().constData()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - QCOMPARE(m_client->traceMessages[14].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->traceMessages[14].detailType, (int)QQmlProfilerClient::HandlingSignal); - QVERIFY2(m_client->traceMessages[14].detailData.endsWith("signalSourceLocation.qml"), - m_client->traceMessages[14].detailData.toUtf8().constData()); - QCOMPARE(m_client->traceMessages[14].line, 8); - QCOMPARE(m_client->traceMessages[14].column, 28); - - QCOMPARE(m_client->traceMessages[19].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->traceMessages[19].detailType, (int)QQmlProfilerClient::HandlingSignal); - QVERIFY2(m_client->traceMessages[19].detailData.endsWith("signalSourceLocation.qml"), - m_client->traceMessages[19].detailData.toUtf8().constData()); - QCOMPARE(m_client->traceMessages[19].line, 7); - QCOMPARE(m_client->traceMessages[19].column, 21); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + checkTraceReceived(); + + QVERIFY2(m_client->synchronousMessages.count() >= 20, + QString::number(m_client->synchronousMessages.count()).toUtf8().constData()); + + QCOMPARE(m_client->synchronousMessages[14].messageType, (int)QQmlProfilerClient::RangeLocation); + QCOMPARE(m_client->synchronousMessages[14].detailType, (int)QQmlProfilerClient::HandlingSignal); + QVERIFY2(m_client->synchronousMessages[14].detailData.endsWith("signalSourceLocation.qml"), + m_client->synchronousMessages[14].detailData.toUtf8().constData()); + QCOMPARE(m_client->synchronousMessages[14].line, 8); + QCOMPARE(m_client->synchronousMessages[14].column, 28); + + QCOMPARE(m_client->synchronousMessages[19].messageType, (int)QQmlProfilerClient::RangeLocation); + QCOMPARE(m_client->synchronousMessages[19].detailType, (int)QQmlProfilerClient::HandlingSignal); + QVERIFY2(m_client->synchronousMessages[19].detailData.endsWith("signalSourceLocation.qml"), + m_client->synchronousMessages[19].detailData.toUtf8().constData()); + QCOMPARE(m_client->synchronousMessages[19].line, 7); + QCOMPARE(m_client->synchronousMessages[19].column, 21); } void tst_QQmlProfilerService::javascript() @@ -579,35 +562,28 @@ void tst_QQmlProfilerService::javascript() while (!(m_process->output().contains(QLatin1String("done")))) QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); m_client->setTraceState(false); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); + checkTraceReceived(); - QVERIFY2(m_client->traceMessages.count() >= 36, - QString::number(m_client->traceMessages.count()).toUtf8().constData()); - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); - - QCOMPARE(m_client->traceMessages[32].messageType, (int)QQmlProfilerClient::RangeStart); - QCOMPARE(m_client->traceMessages[32].detailType, (int)QQmlProfilerClient::Javascript); + QVERIFY2(m_client->synchronousMessages.count() >= 36, + QString::number(m_client->synchronousMessages.count()).toUtf8().constData()); - QCOMPARE(m_client->traceMessages[33].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->traceMessages[33].detailType, (int)QQmlProfilerClient::Javascript); - QVERIFY2(m_client->traceMessages[33].detailData.endsWith("javascript.qml"), - m_client->traceMessages[33].detailData.toUtf8().constData()); - QCOMPARE(m_client->traceMessages[33].line, 4); - QCOMPARE(m_client->traceMessages[33].column, 5); + QCOMPARE(m_client->synchronousMessages[32].messageType, (int)QQmlProfilerClient::RangeStart); + QCOMPARE(m_client->synchronousMessages[32].detailType, (int)QQmlProfilerClient::Javascript); - QCOMPARE(m_client->traceMessages[34].messageType, (int)QQmlProfilerClient::RangeData); - QCOMPARE(m_client->traceMessages[34].detailType, (int)QQmlProfilerClient::Javascript); - QVERIFY2(m_client->traceMessages[34].detailData == "something", - m_client->traceMessages[34].detailData.toUtf8().constData()); + QCOMPARE(m_client->synchronousMessages[33].messageType, (int)QQmlProfilerClient::RangeLocation); + QCOMPARE(m_client->synchronousMessages[33].detailType, (int)QQmlProfilerClient::Javascript); + QVERIFY2(m_client->synchronousMessages[33].detailData.endsWith("javascript.qml"), + m_client->synchronousMessages[33].detailData.toUtf8().constData()); + QCOMPARE(m_client->synchronousMessages[33].line, 4); + QCOMPARE(m_client->synchronousMessages[33].column, 5); - QCOMPARE(m_client->traceMessages[35].messageType, (int)QQmlProfilerClient::RangeEnd); - QCOMPARE(m_client->traceMessages[35].detailType, (int)QQmlProfilerClient::Javascript); + QCOMPARE(m_client->synchronousMessages[34].messageType, (int)QQmlProfilerClient::RangeData); + QCOMPARE(m_client->synchronousMessages[34].detailType, (int)QQmlProfilerClient::Javascript); + QVERIFY2(m_client->synchronousMessages[34].detailData == "something", + m_client->synchronousMessages[34].detailData.toUtf8().constData()); - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + QCOMPARE(m_client->synchronousMessages[35].messageType, (int)QQmlProfilerClient::RangeEnd); + QCOMPARE(m_client->synchronousMessages[35].detailType, (int)QQmlProfilerClient::Javascript); } QTEST_MAIN(tst_QQmlProfilerService) diff --git a/tests/auto/qml/qqmllanguage/data/idPropertyMismatch.qml b/tests/auto/qml/qqmllanguage/data/idPropertyMismatch.qml new file mode 100644 index 0000000000..8c4fd65786 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/idPropertyMismatch.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 +QtObject { + property int id; + id: "root" +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index be417df325..e77c15b79a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -146,6 +146,7 @@ private slots: void onCompleted(); void onDestruction(); void scriptString(); + void scriptStringWithoutSourceCode(); void defaultPropertyListOrder(); void declaredPropertyValues(); void dontDoubleCallClassBegin(); @@ -1200,21 +1201,32 @@ void tst_qqmllanguage::inlineQmlComponents() // Tests that types that have an id property have it set void tst_qqmllanguage::idProperty() { - QQmlComponent component(&engine, testFileUrl("idProperty.qml")); - VERIFY_ERRORS(0); - MyContainer *object = qobject_cast<MyContainer *>(component.create()); - QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 2); - MyTypeObject *child = - qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); - QVERIFY(child != 0); - QCOMPARE(child->id(), QString("myObjectId")); - QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); + { + QQmlComponent component(&engine, testFileUrl("idProperty.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast<MyContainer *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->getChildren()->count(), 2); + MyTypeObject *child = + qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("myObjectId")); + QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); - child = - qobject_cast<MyTypeObject *>(object->getChildren()->at(1)); - QVERIFY(child != 0); - QCOMPARE(child->id(), QString("name.with.dots")); + child = + qobject_cast<MyTypeObject *>(object->getChildren()->at(1)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("name.with.dots")); + } + { + QQmlComponent component(&engine, testFileUrl("idPropertyMismatch.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> root(component.create()); + QVERIFY(!root.isNull()); + QQmlContext *ctx = qmlContext(root.data()); + QVERIFY(ctx); + QCOMPARE(ctx->nameForObject(root.data()), QString("root")); + } } // Tests automatic connection to notify signals if "onBlahChanged" syntax is used @@ -1932,6 +1944,54 @@ void tst_qqmllanguage::scriptString() } } +void tst_qqmllanguage::scriptStringWithoutSourceCode() +{ + QUrl url = testFileUrl("scriptString7.qml"); + { + QQmlEnginePrivate *eng = QQmlEnginePrivate::get(&engine); + QQmlTypeData *td = eng->typeLoader.getType(url); + Q_ASSERT(td); + + QV4::CompiledData::QmlUnit *qmlUnit = td->compiledData()->qmlUnit; + Q_ASSERT(qmlUnit); + const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(qmlUnit->indexOfRootObject); + QCOMPARE(qmlUnit->header.stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject")); + quint32 i; + for (i = 0; i < rootObject->nBindings; ++i) { + const QV4::CompiledData::Binding *binding = rootObject->bindingTable() + i; + if (qmlUnit->header.stringAt(binding->propertyNameIndex) != QString("scriptProperty")) + continue; + QCOMPARE(binding->valueAsScriptString(&qmlUnit->header), QString("intProperty")); + const_cast<QV4::CompiledData::Binding*>(binding)->stringIndex = 0; // empty string index + QVERIFY(binding->valueAsScriptString(&qmlUnit->header).isEmpty()); + break; + } + QVERIFY(i < rootObject->nBindings); + } + QQmlComponent component(&engine, url); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QQmlScriptString ss = object->scriptProperty(); + QVERIFY(!ss.isEmpty()); + QCOMPARE(ss.stringLiteral(), QString()); + bool ok; + QCOMPARE(ss.numberLiteral(&ok), qreal(0.)); + QCOMPARE(ok, false); + + const QQmlScriptStringPrivate *scriptPrivate = QQmlScriptStringPrivate::get(ss); + QVERIFY(scriptPrivate != 0); + QVERIFY(scriptPrivate->script.isEmpty()); + QCOMPARE(scriptPrivate->scope, qobject_cast<QObject*>(object)); + QCOMPARE(scriptPrivate->context, qmlContext(object)); + + { + QQmlExpression expr(ss, /*context*/0, object); + QCOMPARE(expr.evaluate().toInt(), int(100)); + } +} + // Check that default property assignments are correctly spliced into explicit // property assignments void tst_qqmllanguage::defaultPropertyListOrder() diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 22404aa862..ede80b355a 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -132,6 +132,7 @@ private slots: void empty_element_warning_data(); void datetime(); void datetime_data(); + void about_to_be_signals(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1306,6 +1307,134 @@ void tst_qqmllistmodel::datetime() QVERIFY(expected == dtResult); } +class RowTester : public QObject +{ + Q_OBJECT +public: + RowTester(QAbstractItemModel *model) : QObject(model), model(model) + { + reset(); + connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(rowsAboutToBeInserted())); + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted())); + connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(rowsAboutToBeRemoved())); + connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved())); + connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(rowsAboutToBeMoved())); + connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(rowsMoved())); + } + + void reset() + { + rowsAboutToBeInsertedCalls = 0; + rowsAboutToBeInsertedCount = 0; + rowsInsertedCalls = 0; + rowsInsertedCount = 0; + rowsAboutToBeRemovedCalls = 0; + rowsAboutToBeRemovedCount = 0; + rowsRemovedCalls = 0; + rowsRemovedCount = 0; + rowsAboutToBeMovedCalls = 0; + rowsAboutToBeMovedData.clear(); + rowsMovedCalls = 0; + rowsMovedData.clear(); + } + + int rowsAboutToBeInsertedCalls; + int rowsAboutToBeInsertedCount; + int rowsInsertedCalls; + int rowsInsertedCount; + int rowsAboutToBeRemovedCalls; + int rowsAboutToBeRemovedCount; + int rowsRemovedCalls; + int rowsRemovedCount; + int rowsAboutToBeMovedCalls; + QVariantList rowsAboutToBeMovedData; + int rowsMovedCalls; + QVariantList rowsMovedData; + +private slots: + void rowsAboutToBeInserted() + { + rowsAboutToBeInsertedCalls++; + rowsAboutToBeInsertedCount = model->rowCount(); + } + + void rowsInserted() + { + rowsInsertedCalls++; + rowsInsertedCount = model->rowCount(); + } + + void rowsAboutToBeRemoved() + { + rowsAboutToBeRemovedCalls++; + rowsAboutToBeRemovedCount = model->rowCount(); + } + + void rowsRemoved() + { + rowsRemovedCalls++; + rowsRemovedCount = model->rowCount(); + } + + void rowsAboutToBeMoved() + { + rowsAboutToBeMovedCalls++; + for (int i = 0; i < model->rowCount(); ++i) + rowsAboutToBeMovedData += model->data(model->index(i, 0), 0); + } + + void rowsMoved() + { + rowsMovedCalls++; + for (int i = 0; i < model->rowCount(); ++i) + rowsMovedData += model->data(model->index(i, 0), 0); + } + +private: + QAbstractItemModel *model; +}; + +void tst_qqmllistmodel::about_to_be_signals() +{ + QQmlEngine engine; + QQmlListModel model; + QQmlEngine::setContextForObject(&model,engine.rootContext()); + + RowTester tester(&model); + + QQmlExpression e1(engine.rootContext(), &model, "{append({'test':0})}"); + e1.evaluate(); + + QCOMPARE(tester.rowsAboutToBeInsertedCalls, 1); + QCOMPARE(tester.rowsAboutToBeInsertedCount, 0); + QCOMPARE(tester.rowsInsertedCalls, 1); + QCOMPARE(tester.rowsInsertedCount, 1); + + QQmlExpression e2(engine.rootContext(), &model, "{append({'test':1})}"); + e2.evaluate(); + + QCOMPARE(tester.rowsAboutToBeInsertedCalls, 2); + QCOMPARE(tester.rowsAboutToBeInsertedCount, 1); + QCOMPARE(tester.rowsInsertedCalls, 2); + QCOMPARE(tester.rowsInsertedCount, 2); + + QQmlExpression e3(engine.rootContext(), &model, "{move(0, 1, 1)}"); + e3.evaluate(); + + QCOMPARE(tester.rowsAboutToBeMovedCalls, 1); + QCOMPARE(tester.rowsAboutToBeMovedData, QVariantList() << 0.0 << 1.0); + QCOMPARE(tester.rowsMovedCalls, 1); + QCOMPARE(tester.rowsMovedData, QVariantList() << 1.0 << 0.0); + + QQmlExpression e4(engine.rootContext(), &model, "{remove(0, 2)}"); + e4.evaluate(); + + QCOMPARE(tester.rowsAboutToBeRemovedCalls, 1); + QCOMPARE(tester.rowsAboutToBeRemovedCount, 2); + QCOMPARE(tester.rowsRemovedCalls, 1); + QCOMPARE(tester.rowsRemovedCount, 0); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" diff --git a/tests/auto/qmltest/textinput/tst_textinput.qml b/tests/auto/qmltest/textinput/tst_textinput.qml index c359d53200..9a00ac8a60 100644 --- a/tests/auto/qmltest/textinput/tst_textinput.qml +++ b/tests/auto/qmltest/textinput/tst_textinput.qml @@ -75,6 +75,13 @@ Item { TextInput { id: txtfunctions + text: "The quick brown fox" + height: 20 + width: 50 + } + + TextInput { + id: txtclipboard text: "The quick brown fox jumped over the lazy dog" height: 20 width: 50 @@ -143,31 +150,51 @@ Item { compare(txtentry.text, "hello world") } - function test_functions() { + function test_select_insert() { compare(txtfunctions.getText(4,9), "quick") txtfunctions.select(4,9); compare(txtfunctions.selectedText, "quick") + txtfunctions.insert(4, "very ") + compare(txtfunctions.text, "The very quick brown fox") txtfunctions.deselect(); compare(txtfunctions.selectedText, "") - txtfunctions.select(4,9); - txtfunctions.cut(); - compare(txtfunctions.text, "The brown fox jumped over the lazy dog") txtfunctions.text = "Qt"; txtfunctions.insert(txtfunctions.text.length, " ") compare(txtfunctions.text, "Qt "); - txtfunctions.cursorPosition = txtfunctions.text.length; - txtfunctions.paste(); + txtfunctions.insert(txtfunctions.text.length, "quick") compare(txtfunctions.text, "Qt quick"); txtfunctions.cursorPosition = txtfunctions.text.length; txtfunctions.selectWord(); compare(txtfunctions.selectedText, "quick") - txtfunctions.copy(); txtfunctions.selectAll(); compare(txtfunctions.selectedText, "Qt quick") txtfunctions.deselect(); compare(txtfunctions.selectedText, "") - txtfunctions.paste(); - compare(txtfunctions.text, "Qt quickquick"); + } + + function test_clipboard() { + if (typeof(txtclipboard.copy) !== "function" + || typeof(txtclipboard.paste) !== "function" + || typeof(txtclipboard.cut) !== "function") { + skip("Clipboard is not supported on this platform.") + } + txtclipboard.select(4,10); + txtclipboard.cut(); + compare(txtclipboard.text, "The brown fox jumped over the lazy dog") + txtclipboard.select(30,35) + txtclipboard.paste(); + compare(txtclipboard.text, "The brown fox jumped over the quick dog") + txtclipboard.text = "Qt "; + txtclipboard.cursorPosition = txtclipboard.text.length; + txtclipboard.paste(); + compare(txtclipboard.text, "Qt quick "); + txtclipboard.cursorPosition = txtclipboard.text.length-1; + txtclipboard.selectWord(); + compare(txtclipboard.selectedText, "quick") + txtclipboard.copy(); + txtclipboard.cursorPosition = txtclipboard.text.length; + txtclipboard.paste(); + compare(txtclipboard.text, "Qt quick quick"); } function test_intvalidators_data() { diff --git a/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml index 5ba4d35684..876d325d5a 100644 --- a/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml +++ b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml @@ -9,7 +9,7 @@ Rectangle { Rectangle { anchors.centerIn: parent - width: 180 + width: parent.width height: 20 color: "green" diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 9ca7cafe3d..6167577b60 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -732,10 +732,15 @@ void tst_qquicktext::horizontalAlignment() void tst_qquicktext::horizontalAlignment_RightToLeft() { +#if defined(Q_OS_BLACKBERRY) + QQuickWindow dummy; // On BlackBerry first window is always full screen, + dummy.showFullScreen(); // so make test window a second window. +#endif + QQuickView *window = createView(testFile("horizontalAlignment_RightToLeft.qml")); QQuickText *text = window->rootObject()->findChild<QQuickText*>("text"); QVERIFY(text != 0); - window->show(); + window->showNormal(); QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text); QVERIFY(textPrivate != 0); |