diff options
Diffstat (limited to 'tests/auto/qml')
51 files changed, 661 insertions, 34 deletions
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index 363efeabbc..e6cbd41b8e 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -48,7 +48,7 @@ #include <QtCore/QString> #include <QtTest/QtTest> -const char *NORMALMODE = "-qmljsdebugger=port:3777,block"; +const char *NORMALMODE = "-qmljsdebugger=port:3777,3787,block"; const char *QMLFILE = "test.qml"; class QQmlDebugMsgClient; @@ -186,7 +186,8 @@ void tst_QDebugMessageService::init() QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); - m_connection->connectToHost("127.0.0.1", 3777); + const int port = m_process->debugPort(); + m_connection->connectToHost("127.0.0.1", port); QVERIFY(m_connection->waitForConnected()); if (m_client->state() != QQmlDebugClient::Enabled) diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro index eb5f17a55d..d4ce36dc4a 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro @@ -22,3 +22,5 @@ OTHER_FILES += data/test.qml data/test.js \ data/breakpointRelocation.qml \ data/createComponent.qml DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +mac:CONFIG+=insignificant_test # QTBUG-28263 diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index 9c2ba5bcde..424a3b36ac 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -53,6 +53,11 @@ #include "qqmldebugclient.h" #include "../../../shared/util.h" +#if defined (Q_OS_WINCE) +#undef IN +#undef OUT +#endif + const char *V8REQUEST = "v8request"; const char *V8MESSAGE = "v8message"; const char *SEQ = "seq"; diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index dd4dd003ec..1c1d84f37b 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -104,7 +104,7 @@ void tst_QQmlDebugService::checkPortRange() QQmlDebugConnection *connection1 = new QQmlDebugConnection(); QQmlDebugProcess *process1 = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - process1->start(QStringList() << QLatin1String("-qmljsdebugger=port:3772, 3774 ") << testFile("test.qml")); + process1->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") << testFile("test.qml")); if (!process1->waitForSessionStart()) QFAIL("could not launch application, or did not get 'Waiting for connection'."); @@ -118,7 +118,7 @@ void tst_QQmlDebugService::checkPortRange() QQmlDebugConnection *connection2 = new QQmlDebugConnection(); QQmlDebugProcess *process2 = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - process2->start(QStringList() << QLatin1String("-qmljsdebugger=port:3772,3774") << testFile("test.qml")); + process2->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") << testFile("test.qml")); if (!process2->waitForSessionStart()) QFAIL("could not launch application, or did not get 'Waiting for connection'."); diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index 6f99afd917..5badcaa3ae 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -52,8 +52,8 @@ #include "qqmlinspectorclient.h" #include "qqmlenginedebugclient.h" -#define PORT 3776 -#define STR_PORT "3776" +#define STR_PORT_FROM "3776" +#define STR_PORT_TO "3786" class tst_QQmlEngineDebugInspectorIntegration : public QQmlDataTest { @@ -105,7 +105,7 @@ QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject( void tst_QQmlEngineDebugInspectorIntegration::init() { - const QString argument = "-qmljsdebugger=port:" STR_PORT ",block"; + const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"; m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); @@ -117,7 +117,8 @@ void tst_QQmlEngineDebugInspectorIntegration::init() m_inspectorClient = new QQmlInspectorClient(m_connection); m_engineDebugClient = new QQmlEngineDebugClient(m_connection); - m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); + const int port = m_process->debugPort(); + m_connection->connectToHost(QLatin1String("127.0.0.1"), port); bool ok = m_connection->waitForConnected(); QVERIFY(ok); } diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index f1fbdd20a9..e430875355 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -50,8 +50,8 @@ #include "../../../shared/util.h" #include "qqmlinspectorclient.h" -#define PORT 3772 -#define STR_PORT "3772" +#define STR_PORT_FROM "3772" +#define STR_PORT_TO "3782" @@ -87,7 +87,7 @@ private slots: void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) { - const QString argument = "-qmljsdebugger=port:" STR_PORT ",block"; + const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"; m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); m_process->start(QStringList() << argument << testFile("qtquick2.qml")); @@ -97,7 +97,8 @@ void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) QQmlDebugConnection *m_connection = new QQmlDebugConnection(); m_client = new QQmlInspectorClient(m_connection); - m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); + const int port = m_process->debugPort(); + m_connection->connectToHost(QLatin1String("127.0.0.1"), port); } void tst_QQmlInspector::init() diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png b/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png Binary files differnew file mode 100644 index 0000000000..30228cbbdc --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml new file mode 100644 index 0000000000..d56786bfae --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + Image { + source: "TestImage_2x2.png" + onStatusChanged: switch (status) { + case 0: console.log("no image"); break; + case 1: console.log("image loaded"); break; + case 2: console.log("image loading"); break; + case 3: console.log("image error"); break; + } + } +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/scenegraphTest.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/scenegraphTest.qml new file mode 100644 index 0000000000..dd9d053296 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/scenegraphTest.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + Rectangle { + width: 10 + height: 10 + color: "blue" + } + + Component.onCompleted: timer.start(); + + Timer { + id: timer + interval: 100 // 100 ms, enough for at least one frame + running: false + onTriggered: console.log("tick") + } +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index 5bff33dd25..b2b325dc72 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -12,3 +12,6 @@ TESTDATA = data/* QT += core qml testlib gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +OTHER_FILES += \ + data/pixmapCacheTest.qml diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 3a925e2905..e4f886f7ce 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -46,8 +46,8 @@ #include "qqmldebugclient.h" #include "../../../shared/util.h" -#define PORT 13773 -#define STR_PORT "13773" +#define STR_PORT_FROM "13773" +#define STR_PORT_TO "13783" struct QQmlProfilerData { @@ -77,6 +77,8 @@ public: RangeLocation, RangeEnd, Complete, // end of transmission + PixmapCacheEvent, + SceneGraphFrame, MaximumMessage }; @@ -102,6 +104,32 @@ public: MaximumRangeType }; + enum PixmapEventType { + PixmapSizeKnown, + PixmapReferenceCountChanged, + PixmapCacheCountChanged, + PixmapLoadingStarted, + PixmapLoadingFinished, + PixmapLoadingError, + + MaximumPixmapEventType + }; + + enum SceneGraphFrameType { + SceneGraphRendererFrame, + SceneGraphAdaptationLayerFrame, + SceneGraphContextFrame, + SceneGraphRenderLoopFrame, + SceneGraphTexturePrepare, + SceneGraphTextureDeletion, + SceneGraphPolishAndSync, + SceneGraphWindowsRenderShow, + SceneGraphWindowsAnimations, + SceneGraphWindowsPolishFrame, + + MaximumSceneGraphFrameType + }; + QQmlProfilerClient(QQmlDebugConnection *connection) : QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection) { @@ -135,6 +163,7 @@ public: { } + private: QQmlDebugProcess *m_process; QQmlDebugConnection *m_connection; @@ -148,6 +177,8 @@ private slots: void blockingConnectWithTraceEnabled(); void blockingConnectWithTraceDisabled(); void nonBlockingConnect(); + void pixmapCacheData(); + void scenegraphData(); void profileOnExit(); }; @@ -219,6 +250,44 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message) QVERIFY(data.line >= -2); break; } + case QQmlProfilerClient::PixmapCacheEvent: { + stream >> data.detailType >> data.detailData; + if (data.detailType == QQmlProfilerClient::PixmapSizeKnown) + stream >> data.line >> data.column; + if (data.detailType == QQmlProfilerClient::PixmapReferenceCountChanged) + stream >> data.animationcount; + if (data.detailType == QQmlProfilerClient::PixmapCacheCountChanged) + stream >> data.animationcount; + break; + } + case QQmlProfilerClient::SceneGraphFrame: { + stream >> data.detailType; + qint64 subtime_1, subtime_2, subtime_3, subtime_4, subtime_5; + int glyphCount; + switch (data.detailType) { + // RendererFrame: preprocessTime, updateTime, bindingTime, renderTime + case QQmlProfilerClient::SceneGraphRendererFrame: stream >> subtime_1 >> subtime_2 >> subtime_3 >> subtime_4; break; + // AdaptationLayerFrame: glyphCount, glyphRenderTime, glyphStoreTime + case QQmlProfilerClient::SceneGraphAdaptationLayerFrame: stream >> glyphCount >> subtime_2 >> subtime_3; break; + // ContextFrame: compiling material time + case QQmlProfilerClient::SceneGraphContextFrame: stream >> subtime_1; break; + // RenderLoop: syncTime, renderTime, swapTime + case QQmlProfilerClient::SceneGraphRenderLoopFrame: stream >> subtime_1 >> subtime_2 >> subtime_3; break; + // TexturePrepare: bind, convert, swizzle, upload, mipmap + case QQmlProfilerClient::SceneGraphTexturePrepare: stream >> subtime_1 >> subtime_2 >> subtime_3 >> subtime_4 >> subtime_5; break; + // TextureDeletion: deletionTime + case QQmlProfilerClient::SceneGraphTextureDeletion: stream >> subtime_1; break; + // PolishAndSync: polishTime, waitTime, syncTime, animationsTime, + case QQmlProfilerClient::SceneGraphPolishAndSync: stream >> subtime_1 >> subtime_2 >> subtime_3 >> subtime_4; break; + // WindowsRenderLoop: GL time, make current time, SceneGraph time + case QQmlProfilerClient::SceneGraphWindowsRenderShow: stream >> subtime_1 >> subtime_2 >> subtime_3; break; + // WindowsAnimations: update time + case QQmlProfilerClient::SceneGraphWindowsAnimations: stream >> subtime_1; break; + // WindowsRenderWindow: polish time + case QQmlProfilerClient::SceneGraphWindowsPolishFrame: stream >> subtime_1; break; + } + break; + } default: QString failMsg = QString("Unknown message type:") + data.messageType; QFAIL(qPrintable(failMsg)); @@ -234,9 +303,9 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) QStringList arguments; if (block) - arguments << QString("-qmljsdebugger=port:" STR_PORT ",block"); + arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"); else - arguments << QString("-qmljsdebugger=port:" STR_PORT); + arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ); arguments << QQmlDataTest::instance()->testFile(testFile); @@ -247,7 +316,8 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) QQmlDebugConnection *m_connection = new QQmlDebugConnection(); m_client = new QQmlProfilerClient(m_connection); - m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); + const int port = m_process->debugPort(); + m_connection->connectToHost(QLatin1String("127.0.0.1"), port); } void tst_QQmlProfilerService::cleanup() @@ -319,6 +389,84 @@ void tst_QQmlProfilerService::nonBlockingConnect() QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); } +void tst_QQmlProfilerService::pixmapCacheData() +{ + connect(true, "pixmapCacheTest.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); + + QVERIFY(m_process->output().indexOf(QLatin1String("image loaded")) != -1 || + m_process->output().indexOf(QLatin1String("image error")) != -1 ); + + + 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); + + // image starting to load + QCOMPARE(m_client->traceMessages[8].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->traceMessages[8].detailType, (int)QQmlProfilerClient::PixmapLoadingStarted); + + // image loaded + QCOMPARE(m_client->traceMessages[9].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->traceMessages[9].detailType, (int)QQmlProfilerClient::PixmapLoadingFinished); + + // image size + QCOMPARE(m_client->traceMessages[10].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->traceMessages[10].detailType, (int)QQmlProfilerClient::PixmapSizeKnown); + QCOMPARE(m_client->traceMessages[10].line, 2); // width + QCOMPARE(m_client->traceMessages[10].column, 2); // height + + // cache size + QCOMPARE(m_client->traceMessages[11].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); + QCOMPARE(m_client->traceMessages[11].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); + +} + +void tst_QQmlProfilerService::scenegraphData() +{ + connect(true, "scenegraphTest.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); + QVERIFY(m_process->output().indexOf(QLatin1String("tick")) != -1); + m_client->setTraceState(false); + + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); + QVERIFY(m_client->traceMessages.count()); + + // check that at least one frame was rendered + // there should be a SGPolishAndSync + SGRendererFrame + SGRenderLoopFrame sequence + // 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) { + if (msg.messageType == QQmlProfilerClient::SceneGraphFrame) { + if (loopcheck == 0 && msg.detailType == QQmlProfilerClient::SceneGraphContextFrame) + loopcheck = 1; + else + if (loopcheck == 1 && msg.detailType == QQmlProfilerClient::SceneGraphRendererFrame) + loopcheck = 2; + else + if (loopcheck == 2 && msg.detailType == QQmlProfilerClient::SceneGraphRenderLoopFrame) + loopcheck = 3; + } + } + + QCOMPARE(loopcheck, 3); +} + void tst_QQmlProfilerService::profileOnExit() { connect(true, "exit.qml"); diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index 6585f7eca2..ff3140f520 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -182,6 +182,8 @@ void QQmlDebugProcess::processAppOutput() { m_mutex.lock(); + bool outputFromAppItself = false; + QString newOutput = m_process.readAll(); m_output.append(newOutput); m_outputBuffer.append(newOutput); @@ -208,7 +210,13 @@ void QQmlDebugProcess::processAppOutput() m_eventLoop.quit(); continue; } + } else { + // set to true if there is output not coming from the debugger + outputFromAppItself = true; } } m_mutex.unlock(); + + if (outputFromAppItself) + emit readyReadStandardOutput(); } diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h index 2b9a94366a..11b16a1fb8 100644 --- a/tests/auto/qml/debugger/shared/debugutil_p.h +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -57,7 +57,7 @@ class QQmlDebugTest { public: - static bool waitForSignal(QObject *receiver, const char *member, int timeout = 10000); + static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); }; class QQmlDebugTestClient : public QQmlDebugClient @@ -98,6 +98,9 @@ public: QString output() const; void stop(); +signals: + void readyReadStandardOutput(); + private slots: void timeout(); void processAppOutput(); diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 5e3d78d39b..7c9f5b106c 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -2554,7 +2554,7 @@ void tst_QJSEngine::qRegExpInport() } // QScriptValue::toDateTime() returns a local time, whereas JS dates -// are always stored as UTC. QtScript must respect the current time +// are always stored as UTC. Qt Script must respect the current time // zone, and correctly adjust for daylight saving time that may be in // effect at a given date (QTBUG-9770). void tst_QJSEngine::dateRoundtripJSQtJS() diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index b080a824cf..371d47ba32 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -69,3 +69,7 @@ SUBDIRS += debugger contains(QT_CONFIG, private_tests) { SUBDIRS += $$PRIVATETESTS } + +qtNomakeTools( \ + qmlplugindump \ +) diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index a69dce7ec3..e513861bdf 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -169,7 +169,7 @@ bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const } /* -This test runs all the examples in the QtQml UI source tree and ensures +This test runs all the examples in the Qt QML UI source tree and ensures that they start and exit cleanly. Examples are any .qml files under the examples/ directory that start diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 6aca47656b..d9a370b200 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -68,9 +68,7 @@ void tst_qmlplugindump::initTestCase() { qmlplugindumpPath = QLibraryInfo::location(QLibraryInfo::BinariesPath); -#if defined(Q_OS_MAC) - qmlplugindumpPath += QLatin1String("/qmlplugindump.app/Contents/MacOS/qmlplugindump"); -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) qmlplugindumpPath += QLatin1String("/qmlplugindump.exe"); #else qmlplugindumpPath += QLatin1String("/qmlplugindump"); diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 1c11fcbc73..4780ee0310 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -110,13 +110,11 @@ void tst_qqmlapplicationengine::application() */ QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); - QTest::ignoreMessage(QtWarningMsg, "Don't know how to handle 'QProcess::ExitStatus', use qRegisterMetaType to register it."); - QSignalSpy processFinished(testProcess, SIGNAL(finished(int,QProcess::ExitStatus))); QStringList args; args << QLatin1String("testData"); testProcess->start(QLatin1String("testapp/testapp"), args); - QTRY_VERIFY(processFinished.count());//Application should immediately exit - QCOMPARE(processFinished[0][0].toInt(), 0); + QVERIFY(testProcess->waitForFinished(5000)); + QCOMPARE(testProcess->exitCode(), 0); QByteArray test_stdout = testProcess->readAllStandardOutput(); QByteArray test_stderr = testProcess->readAllStandardError(); QByteArray test_stderr_target("Start: testData\nEnd\n"); diff --git a/tests/auto/qml/qqmlcomponent/data/createWindow.qml b/tests/auto/qml/qqmlcomponent/data/createWindow.qml new file mode 100644 index 0000000000..af0b7edeb2 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/createWindow.qml @@ -0,0 +1,29 @@ +import QtQuick 2.1 +import QtQuick.Window 2.1 + +Window { + id: window1; + objectName: "window1"; + color: "#00FF00"; + width: 100; height: 100; + Item { + objectName: "item1" + width: 100; height: 100; + MouseArea { + objectName: "mousearea" + anchors.fill: parent; + onPressed: window2.requestActivate(); + } + Component.onCompleted: window2.show(); + } + + Window { + id: window2; + objectName: "window2"; + color: "#FF0000"; + width: 100; height: 100; + Item { + width: 100; height: 100; + } + } +} diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 697c8103b0..9eeff66e7a 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -105,6 +105,7 @@ public: private slots: void null(); void loadEmptyUrl(); + void qmlCreateWindow(); void qmlCreateObject(); void qmlCreateObjectWithProperties(); void qmlIncubateObject(); @@ -163,6 +164,15 @@ void tst_qqmlcomponent::qmlIncubateObject() delete object; } +void tst_qqmlcomponent::qmlCreateWindow() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("createWindow.qml")); + QQuickWindow* window = qobject_cast<QQuickWindow *>(component.create()); + QVERIFY(window); +} + void tst_qqmlcomponent::qmlCreateObject() { QQmlEngine engine; diff --git a/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent.qml b/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent.qml new file mode 100644 index 0000000000..1432e7da55 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 +import QtQml 2.0 + +MyDeferredObject { + id: root + property QtObject target: null + objectProperty: MyQmlObject { + value: target.value + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent2.qml b/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent2.qml new file mode 100644 index 0000000000..de73629f7a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/MyDeferredComponent2.qml @@ -0,0 +1,3 @@ +import Qt.test 1.0 + +MyDeferredObject {} diff --git a/tests/auto/qml/qqmlecmascript/data/deferredPropertiesInComponents.qml b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesInComponents.qml new file mode 100644 index 0000000000..868b7b1908 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesInComponents.qml @@ -0,0 +1,15 @@ +import Qt.test 1.0 +import QtQml 2.0 + +QtObject { + id: root + property int value: 10 + property QtObject deferredInside: MyDeferredComponent { + target: root + } + property QtObject deferredOutside: MyDeferredComponent2 { + objectProperty: MyQmlObject { + value: root.value + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index dcf72f9dc0..cb1b0b3212 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -89,6 +89,7 @@ private slots: void objectPropertiesTriggerReeval(); void deferredProperties(); void deferredPropertiesErrors(); + void deferredPropertiesInComponents(); void extensionObjects(); void overrideExtensionProperties(); void attachedProperties(); @@ -863,6 +864,37 @@ void tst_qqmlecmascript::deferredPropertiesErrors() delete object; } +void tst_qqmlecmascript::deferredPropertiesInComponents() +{ + // Test that it works when the property is set inside and outside component + QQmlComponent component(&engine, testFileUrl("deferredPropertiesInComponents.qml")); + QObject *object = component.create(); + if (!object) + qDebug() << component.errorString(); + QVERIFY(object != 0); + QCOMPARE(object->property("value").value<int>(), 10); + + MyDeferredObject *defObjectA = + qobject_cast<MyDeferredObject *>(object->property("deferredInside").value<QObject*>()); + QVERIFY(defObjectA != 0); + QVERIFY(defObjectA->objectProperty() == 0); + + qmlExecuteDeferred(defObjectA); + QVERIFY(defObjectA->objectProperty() != 0); + QCOMPARE(defObjectA->objectProperty()->property("value").value<int>(), 10); + + MyDeferredObject *defObjectB = + qobject_cast<MyDeferredObject *>(object->property("deferredOutside").value<QObject*>()); + QVERIFY(defObjectB != 0); + QVERIFY(defObjectB->objectProperty() == 0); + + qmlExecuteDeferred(defObjectB); + QVERIFY(defObjectB->objectProperty() != 0); + QCOMPARE(defObjectB->objectProperty()->property("value").value<int>(), 10); + + delete object; +} + void tst_qqmlecmascript::extensionObjects() { QQmlComponent component(&engine, testFileUrl("extensionObjects.qml")); diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/qmldir/Intercepted.qml new file mode 100644 index 0000000000..0331a01ad4 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/Intercepted.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted.js new file mode 100644 index 0000000000..6f54ebcdc5 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted.js @@ -0,0 +1 @@ +var myStr = "base file" diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted.qml new file mode 100644 index 0000000000..ef5c28f87b --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" + property Intercepted2 compilationIsTest: Intercepted2{} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted2.qml b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted2.qml new file mode 100644 index 0000000000..0331a01ad4 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/Intercepted2.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/intercepted.js new file mode 100644 index 0000000000..6eeee6e72f --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/intercepted.js @@ -0,0 +1 @@ +var myStr = "intercepted" diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/urlInterceptor.qml new file mode 100644 index 0000000000..bd4aee056a --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/intercepted/urlInterceptor.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import "intercepted.js" as Script + +QtObject { + property url filePath: "FailsTest" + property url resolvedUrl: Qt.resolvedUrl("FailsTest"); + property url absoluteUrl: Qt.resolvedUrl("file:///FailsTest"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/qmldir/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/qmldir/urlInterceptor.qml new file mode 100644 index 0000000000..22a09e5522 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/qmldir/urlInterceptor.qml @@ -0,0 +1,12 @@ +import QtQml 2.0 +import "." +import "intercepted.js" as Script + +QtObject { + property url filePath: "doesNotExist.file" + property url resolvedUrl: Qt.resolvedUrl("doesNotExist.file"); + property url absoluteUrl: Qt.resolvedUrl("file:///doesNotExist.file"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/strings/Intercepted.qml new file mode 100644 index 0000000000..449207e0e3 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/Intercepted.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "base file" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted.js new file mode 100644 index 0000000000..6f54ebcdc5 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted.js @@ -0,0 +1 @@ +var myStr = "base file" diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/Intercepted.qml new file mode 100644 index 0000000000..0331a01ad4 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/Intercepted.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/intercepted.js new file mode 100644 index 0000000000..6eeee6e72f --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/intercepted.js @@ -0,0 +1 @@ +var myStr = "intercepted" diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/urlInterceptor.qml new file mode 100644 index 0000000000..bd4aee056a --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/intercepted/urlInterceptor.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import "intercepted.js" as Script + +QtObject { + property url filePath: "FailsTest" + property url resolvedUrl: Qt.resolvedUrl("FailsTest"); + property url absoluteUrl: Qt.resolvedUrl("file:///FailsTest"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/strings/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/strings/urlInterceptor.qml new file mode 100644 index 0000000000..be86195bd8 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/strings/urlInterceptor.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import "intercepted.js" as Script + +QtObject { + property url filePath: "doesNotExist.file" + property url resolvedUrl: Qt.resolvedUrl("doesNotExist.file"); + property url absoluteUrl: Qt.resolvedUrl("file:///doesNotExist.file"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/types/Intercepted.qml new file mode 100644 index 0000000000..449207e0e3 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/Intercepted.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "base file" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/Intercepted2.qml b/tests/auto/qml/qqmlengine/data/interception/types/Intercepted2.qml new file mode 100644 index 0000000000..0331a01ad4 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/Intercepted2.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/types/intercepted.js new file mode 100644 index 0000000000..6f54ebcdc5 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/intercepted.js @@ -0,0 +1 @@ +var myStr = "base file" diff --git a/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted.qml b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted.qml new file mode 100644 index 0000000000..ef5c28f87b --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" + property Intercepted2 compilationIsTest: Intercepted2{} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted2.qml b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted2.qml new file mode 100644 index 0000000000..0331a01ad4 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/Intercepted2.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string myStr: "intercepted" +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/intercepted/intercepted.js b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/intercepted.js new file mode 100644 index 0000000000..6eeee6e72f --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/intercepted.js @@ -0,0 +1 @@ +var myStr = "intercepted" diff --git a/tests/auto/qml/qqmlengine/data/interception/types/intercepted/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/urlInterceptor.qml new file mode 100644 index 0000000000..be86195bd8 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/intercepted/urlInterceptor.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import "intercepted.js" as Script + +QtObject { + property url filePath: "doesNotExist.file" + property url resolvedUrl: Qt.resolvedUrl("doesNotExist.file"); + property url absoluteUrl: Qt.resolvedUrl("file:///doesNotExist.file"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/data/interception/types/urlInterceptor.qml b/tests/auto/qml/qqmlengine/data/interception/types/urlInterceptor.qml new file mode 100644 index 0000000000..bd4aee056a --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/interception/types/urlInterceptor.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import "intercepted.js" as Script + +QtObject { + property url filePath: "FailsTest" + property url resolvedUrl: Qt.resolvedUrl("FailsTest"); + property url absoluteUrl: Qt.resolvedUrl("file:///FailsTest"); + property string childString: child.myStr + property string scriptString: Script.myStr + property Intercepted child: Intercepted {} +} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 9177ff58f7..d604118b58 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -54,6 +54,7 @@ #include <QQmlExpression> #include <QQmlIncubationController> #include <private/qqmlengine_p.h> +#include <private/qqmlabstracturlinterceptor_p.h> class tst_qqmlengine : public QQmlDataTest { @@ -79,6 +80,8 @@ private slots: void multipleEngines(); void qtqmlModule_data(); void qtqmlModule(); + void urlInterceptor_data(); + void urlInterceptor(); public slots: QObject *createAQObjectForOwnershipTest () @@ -674,6 +677,99 @@ void tst_qqmlengine::qtqmlModule() } } +class CustomSelector : public QQmlAbstractUrlInterceptor +{ +public: + virtual QUrl intercept(const QUrl &url, QQmlAbstractUrlInterceptor::DataType d) + { + if (url.scheme() != QStringLiteral("file")) + return url; + if (!m_interceptionPoints.contains(d)) + return url; + + QString alteredPath = url.path(); + int a = alteredPath.lastIndexOf('/'); + if (a < 0) + a = 0; + alteredPath.insert(a, QStringLiteral("/intercepted")); + + QUrl ret = url; + ret.setPath(alteredPath); + return ret; + } + QList<QQmlAbstractUrlInterceptor::DataType> m_interceptionPoints; +}; + +Q_DECLARE_METATYPE(QList<QQmlAbstractUrlInterceptor::DataType>); +void tst_qqmlengine::urlInterceptor_data() +{ + QTest::addColumn<QUrl>("testFile"); + QTest::addColumn<QList<QQmlAbstractUrlInterceptor::DataType> >("interceptionPoint"); + QTest::addColumn<QString>("expectedFilePath"); + QTest::addColumn<QString>("expectedChildString"); + QTest::addColumn<QString>("expectedScriptString"); + QTest::addColumn<QString>("expectedResolvedUrl"); + QTest::addColumn<QString>("expectedAbsoluteUrl"); + + QTest::newRow("InterceptTypes") + << testFileUrl("interception/types/urlInterceptor.qml") + << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::QmlFile << QQmlAbstractUrlInterceptor::JavaScriptFile << QQmlAbstractUrlInterceptor::UrlString) + << testFileUrl("interception/types/intercepted/doesNotExist.file").toString() + << QStringLiteral("intercepted") + << QStringLiteral("intercepted") + << testFileUrl("interception/types/intercepted/doesNotExist.file").toString() + << QStringLiteral("file:///intercepted/doesNotExist.file"); + + QTest::newRow("InterceptQmlDir") + << testFileUrl("interception/qmldir/urlInterceptor.qml") + << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::QmldirFile << QQmlAbstractUrlInterceptor::UrlString) + << testFileUrl("interception/qmldir/intercepted/doesNotExist.file").toString() + << QStringLiteral("intercepted") + << QStringLiteral("base file") + << testFileUrl("interception/qmldir/intercepted/doesNotExist.file").toString() + << QStringLiteral("file:///intercepted/doesNotExist.file"); + + QTest::newRow("InterceptStrings") + << testFileUrl("interception/strings/urlInterceptor.qml") + << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::UrlString) + << testFileUrl("interception/strings/intercepted/doesNotExist.file").toString() + << QStringLiteral("base file") + << QStringLiteral("base file") + << testFileUrl("interception/strings/intercepted/doesNotExist.file").toString() + << QStringLiteral("file:///intercepted/doesNotExist.file"); +} + +void tst_qqmlengine::urlInterceptor() +{ + + QFETCH(QUrl, testFile); + QFETCH(QList<QQmlAbstractUrlInterceptor::DataType>, interceptionPoint); + QFETCH(QString, expectedFilePath); + QFETCH(QString, expectedChildString); + QFETCH(QString, expectedScriptString); + QFETCH(QString, expectedResolvedUrl); + QFETCH(QString, expectedAbsoluteUrl); + + QQmlEngine e; + CustomSelector cs; + cs.m_interceptionPoints = interceptionPoint; + e.setUrlInterceptor(&cs); + QQmlComponent c(&e, testFile); //Note that this can get intercepted too + QObject *o = c.create(); + if (!o) + qDebug() << c.errorString(); + QVERIFY(o); + //Test a URL as a property initialization + QCOMPARE(o->property("filePath").toString(), expectedFilePath); + //Test a URL as a Type location + QCOMPARE(o->property("childString").toString(), expectedChildString); + //Test a URL as a Script location + QCOMPARE(o->property("scriptString").toString(), expectedScriptString); + //Test a URL as a resolveUrl() call + QCOMPARE(o->property("resolvedUrl").toString(), expectedResolvedUrl); + QCOMPARE(o->property("absoluteUrl").toString(), expectedAbsoluteUrl); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 1a82bacfb2..29c4463471 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -242,6 +242,7 @@ private: void tst_qqmllanguage::cleanupTestCase() { QVERIFY(QFile::remove(testFile(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")))); + qmlClearTypeRegistrations(); // Should not crash } void tst_qqmllanguage::insertedSemicolon_data() diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 327716f1b5..ca212d333b 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -66,6 +66,8 @@ private slots: void crashBug(); void QTBUG_17868(); void metaObjectAccessibility(); + void QTBUG_31226(); + void QTBUG_29836(); }; void tst_QQmlPropertyMap::insert() @@ -286,13 +288,17 @@ class MyEnhancedPropertyMap : public QQmlPropertyMap { Q_OBJECT public: - MyEnhancedPropertyMap() : QQmlPropertyMap(this, 0) {} + MyEnhancedPropertyMap() : QQmlPropertyMap(this, 0), m_testSlotCalled(false) {} + bool testSlotCalled() const { return m_testSlotCalled; } signals: void testSignal(); public slots: - void testSlot() {} + void testSlot() { m_testSlotCalled = true; } + +private: + bool m_testSlotCalled; }; void tst_QQmlPropertyMap::metaObjectAccessibility() @@ -312,6 +318,57 @@ void tst_QQmlPropertyMap::metaObjectAccessibility() QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } +void tst_QQmlPropertyMap::QTBUG_31226() +{ + /* Instantiate a property map from QML, and verify that property changes + * made from C++ are visible from QML */ + QQmlEngine engine; + QQmlContext context(&engine); + qmlRegisterType<QQmlPropertyMap>("QTBUG_31226", 1, 0, "PropertyMap"); + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\nimport QTBUG_31226 1.0\n" + "Item {\n" + " property string myProp\n" + " PropertyMap { id: qmlPropertyMap; objectName: \"qmlPropertyMap\" }\n" + " Timer { interval: 5; running: true; onTriggered: { myProp = qmlPropertyMap.greeting; } }\n" + "}", + QUrl()); + QObject *obj = c.create(&context); + QVERIFY(obj); + + QQmlPropertyMap *qmlPropertyMap = obj->findChild<QQmlPropertyMap*>(QString("qmlPropertyMap")); + QVERIFY(qmlPropertyMap); + + qmlPropertyMap->insert("greeting", QString("Hello world!")); + QTRY_COMPARE(obj->property("myProp").toString(), QString("Hello world!")); + + delete obj; + +} + +void tst_QQmlPropertyMap::QTBUG_29836() +{ + MyEnhancedPropertyMap map; + QCOMPARE(map.testSlotCalled(), false); + + QQmlEngine engine; + QQmlContext context(&engine); + context.setContextProperty("enhancedMap", &map); + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\n" + "Item {\n" + " Timer { interval: 5; running: true; onTriggered: enhancedMap.testSlot() }\n" + "}", + QUrl()); + QObject *obj = c.create(&context); + QVERIFY(obj); + + QTRY_COMPARE(map.testSlotCalled(), true); + + delete obj; + +} + QTEST_MAIN(tst_QQmlPropertyMap) #include "tst_qqmlpropertymap.moc" diff --git a/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml b/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml new file mode 100644 index 0000000000..b65ace2f78 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + showDotAndDotDot: false +} diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index a8bb887158..b845faca7d 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -73,9 +73,12 @@ private slots: void basicProperties(); void resetFiltering(); void refresh(); -#if defined (Q_OS_WIN) +#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE) + // WinCE does not have drive concept, so lets execute this test only on desktop Windows. void changeDrive(); #endif + void showDotAndDotDot(); + void showDotAndDotDot_data(); private: void checkNoErrors(const QQmlComponent& component); @@ -112,7 +115,7 @@ void tst_qquickfolderlistmodel::basicProperties() QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(),5); // wait for refresh QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl()); QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath())); QCOMPARE(flm->property("sortField").toInt(), int(Name)); @@ -168,7 +171,7 @@ void tst_qquickfolderlistmodel::refresh() QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(),5); // wait for refresh int count = flm->rowCount(); @@ -181,7 +184,7 @@ void tst_qquickfolderlistmodel::refresh() QTRY_COMPARE(removeEnd, count-1); // wait for refresh } -#if defined (Q_OS_WIN) +#if defined (Q_OS_WIN) && !defined (Q_OS_WINCE) void tst_qquickfolderlistmodel::changeDrive() { QSKIP("QTBUG-26728"); @@ -227,6 +230,49 @@ void tst_qquickfolderlistmodel::changeDrive() } #endif +void tst_qquickfolderlistmodel::showDotAndDotDot() +{ + QFETCH(QUrl, folder); + QFETCH(QUrl, rootFolder); + QFETCH(bool, showDotAndDotDot); + QFETCH(bool, showDot); + QFETCH(bool, showDotDot); + + QQmlComponent component(&engine, testFileUrl("showDotAndDotDot.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", folder); + flm->setProperty("rootFolder", rootFolder); + flm->setProperty("showDotAndDotDot", showDotAndDotDot); + + int count = 5; + if (showDot) count++; + if (showDotDot) count++; + QTRY_COMPARE(flm->property("count").toInt(), count); // wait for refresh + + if (showDot) + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String(".")); + if (showDotDot) + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("..")); +} + +void tst_qquickfolderlistmodel::showDotAndDotDot_data() +{ + QTest::addColumn<QUrl>("folder"); + QTest::addColumn<QUrl>("rootFolder"); + QTest::addColumn<bool>("showDotAndDotDot"); + QTest::addColumn<bool>("showDot"); + QTest::addColumn<bool>("showDotDot"); + + QTest::newRow("false") << dataDirectoryUrl() << QUrl() << false << false << false; + QTest::newRow("true") << dataDirectoryUrl() << QUrl() << true << true << true; + QTest::newRow("true but root") << dataDirectoryUrl() << dataDirectoryUrl() << true << true << false; + +} + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index 9d74e32383..1530ce83e2 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -138,7 +138,7 @@ void tst_QQuickWorkerScript::messaging_data() QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c")); QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime()); #ifndef QT_NO_REGEXP - // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax + // Qt Script's QScriptValue -> QRegExp uses RegExp2 pattern syntax QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2)); #endif } |