diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-12-20 09:37:14 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-12-20 09:37:14 +0100 |
commit | c07610b208268e6b6b952d634a6540ff66a0a8a8 (patch) | |
tree | df8f0a71db8e1d3a6144e35468125c2b263dc372 /tests | |
parent | 6f94828e8f1865259ff1b1cd7fda5064ffd9576c (diff) | |
parent | c4eefa4a8d6d3e95062deb78229940460a7ef605 (diff) |
Merge branch remote-tracking branch 'origin/dev' into wip/pointerhandler
Change-Id: I9ed2e696108f11c9153012fcf092541fd0e0d7c8
Diffstat (limited to 'tests')
72 files changed, 1539 insertions, 278 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 556f5ddc7a..f25742fb14 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs SUBDIRS=\ qml \ quick \ + quicktest \ qmltest \ qmldevtools \ cmake \ diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml index a36d0cae91..0fa9f1ffd8 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml @@ -36,6 +36,7 @@ Item { var b = {a: "hello", d: 1 } var c var d = 12 + console.log("Component.onCompleted"); } function foo() { var a = [1, 2] diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 8d1a165243..3aa3a5c87e 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -142,24 +142,36 @@ void tst_QQmlDebuggingEnabler::cleanup() void tst_QQmlDebuggingEnabler::data() { + QTest::addColumn<QString>("connector"); QTest::addColumn<bool>("blockMode"); QTest::addColumn<QStringList>("services"); - QTest::newRow("noblock,all") << false << QStringList(); - QTest::newRow("block,all") << true << QStringList(); - QTest::newRow("noblock,debugger") << false << QQmlDebuggingEnabler::debuggerServices(); - QTest::newRow("block,debugger") << true << QQmlDebuggingEnabler::debuggerServices(); - QTest::newRow("noblock,inspector") << false << QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("block,inspector") << true << QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("noblock,profiler") << false << QQmlDebuggingEnabler::profilerServices(); - QTest::newRow("block,profiler") << true << QQmlDebuggingEnabler::profilerServices(); - QTest::newRow("noblock,debugger+inspector") - << false << QQmlDebuggingEnabler::debuggerServices() + - QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("block,debugger+inspector") - << true << QQmlDebuggingEnabler::debuggerServices() + - QQmlDebuggingEnabler::inspectorServices(); - + QStringList connectors({ + QLatin1String("QQmlDebugServer"), + QLatin1String("QQmlNativeDebugConnector") + }); + + QList<bool> blockModes({ true, false }); + + QList<QStringList> serviceLists({ + QStringList(), + QQmlDebuggingEnabler::nativeDebuggerServices(), + QQmlDebuggingEnabler::debuggerServices(), + QQmlDebuggingEnabler::inspectorServices(), + QQmlDebuggingEnabler::profilerServices(), + QQmlDebuggingEnabler::debuggerServices() + QQmlDebuggingEnabler::inspectorServices() + }); + + foreach (const QString &connector, connectors) { + foreach (bool blockMode, blockModes) { + foreach (const QStringList &serviceList, serviceLists) { + QString name = connector + QLatin1Char(',') + + QLatin1String(blockMode ? "block" : "noblock") + QLatin1Char(',') + + serviceList.join(QLatin1Char('-')); + QTest::newRow(name.toUtf8().constData()) << connector << blockMode << serviceList; + } + } + } } void tst_QQmlDebuggingEnabler::qmlscene_data() @@ -169,27 +181,36 @@ void tst_QQmlDebuggingEnabler::qmlscene_data() void tst_QQmlDebuggingEnabler::qmlscene() { + QFETCH(QString, connector); QFETCH(bool, blockMode); QFETCH(QStringList, services); - connection = new QQmlDebugConnection(); - QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); process->setMaximumBindErrors(1); process->start(QStringList() - << QString::fromLatin1("-qmljsdebugger=port:5555,5565%1%2%3") + << QString::fromLatin1("-qmljsdebugger=connector:%1%2%3%4") + .arg(connector + (connector == QLatin1String("QQmlDebugServer") ? + QLatin1String(",port:5555,5565") : QString())) .arg(blockMode ? QLatin1String(",block") : QString()) .arg(services.isEmpty() ? QString() : QString::fromLatin1(",services:")) .arg(services.isEmpty() ? QString() : services.join(",")) << testFile(QLatin1String("test.qml"))); - QVERIFY(process->waitForSessionStart()); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) - QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? - QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + if (connector == QLatin1String("QQmlDebugServer")) { + QVERIFY(process->waitForSessionStart()); + connection = new QQmlDebugConnection(); + QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + foreach (QQmlDebugClient *client, clients) + QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? + QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + } + + QCOMPARE(process->state(), QLatin1String("running")); + if (!blockMode) + QTRY_VERIFY(process->output().contains(QLatin1String("qml: Component.onCompleted"))); } void tst_QQmlDebuggingEnabler::custom_data() @@ -199,13 +220,12 @@ void tst_QQmlDebuggingEnabler::custom_data() void tst_QQmlDebuggingEnabler::custom() { + QFETCH(QString, connector); QFETCH(bool, blockMode); QFETCH(QStringList, services); const int portFrom = 5555; const int portTo = 5565; - connection = new QQmlDebugConnection(); - QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebuggingenablerserver"), this); process->setMaximumBindErrors(portTo - portFrom); @@ -214,18 +234,28 @@ void tst_QQmlDebuggingEnabler::custom() if (blockMode) args << QLatin1String("-block"); - args << QString::number(portFrom) << QString::number(portTo); + args << QLatin1String("-connector") << connector + << QString::number(portFrom) << QString::number(portTo); + if (!services.isEmpty()) args << QLatin1String("-services") << services; process->start(args); - QVERIFY(process->waitForSessionStart()); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) - QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? - QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + if (connector == QLatin1String("QQmlDebugServer")) { + QVERIFY(process->waitForSessionStart()); + connection = new QQmlDebugConnection(); + QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + foreach (QQmlDebugClient *client, clients) + QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? + QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + } + + QCOMPARE(process->state(), QLatin1String("running")); + if (!blockMode) + QTRY_VERIFY(process->output().contains(QLatin1String("QQmlEngine created"))); } QTEST_MAIN(tst_QQmlDebuggingEnabler) diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp index cfbb31f9e1..a064bbbacc 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp @@ -28,6 +28,7 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qlibraryinfo.h> +#include <QtCore/qdebug.h> #include <QtQml/qqmldebug.h> #include <QtQml/qqmlengine.h> @@ -40,12 +41,18 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); QStringList arguments = app.arguments(); arguments.removeFirst(); + QString connector = QLatin1String("QQmlDebugServer"); if (arguments.size() && arguments.first() == QLatin1String("-block")) { block = QQmlDebuggingEnabler::WaitForClient; arguments.removeFirst(); } + if (arguments.size() >= 2 && arguments.first() == QLatin1String("-connector")) { + arguments.removeFirst(); + connector = arguments.takeFirst(); + } + if (arguments.size() >= 2) { portFrom = arguments.takeFirst().toInt(); portTo = arguments.takeFirst().toInt(); @@ -54,12 +61,20 @@ int main(int argc, char *argv[]) if (arguments.size() && arguments.takeFirst() == QLatin1String("-services")) QQmlDebuggingEnabler::setServices(arguments); - if (!portFrom || !portTo) - qFatal("Port range has to be specified."); + if (connector == QLatin1String("QQmlDebugServer")) { + if (!portFrom || !portTo) + qFatal("Port range has to be specified."); + + while (portFrom <= portTo) + QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); + } else if (connector == QLatin1String("QQmlNativeDebugConnector")) { + QVariantHash configuration; + configuration[QLatin1String("block")] = (block == QQmlDebuggingEnabler::WaitForClient); + QQmlDebuggingEnabler::startDebugConnector(connector, configuration); + } - while (portFrom <= portTo) - QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); QQmlEngine engine; + qDebug() << "QQmlEngine created\n"; Q_UNUSED(engine); return app.exec(); } diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro index 79e772c1ee..cbaf3b5309 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro @@ -9,6 +9,7 @@ SOURCES += tst_qqmldebugjs.cpp INCLUDEPATH += ../../shared include(../../../../shared/util.pri) include(../../shared/debugutil.pri) +include(../../shared/qqmlenginedebugclient.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp index d1150be831..31b8d63ec2 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "../../shared/qqmlenginedebugclient.h" #include "../../../../shared/util.h" #include <private/qqmldebugclient_p.h> @@ -52,6 +53,7 @@ const char *STEPACTION = "stepaction"; const char *STEPCOUNT = "stepcount"; const char *EXPRESSION = "expression"; const char *FRAME = "frame"; +const char *CONTEXT = "context"; const char *GLOBAL = "global"; const char *DISABLEBREAK = "disable_break"; const char *HANDLES = "handles"; @@ -215,6 +217,8 @@ private slots: void evaluateInLocalScope_data() { targetData(); } void evaluateInLocalScope(); + void evaluateInContext(); + void getScripts_data() { targetData(); } void getScripts(); @@ -257,7 +261,7 @@ public: void interrupt(); void continueDebugging(StepAction stepAction); - void evaluate(QString expr, int frame = -1); + void evaluate(QString expr, int frame = -1, int context = -1); void lookup(QList<int> handles, bool includeSource = false); void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); void frame(int number = -1); @@ -280,6 +284,7 @@ signals: void connected(); void interruptRequested(); void result(); + void failure(); void stopped(); private: @@ -340,13 +345,14 @@ void QJSDebugClient::continueDebugging(StepAction action) sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::evaluate(QString expr, int frame) +void QJSDebugClient::evaluate(QString expr, int frame, int context) { // { "seq" : <number>, // "type" : "request", // "command" : "evaluate", // "arguments" : { "expression" : <expression to evaluate>, - // "frame" : <number> + // "frame" : <number>, + // "context" : <object ID> // } // } VARIANTMAPINIT; @@ -358,6 +364,9 @@ void QJSDebugClient::evaluate(QString expr, int frame) if (frame != -1) args.setProperty(QLatin1String(FRAME),QJSValue(frame)); + if (context != -1) + args.setProperty(QLatin1String(CONTEXT), QJSValue(context)); + if (!args.isUndefined()) { jsonVal.setProperty(QLatin1String(ARGUMENTS),args); } @@ -684,6 +693,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data) if (type == "response") { if (!value.value("success").toBool()) { + emit failure(); qDebug() << "Received success == false response from application"; return; } @@ -1394,6 +1404,58 @@ void tst_QQmlDebugJS::evaluateInLocalScope() QCOMPARE(body.value("value").toInt(),10); } +void tst_QQmlDebugJS::evaluateInContext() +{ + connection = new QQmlDebugConnection(); + process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + + "/qmlscene", this); + client = new QJSDebugClient(connection); + QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(connection)); + process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE)); + + QVERIFY(process->waitForSessionStart()); + + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + + QTRY_COMPARE(client->state(), QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(engineClient->state(), QQmlEngineDebugClient::Enabled); + client->connect(); + + // "a" not accessible without extra context + client->evaluate(QLatin1String("a + 10"), -1, -1); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(failure()))); + + bool success = false; + engineClient->queryAvailableEngines(&success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + QVERIFY(engineClient->engines().count()); + engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + auto contexts = engineClient->rootContext().contexts; + QCOMPARE(contexts.count(), 1); + auto objects = contexts[0].objects; + QCOMPARE(objects.count(), 1); + engineClient->queryObjectRecursive(objects[0], &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + auto object = engineClient->object(); + + // "a" accessible in context of surrounding object + client->evaluate(QLatin1String("a + 10"), -1, object.debugId); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + QString jsonString = client->response; + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QTRY_COMPARE(body.value("value").toInt(), 20); +} + void tst_QQmlDebugJS::getScripts() { //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant()); diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp index a503da4e4b..8d21a8a45a 100644 --- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp @@ -51,12 +51,6 @@ private: QQmlDebugConnection *m_conn; QQmlDebugTestService *m_service; - bool connect(); - -signals: - void waiting(); - void parallel(); - private slots: void initTestCase(); @@ -75,12 +69,13 @@ void tst_QQmlDebugLocal::initTestCase() const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName); QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData()); + QQmlDebuggingEnabler::connectToLocalDebugger(fileName); + + QTest::qWait(1000); m_conn = new QQmlDebugConnection(this); m_conn->startLocalServer(fileName); - QQmlDebuggingEnabler::connectToLocalDebugger(fileName); - new QQmlEngine(this); QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn); diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index c4b17aa60a..692e70d7da 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -618,7 +618,7 @@ void tst_QQmlProfilerService::scenegraphData() // if the clocks are acting up. qint64 contextFrameTime = -1; qint64 renderFrameTime = -1; -#ifndef QT_NO_OPENGL //Software renderer doesn't have context frames +#if QT_CONFIG(opengl) //Software renderer doesn't have context frames foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) { if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) { diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index a23b7e37eb..6793596174 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -41,6 +41,7 @@ #include <private/qv4isel_moth_p.h> #include <private/qv4string_p.h> #include <private/qqmlbuiltinfunctions_p.h> +#include <private/qqmldebugservice_p.h> using namespace QV4; using namespace QV4::Debugging; @@ -203,8 +204,8 @@ public slots: while (!m_expressionRequests.isEmpty()) { Q_ASSERT(debugger->state() == QV4Debugger::Paused); ExpressionRequest request = m_expressionRequests.takeFirst(); - ExpressionEvalJob job(debugger->engine(), request.frameNr, request.expression, - &collector); + ExpressionEvalJob job(debugger->engine(), request.frameNr, request.context, + request.expression, &collector); debugger->runInEngine(&job); m_expressionResults << job.returnValue(); m_expressionRefs << job.refs(); @@ -276,6 +277,7 @@ public: struct ExpressionRequest { QString expression; int frameNr; + int context; }; QVector<ExpressionRequest> m_expressionRequests; QList<QJsonObject> m_expressionResults; @@ -726,24 +728,34 @@ void tst_qv4debugger::evaluateExpression() TestAgent::ExpressionRequest request; request.expression = "x"; request.frameNr = 0; + request.context = -1; // no extra context m_debuggerAgent->m_expressionRequests << request; request.expression = "x"; request.frameNr = 1; m_debuggerAgent->m_expressionRequests << request; + request.context = 5355; // invalid context object + m_debuggerAgent->m_expressionRequests << request; + + QObject object; // some object without QML context + request.context = QQmlDebugService::idForObject(&object); + m_debuggerAgent->m_expressionRequests << request; + debugger()->addBreakPoint("evaluateExpression", 3); evaluateJavaScript(script, "evaluateExpression"); - QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 2); + QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 4); QCOMPARE(m_debuggerAgent->m_expressionRefs[0].size(), 1); QJsonObject result0 = m_debuggerAgent->m_expressionRefs[0].first().toObject(); QCOMPARE(result0.value("type").toString(), QStringLiteral("number")); QCOMPARE(result0.value("value").toInt(), 10); - QCOMPARE(m_debuggerAgent->m_expressionRefs[1].size(), 1); - QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); - QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); - QCOMPARE(result1.value("value").toInt(), 20); + for (int i = 1; i < 4; ++i) { + QCOMPARE(m_debuggerAgent->m_expressionRefs[i].size(), 1); + QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); + QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); + QCOMPARE(result1.value("value").toInt(), 20); + } } QTEST_MAIN(tst_qv4debugger) diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index f6fbb8c37e..82bc3d0c59 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -196,6 +196,8 @@ private slots: void basicBlockMergeAfterLoopPeeling(); + void malformedExpression(); + signals: void testSignal(); }; @@ -4079,6 +4081,12 @@ void tst_QJSEngine::basicBlockMergeAfterLoopPeeling() } +void tst_QJSEngine::malformedExpression() +{ + QJSEngine engine; + engine.evaluate("5%55555&&5555555\n7-0"); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index d28bbc1ffa..12c33909cf 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1372,6 +1372,33 @@ void tst_QJSValue::hasProperty_changePrototype() QVERIFY(obj.hasOwnProperty("foo")); } +void tst_QJSValue::hasProperty_QTBUG56830_data() +{ + QTest::addColumn<QString>("key"); + QTest::addColumn<QString>("lookup"); + + QTest::newRow("bugreport-1") << QStringLiteral("240000000000") << QStringLiteral("3776798720"); + QTest::newRow("bugreport-2") << QStringLiteral("240000000001") << QStringLiteral("3776798721"); + QTest::newRow("biggest-ok-before-bug") << QStringLiteral("238609294221") << QStringLiteral("2386092941"); + QTest::newRow("smallest-bugged") << QStringLiteral("238609294222") << QStringLiteral("2386092942"); + QTest::newRow("biggest-bugged") << QStringLiteral("249108103166") << QStringLiteral("12884901886"); + QTest::newRow("smallest-ok-after-bug") << QStringLiteral("249108103167") << QStringLiteral("12884901887"); +} + +void tst_QJSValue::hasProperty_QTBUG56830() +{ + QFETCH(QString, key); + QFETCH(QString, lookup); + + QJSEngine eng; + const QJSValue value(42); + + QJSValue obj = eng.newObject(); + obj.setProperty(key, value); + QVERIFY(obj.hasProperty(key)); + QVERIFY(!obj.hasProperty(lookup)); +} + void tst_QJSValue::deleteProperty_basic() { QJSEngine eng; diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h index 6ed880c865..b8b9f4403c 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h @@ -92,6 +92,8 @@ private slots: void hasProperty_basic(); void hasProperty_globalObject(); void hasProperty_changePrototype(); + void hasProperty_QTBUG56830_data(); + void hasProperty_QTBUG56830(); void deleteProperty_basic(); void deleteProperty_globalObject(); diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index e2c0055ea1..8af446173d 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources() { CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml")); - qDebug() << component.errorString(); QScopedPointer<QObject> obj(component.create()); QVERIFY(!obj.isNull()); QCOMPARE(obj->property("value").toInt(), 20); @@ -558,12 +557,36 @@ void tst_qmldiskcache::cacheResources() const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); QCOMPARE(entries.count(), 1); + QDateTime cacheFileTimeStamp; + { QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()); QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit)); - QCOMPARE(qint64(unit.sourceTimeStamp), QFileInfo(QCoreApplication::applicationFilePath()).lastModified().toMSecsSinceEpoch()); + + cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified(); + + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); + if (!referenceTimeStamp.isValid()) + referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); + QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); + } + + waitForFileSystem(); + + { + CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("value").toInt(), 20); + } + + { + const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); + QCOMPARE(entries.count(), 1); + + QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch()); } } diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 7e4a643ffa..3ed0aa7446 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -86,7 +86,6 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; - invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml"; diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index a401e04020..98b92e5fab 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -96,7 +96,7 @@ void tst_qqmlapplicationengine::application() Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; @@ -114,9 +114,9 @@ void tst_qqmlapplicationengine::application() QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); delete testProcess; QDir::setCurrent(srcDir); -#else // !QT_NO_PROCESS +#else // process QSKIP("No process support"); -#endif // QT_NO_PROCESS +#endif // process } void tst_qqmlapplicationengine::applicationProperties() diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 723f575330..f2b0b9973e 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -37,7 +37,9 @@ #include <QtQuick/private/qquickmousearea_p.h> #include <private/qv8engine_p.h> #include <private/qqmlcontext_p.h> +#include <private/qv4qmlcontext_p.h> #include <private/qv4scopedvalue_p.h> +#include <private/qv4qmlcontext_p.h> #include <qcolor.h> #include "../../shared/util.h" #include "testhttpserver.h" diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml new file mode 100644 index 0000000000..d5aa0f102a --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + width: 50 + + property bool tested: false + + Connections { onWidthChanged: tested = true } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index 615de0885a..b3ac1ce958 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -52,6 +52,7 @@ private slots: void rewriteErrors(); void singletonTypeTarget(); void enableDisable_QTBUG_36350(); + void clearImplicitTarget(); private: QQmlEngine engine; @@ -352,6 +353,32 @@ void tst_qqmlconnections::enableDisable_QTBUG_36350() delete item; } +//QTBUG-56499 +void tst_qqmlconnections::clearImplicitTarget() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + + QVERIFY(item != 0); + + // normal case: fire Connections + item->setWidth(100.); + QCOMPARE(item->property("tested").toBool(), true); + + item->setProperty("tested", false); + // clear the implicit target + QQmlConnections *connections = item->findChild<QQmlConnections*>(); + QVERIFY(connections); + connections->setTarget(0); + + // target cleared: no longer fire Connections + item->setWidth(150.); + QCOMPARE(item->property("tested").toBool(), false); + + delete item; +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index be04ec2bf3..88a8886ecb 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -36,7 +36,7 @@ #include <QtCore/qnumeric.h> #include <private/qqmlengine_p.h> #include <private/qqmlvmemetaobject_p.h> -#include <private/qqmlcontextwrapper_p.h> +#include <private/qv4qmlcontext_p.h> #include "testtypes.h" #include "testhttpserver.h" #include "../../shared/util.h" @@ -3986,7 +3986,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { { QV4::Scope scope(QV8Engine::getV4((engine))); - QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(scope.engine, scriptContext, 0)); + QV4::ScopedContext temporaryScope(scope, QV4::QmlContext::create(scope.engine->rootContext(), scriptContext, 0)); Q_UNUSED(temporaryScope) } diff --git a/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml new file mode 100644 index 0000000000..bb28e22110 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + default property list<QtObject> myChildren; +} diff --git a/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml new file mode 100644 index 0000000000..d68ffd2979 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +QtObjectWithChildren { + QtObject { + } +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml index 319e1f5bc5..f028e5dcac 100644 --- a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml +++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtQuick 2.0 as Qt47 -Qt.QtObject { +Qt47.QtObject { property Qt47.QtObject objectProperty property list<Qt47.QtObject> objectPropertyList diff --git a/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml new file mode 100644 index 0000000000..5ad62edab3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 as MyQuick + +MyQuick.Item { + property MyQuick.Item myProp; + property list<MyQuick.Item> myList; + default property list<MyQuick.Item> myDefaultList; + signal mySignal(MyQuick.Item someItem) +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 3af7645ff7..bc8c192a61 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -128,12 +128,11 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); - QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); - QQmlProperty property(m_target, name, qmlContext(this)); + QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); + QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, m_target)); QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, - function, m_target, context); + compilationUnit->runtimeFunctions[bindingId], m_target, context, qmlContext); qmlBinding->setTarget(property); QQmlPropertyPrivate::setBinding(property, qmlBinding); } diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index ad06946b0b..f586f7d429 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -254,6 +254,9 @@ private slots: void arrayBuffer_data(); void arrayBuffer(); + void defaultListProperty(); + void namespacedPropertyTypes(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -1395,7 +1398,6 @@ void tst_qqmllanguage::dynamicObjectProperties() } { QQmlComponent component(&engine, testFileUrl("dynamicObjectProperties.2.qml")); - QEXPECT_FAIL("", "QTBUG-10822", Abort); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -4233,6 +4235,21 @@ void tst_qqmllanguage::arrayBuffer() QCOMPARE(object->property("ok").toBool(), true); } +void tst_qqmllanguage::defaultListProperty() +{ + QQmlComponent component(&engine, testFileUrl("defaultListProperty.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); +} + +void tst_qqmllanguage::namespacedPropertyTypes() +{ + QQmlComponent component(&engine, testFileUrl("namespacedPropertyTypes.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml new file mode 100644 index 0000000000..6bf750dcda --- /dev/null +++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property ListModel model: ListModel { + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + } + + property bool isModified: { + for (var i = 0; i < model.count; ++i) { + if (model.get(i).modified) + return true; + } + return false; + } + + property bool success: false + Component.onCompleted: { + // trigger read and setup of property captures + success = isModified + model.setProperty(0, "modified", true) + success = isModified + } +} diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index cd497cbd79..555ca5713e 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -122,6 +122,7 @@ private slots: void datetime_data(); void about_to_be_signals(); void modify_through_delegate(); + void bindingsOnGetResult(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1469,6 +1470,18 @@ void tst_qqmllistmodel::modify_through_delegate() QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); } +void tst_qqmllistmodel::bindingsOnGetResult() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml")); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); + + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + + QVERIFY(obj->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works22.qml b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml new file mode 100644 index 0000000000..571a7e754d --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml @@ -0,0 +1,3 @@ +import org.qtproject.AutoTestQmlPluginType 2.2 + +MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro new file mode 100644 index 0000000000..eec5f23a7b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2.2 + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp new file mode 100644 index 0000000000..ecec870374 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QStringList> +#include <QtQml/qqmlextensionplugin.h> +#include <QtQml/qqml.h> +#include <QDebug> + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import2.2 worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + MyPlugin() + { + qWarning("plugin2.2 created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType"); + qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType"); + qmlRegisterModule(uri, 2, 2); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir new file mode 100644 index 0000000000..0a8b5d46eb --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro index 889968f6cc..0f548aa6f8 100644 --- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -20,7 +20,8 @@ SUBDIRS =\ protectedModule\ plugin/childplugin\ plugin.2/childplugin\ - plugin.2.1/childplugin + plugin.2.1/childplugin\ + plugin.2.2 tst_qqmlmoduleplugin_pro.depends += plugin SUBDIRS += tst_qqmlmoduleplugin.pro diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 265492b435..8600e1e8ab 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -52,8 +52,7 @@ public: private slots: virtual void initTestCase(); void importsPlugin(); - void importsPlugin2(); - void importsPlugin21(); + void importsPlugin_data(); void importsMixedQmlCppPlugin(); void incorrectPluginCase(); void importPluginWithQmlFile(); @@ -70,6 +69,7 @@ private slots: void importStrictModule(); void importStrictModule_data(); void importProtectedModule(); + void importVersionedModule(); void importsChildPlugin(); void importsChildPlugin2(); void importsChildPlugin21(); @@ -130,29 +130,15 @@ void tst_qqmlmoduleplugin::initTestCase() void tst_qqmlmoduleplugin::importsPlugin() { - QQmlEngine engine; - engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin created"); - QTest::ignoreMessage(QtWarningMsg, "import worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); - foreach (QQmlError err, component.errors()) - qWarning() << err; - VERIFY_ERRORS(0); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("value").toInt(),123); - delete object; -} + QFETCH(QString, suffix); + QFETCH(QString, qmlFile); -void tst_qqmlmoduleplugin::importsPlugin2() -{ QQmlEngine engine; engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); - QTest::ignoreMessage(QtWarningMsg, "import2 worked"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("plugin%1 created").arg(suffix))); + QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("import%1 worked").arg(suffix))); QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); + QQmlComponent component(&engine, testFileUrl(qmlFile)); foreach (QQmlError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -162,21 +148,15 @@ void tst_qqmlmoduleplugin::importsPlugin2() delete object; } -void tst_qqmlmoduleplugin::importsPlugin21() +void tst_qqmlmoduleplugin::importsPlugin_data() { - QQmlEngine engine; - engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); - QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); - foreach (QQmlError err, component.errors()) - qWarning() << err; - VERIFY_ERRORS(0); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("value").toInt(),123); - delete object; + QTest::addColumn<QString>("suffix"); + QTest::addColumn<QString>("qmlFile"); + + QTest::newRow("1.0") << "" << "works.qml"; + QTest::newRow("2.0") << "2" << "works2.qml"; + QTest::newRow("2.1") << "2.1" << "works21.qml"; + QTest::newRow("2.2") << "2.2" << "works22.qml"; } void tst_qqmlmoduleplugin::incorrectPluginCase() @@ -578,6 +558,32 @@ void tst_qqmlmoduleplugin::importProtectedModule() QVERIFY(object != 0); } +void tst_qqmlmoduleplugin::importVersionedModule() +{ + qmlRegisterType<QObject>("org.qtproject.VersionedModule", 1, 0, "TestType"); + qmlRegisterModule("org.qtproject.VersionedModule", 1, 1); + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + QUrl url(testFileUrl("empty.qml")); + + QQmlComponent component(&engine); + component.setData("import org.qtproject.VersionedModule 1.0\n TestType {}\n", url); + QScopedPointer<QObject> object10(component.create()); + QVERIFY(!object10.isNull()); + + component.setData("import org.qtproject.VersionedModule 1.1\n TestType {}\n", url); + QScopedPointer<QObject> object11(component.create()); + QVERIFY(!object11.isNull()); + + component.setData("import org.qtproject.VersionedModule 1.2\n TestType {}\n", url); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QScopedPointer<QObject> object12(component.create()); + QVERIFY(object12.isNull()); + QCOMPARE(component.errorString(), QString("%1:1 module \"org.qtproject.VersionedModule\" version 1.2 is not installed\n").arg(url.toString())); +} + void tst_qqmlmoduleplugin::importsChildPlugin() { QQmlEngine engine; diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index fe73610bcc..385ffc523a 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -157,7 +157,7 @@ void tst_qqmlproperty::qmlmetaproperty() QObject *obj = new QObject; - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -399,7 +399,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&object); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -447,7 +447,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&dobject); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -504,7 +504,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&object, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -552,7 +552,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -603,7 +603,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onClicked")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -653,7 +653,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -709,7 +709,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&object, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -757,7 +757,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&dobject, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -814,7 +814,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -862,7 +862,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -913,7 +913,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -963,7 +963,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 803bad197a..163ce11cb8 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -91,6 +91,7 @@ private slots: void gadgetInheritance(); void toStringConversion(); void enumerableProperties(); + void enumProperties(); private: QQmlEngine engine; @@ -322,7 +323,7 @@ void tst_qqmlvaluetypes::locale() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVERIFY(QQml_guiProvider()->inputMethod()); QInputMethod *inputMethod = qobject_cast<QInputMethod*>(QQml_guiProvider()->inputMethod()); QLocale locale = inputMethod->locale(); @@ -349,7 +350,7 @@ void tst_qqmlvaluetypes::locale() } QCOMPARE(weekDays, locale.weekdays()); QCOMPARE(object->property("zeroDigit").toString().at(0), locale.zeroDigit()); -#endif // QT_NO_IM +#endif // im } } @@ -1703,6 +1704,39 @@ void tst_qqmlvaluetypes::enumerableProperties() QVERIFY(names.contains(QStringLiteral("derivedProperty"))); } +struct GadgetWithEnum +{ + Q_GADGET +public: + + enum MyEnum { FirstValue, SecondValue }; + + Q_ENUM(MyEnum) + Q_PROPERTY(MyEnum enumProperty READ enumProperty) + + MyEnum enumProperty() const { return SecondValue; } +}; + +void tst_qqmlvaluetypes::enumProperties() +{ + QJSEngine engine; + + // When creating the property cache for the gadget when MyEnum is _not_ a registered + // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently + // property-read meta-calls will return an int (as expected in this test). However if we + // explicitly register the gadget, then QMetaProperty::type() will return the user-type + // and QQmlValueTypeWrapper should still handle that and return an integer/number for the + // enum property when it is read. + qRegisterMetaType<GadgetWithEnum::MyEnum>(); + + GadgetWithEnum g; + QJSValue value = engine.toScriptValue(g); + + QJSValue enumValue = value.property("enumProperty"); + QVERIFY(enumValue.isNumber()); + QCOMPARE(enumValue.toInt(), int(g.enumProperty())); +} + QTEST_MAIN(tst_qqmlvaluetypes) diff --git a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml index 56bec4e452..a70da63e13 100644 --- a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml +++ b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml @@ -37,7 +37,7 @@ Item { TestCase { id: testcase name: "animators-stopped" - when: root.done + when: false function test_endresult() { verify(true); } diff --git a/tests/auto/qmltest/events/tst_touch.qml b/tests/auto/qmltest/events/tst_touch.qml new file mode 100644 index 0000000000..5b209a6d0b --- /dev/null +++ b/tests/auto/qmltest/events/tst_touch.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import QtTest 1.0 + +MultiPointTouchArea { + id: touchArea + width: 100 + height: 100 + + SignalSpy { + id: touchUpdatedSpy + target: touchArea + signalName: "touchUpdated" + } + + SignalSpy { + id: interiorSpy + target: interior + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: interior + width: parent.width / 2 + height: parent.height + anchors.right: parent.right + } + + Window { + width: 100; height: 100 + + SignalSpy { + id: subWindowSpy + target: subWindowTouchArea + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: subWindowTouchArea + anchors.fill: parent + } + } + + TestCase { + when: windowShown + name: "touch" + + function comparePoint(point, id, x, y) { + var retval = true; + var pointId = point.pointId & 0xFFFFFF; //strip device identifier + if (pointId !== id) { + warn("Unexpected pointId: " + pointId + ". Expected " + id); + retval = false; + } + if (point.x !== x) { + warn("Unexpected x: " + point.x + ". Expected " + x); + retval = false; + } + if (point.y !== y) { + warn("Unexpected y: " + point.y + ". Expected " + y); + retval = false; + } + return retval; + } + + function cleanup() { + touchUpdatedSpy.clear(); + interiorSpy.clear(); + subWindowSpy.clear(); + } + + function test_secondWindow() { + var first = 1; + var sequence = touchEvent(subWindowTouchArea); + sequence.press(first, 0, 0, 0); + sequence.commit(); + sequence.release(first, subWindowTouchArea, 0, 0) + sequence.commit(); + compare(subWindowSpy.count, 2); + var touchPoint = subWindowSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, 0, 0)); + } + + function initTestCase() { + waitForRendering(touchArea) // when: windowShown may be insufficient + } + + function test_childMapping() { + var sequence = touchEvent(touchArea); + + var first = 1; + // Test mapping touches to a child item + sequence.press(first, interior, 0, 0); + sequence.commit(); + + // Map touches to the parent at the same point + sequence.move(first, touchArea, interior.x, interior.y); + sequence.commit(); + + sequence.release(first, touchArea, interior.x, interior.y); + sequence.commit(); + + compare(interiorSpy.count, 3); + verify(comparePoint(interiorSpy.signalArguments[0][0][0], first, 0, 0)); + verify(comparePoint(interiorSpy.signalArguments[1][0][0], first, 0, 0)); + } + + function test_fullSequence() { + var sequence = touchEvent(touchArea); + verify(sequence); + + var first = 1; + var second = 2; + + sequence.press(first, null, 0, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 1); + var touchPoints = touchUpdatedSpy.signalArguments[0][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], first, 0, 0)); + + sequence.stationary(first); + sequence.press(second, null, 1, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 2); + touchPoints = touchUpdatedSpy.signalArguments[1][0]; + compare(touchPoints.length, 2); + verify(comparePoint(touchPoints[0], first, 0, 0)); + verify(comparePoint(touchPoints[1], second, 1, 0)); + + sequence.release(first); + sequence.move(second, null, 1, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 3); + touchPoints = touchUpdatedSpy.signalArguments[2][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], second, 1, 1)); + + sequence.release(second, null, 0, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 4); + touchPoints = touchUpdatedSpy.signalArguments[3][0]; + compare(touchPoints.length, 0); + } + + function test_simpleChain() { + var first = 1; + touchEvent(touchArea).press(first).commit().release(first).commit(); + compare(touchUpdatedSpy.count, 2); + var touchPoint = touchUpdatedSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, touchArea.width / 2, touchArea.height / 2)); + } + } +} diff --git a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml new file mode 100644 index 0000000000..c4912c7388 --- /dev/null +++ b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.8 +import QtQuick.Window 2.2 +import QtTest 1.2 + +TestCase { + id: testCase + name: "tst_createTemporaryObject" + width: 100 + height: 100 + when: windowShown + + property var createdObjectNames: [] + + function verifyNoChildren() { + for (var i = 0; i < createdObjectNames.length; ++i) { + verify(!findChild(testCase, createdObjectNames[i])); + } + } + + function init() { + // The items are destroyed after cleanup(), so we check here after every test, + // and once for the last test in cleanupTestCase(). + verifyNoChildren(); + } + + function cleanupTestCase() { + verifyNoChildren(); + } + + function test_fromQml_data() { + return [ + { tag: "QtObject", qml: "import QtQml 2.0; QtObject {}" }, + { tag: "Item", qml: "import QtQuick 2.0; Item {}" }, + ]; + } + + function test_fromQml(data) { + var object = createTemporaryQmlObject(data.qml, testCase); + verify(object); + + object.objectName = data.tag + "FromQml"; + compare(findChild(testCase, object.objectName), object); + + createdObjectNames.push(object.objectName); + } + + Component { + id: objectComponent + + QtObject {} + } + + Component { + id: itemComponent + + Item {} + } + + Component { + id: windowComponent + + Window {} + } + + function test_fromComponent_data() { + return [ + { tag: "QtObject", component: objectComponent }, + { tag: "Item", component: itemComponent }, + { tag: "Window", component: windowComponent }, + ]; + } + + function test_fromComponent(data) { + var object = createTemporaryObject(data.component, testCase); + verify(object); + + object.objectName = data.tag + "FromComponent"; + compare(findChild(testCase, object.objectName), object); + + if (object.hasOwnProperty("contentItem")) + object.contentItem.objectName = "WindowContentItemFromComponent"; + + createdObjectNames.push(object.objectName); + } +} diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 872a71011d..1ca809c05f 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -103,7 +103,7 @@ tst_examples::tst_examples() excludedFiles << "views/visualdatamodel/slideshow.qml"; #endif -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) //No support for Particles excludedFiles << "examples/qml/dynamicscene/dynamicscene.qml"; excludedFiles << "examples/quick/animation/basics/color-animation.qml"; diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp index 6c94b484ae..ad77743ddd 100644 --- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp +++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp @@ -48,7 +48,7 @@ #include <QtQuick/private/qsgadaptationlayer_p.h> #include <QtQuick/private/qsgcontext_p.h> #include <QtQuick/private/qsgcontextplugin_p.h> -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include <QtQuick/private/qsgdefaultdistancefieldglyphcache_p.h> #include <QtQuick/private/qsgdefaultglyphnode_p.h> #include <QtQuick/private/qsgdefaultinternalimagenode_p.h> diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 5d242fab9e..71b0160c8e 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -76,7 +76,7 @@ private slots: void statusChanges_data(); void sourceSizeChanges(); void progressAndStatusChanges(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void borderImageMesh(); #endif @@ -583,7 +583,7 @@ void tst_qquickborderimage::progressAndStatusChanges() delete obj; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickborderimage::borderImageMesh() { QQuickView *window = new QQuickView; diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index b774481592..942e99018f 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1225,7 +1225,7 @@ void tst_qquickflickable::flickOnRelease() QTRY_VERIFY(!flickable->isMoving()); #ifdef Q_OS_MAC -# ifndef QT_NO_OPENGL +# if QT_CONFIG(opengl) QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue); # endif #endif diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp index 256fa43d2e..650892d650 100644 --- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp +++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp @@ -35,7 +35,7 @@ #include "../../shared/util.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include <QtGui/qopenglcontext.h> #include <QtGui/qsurfaceformat.h> #endif @@ -67,7 +67,7 @@ void tst_QQuickGraphicsInfo::testProperties() QCOMPARE(obj->property("api").toInt(), expectedAPI); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (expectedAPI == QSGRendererInterface::OpenGL) { QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL)); QVERIFY(view.openglContext()); diff --git a/tests/auto/quick/qquickitem/data/shortcutOverride.qml b/tests/auto/quick/qquickitem/data/shortcutOverride.qml new file mode 100644 index 0000000000..fab9175c17 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/shortcutOverride.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.8 +import QtQuick.Window 2.1 + +Item { + property int escapeHandlerActivationCount: 0 + property int shortcutActivationCount: 0 + property alias escapeItem: escapeItem + + Item { + id: escapeItem + objectName: "escapeItem" + focus: true + + // By accepting shortcut override events when the key is Qt.Key_Escape, + // we can ensure that our Keys.onEscapePressed handler (below) will be called. + Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape) + + Keys.onEscapePressed: { + // Pretend that we just did some really important stuff that was triggered + // by the escape key (like might occur in a popup that has a keyboard shortcut editor, for example). + // Now that we're done, we no longer need focus, so we won't accept future shorcut override events. + focus = false; + event.accepted = true; + ++escapeHandlerActivationCount; + } + } + + Shortcut { + sequence: "Escape" + onActivated: ++shortcutActivationCount + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index d0139b6cdf..8d974f4d17 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -172,6 +172,8 @@ private slots: void ignoreButtonPressNotInAcceptedMouseButtons(); + void shortcutOverride(); + private: enum PaintOrderOp { @@ -2036,6 +2038,39 @@ void tst_qquickitem::ignoreButtonPressNotInAcceptedMouseButtons() QCOMPARE(item.releaseCount, 1); } +void tst_qquickitem::shortcutOverride() +{ + QQuickView view; + view.setSource(testFileUrl("shortcutOverride.qml")); + ensureFocus(&view); + + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 0); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + + QQuickItem *escapeItem = view.rootObject()->property("escapeItem").value<QQuickItem*>(); + QVERIFY(escapeItem); + QVERIFY(escapeItem->hasActiveFocus()); + + // escapeItem's onEscapePressed handler should accept the first escape press event. + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + // Now it shouldn't have focus, so it can't handle the next escape press event. + QVERIFY(!escapeItem->hasActiveFocus()); + + QTest::keyRelease(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1); + + QTest::keyRelease(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1); +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 6554d749dd..cc74b7e07d 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -2726,9 +2726,9 @@ struct TestListener : public QQuickItemChangeListener { TestListener(bool remove = false) : remove(remove) { } - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &diff) override + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &oldGeometry) override { - record(item, QQuickItemPrivate::Geometry, diff); + record(item, QQuickItemPrivate::Geometry, oldGeometry); } void itemSiblingOrderChanged(QQuickItem *item) override { @@ -2810,20 +2810,20 @@ void tst_QQuickItem::changeListener() item->setImplicitWidth(10); QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitWidth), 1); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 1); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,0))); item->setImplicitHeight(20); QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitHeight), 1); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 2); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,20))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0))); item->setWidth(item->width() + 30); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 3); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,30,0))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,20))); item->setHeight(item->height() + 40); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 4); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,40))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,40,20))); item->setOpacity(0.5); QCOMPARE(itemListener.count(QQuickItemPrivate::Opacity), 1); @@ -3133,7 +3133,7 @@ void tst_QQuickItem::parentLoop() { QQuickView *window = new QQuickView(0); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression msgRegexp = QRegularExpression("QQuickItem::setParentItem: Parent QQuickItem\\(.*\\) is already part of the subtree of QQuickItem\\(.*\\)"); QTest::ignoreMessage(QtWarningMsg, msgRegexp); #endif @@ -3304,7 +3304,7 @@ void tst_QQuickItem::grab() QVERIFY(root); QQuickItem *item = root->findChild<QQuickItem *>("myItem"); QVERIFY(item); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) { // Default size (item is 100x100) QSharedPointer<QQuickItemGrabResult> result = item->grabToImage(); QSignalSpy spy(result.data(), SIGNAL(ready())); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 2576a1b0fc..44310008d6 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -61,7 +61,7 @@ private slots: void initTestCase() Q_DECL_OVERRIDE; void layerEnabled(); void layerSmooth(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void layerMipmap(); void layerEffect(); #endif @@ -105,7 +105,7 @@ tst_QQuickItemLayer::tst_QQuickItemLayer() void tst_QQuickItemLayer::initTestCase() { QQmlDataTest::initTestCase(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QWindow window; QOpenGLContext context; window.setSurfaceType(QWindow::OpenGLSurface); @@ -177,7 +177,7 @@ void tst_QQuickItemLayer::layerEnabled() QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1)); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // The test draws a one pixel wide line and scales it down by more than a a factor 2 // If mipmpping works, the pixels should be gray, not white or black diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index b0d903908f..61ba2caaf7 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2373,7 +2373,7 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header + QTRY_VERIFY((topItem = findVisibleChild(contentItem, "sect_aaa"))); // section header QCOMPARE(topItem->y(), 10.); // remove section boundary @@ -2389,7 +2389,8 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QVERIFY(topItem = findVisibleChild(contentItem, "sect_1")); + topItem = findVisibleChild(contentItem, "sect_1"); + QVERIFY(topItem); QTRY_COMPARE(topItem->y(), 120.); // Change the next section @@ -2974,31 +2975,38 @@ void tst_QQuickListView::itemListFlicker() QTRY_COMPARE(model->count(), 3); QTRY_COMPARE(listview->currentIndex(), 0); - QQuickItem *item; - - QVERIFY(item = findItem<QQuickItem>(contentItem, "item1")); + QQuickItem *item = findItem<QQuickItem>(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item2")); + item = findItem<QQuickItem>(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item3")); + item = findItem<QQuickItem>(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(1); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item1")); + item = findItem<QQuickItem>(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item2")); + item = findItem<QQuickItem>(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item3")); + item = findItem<QQuickItem>(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(2); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item1")); + item = findItem<QQuickItem>(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item2")); + item = findItem<QQuickItem>(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem<QQuickItem>(contentItem, "item3")); + item = findItem<QQuickItem>(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); } @@ -5335,14 +5343,17 @@ void tst_QQuickListView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem")); + QQuickItem *item = findItem<QQuickItem>(rootItem, "listItem"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild<QQuickItem *>("header")); + item = rootItem->findChild<QQuickItem *>("header"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild<QQuickItem *>("footer")); + item = rootItem->findChild<QQuickItem *>("footer"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild<QQuickItem *>("section")); + item = rootItem->findChild<QQuickItem *>("section"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -5604,42 +5615,49 @@ void tst_QQuickListView::unrequestedVisibility() QVERIFY(QTest::qWaitForWindowExposed(window)); - QQuickListView *leftview = findItem<QQuickListView>(window->rootObject(), "leftList"); - QTRY_VERIFY(leftview != 0); + QQuickListView *leftview; + QTRY_VERIFY((leftview = findItem<QQuickListView>(window->rootObject(), "leftList"))); - QQuickListView *rightview = findItem<QQuickListView>(window->rootObject(), "rightList"); - QTRY_VERIFY(rightview != 0); + QQuickListView *rightview; + QTRY_VERIFY((rightview = findItem<QQuickListView>(window->rootObject(), "rightList"))); QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); + QTRY_VERIFY((leftContent = leftview->contentItem())); - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); + QQuickItem *rightContent; + QTRY_VERIFY((rightContent = rightview->contentItem())); rightview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 100.0); - QQuickItem *item; - - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1)); + const QString wrapperObjectName = QStringLiteral("wrapper"); + QQuickItem *item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); rightview->setCurrentIndex(0); @@ -5647,106 +5665,139 @@ void tst_QQuickListView::unrequestedVisibility() QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); - QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19)); - QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19)); + QVERIFY(!findItem<QQuickItem>(leftContent, wrapperObjectName, 19)); + QVERIFY(!findItem<QQuickItem>(rightContent, wrapperObjectName, 19)); leftview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 100.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(19, 1, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1)); + QTRY_VERIFY((item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1))); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(3, 4, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(4, 3, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(16, 17, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(17, 16, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5)); + item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17)); + item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); delete window; @@ -7249,14 +7300,14 @@ void tst_QQuickListView::displayMargin() QQuickItem *content = listview->contentItem(); QVERIFY(content != 0); - QQuickItem *item0; - QQuickItem *item14; - - QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0)); + QQuickItem *item0 = findItem<QQuickItem>(content, "delegate", 0); + QVERIFY(item0); QCOMPARE(delegateVisible(item0), true); // the 14th item should be within the end margin - QVERIFY(item14 = findItem<QQuickItem>(content, "delegate", 13)); + + QQuickItem *item14 = findItem<QQuickItem>(content, "delegate", 13); + QVERIFY(item14); QCOMPARE(delegateVisible(item14), true); // the 15th item should be outside the end margin @@ -7273,7 +7324,6 @@ void tst_QQuickListView::displayMargin() void tst_QQuickListView::negativeDisplayMargin() { - QQuickItem *item; QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("negativeDisplayMargin.qml")); window->show(); @@ -7289,22 +7339,26 @@ void tst_QQuickListView::negativeDisplayMargin() QQuickItem *content = innerList->contentItem(); QVERIFY(content != 0); - QVERIFY(item = findItem<QQuickItem>(content, "delegate", 0)); + QQuickItem *item = findItem<QQuickItem>(content, "delegate", 0); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(content, "delegate", 7)); + item = findItem<QQuickItem>(content, "delegate", 7); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8)); + item = findItem<QQuickItem>(content, "delegate", 8); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); // Flick until contentY means that delegate8 should be visible listview->setProperty("contentY", 500); - QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8)); + item = findItem<QQuickItem>(content, "delegate", 8); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 1000); - QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 14)); + QTRY_VERIFY((item = findItem<QQuickItem>(content, "delegate", 14))); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 0); diff --git a/tests/auto/quick/qquickmousearea/data/pressAndHold.qml b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml new file mode 100644 index 0000000000..bde195965e --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml @@ -0,0 +1,12 @@ +import QtQuick 2.9 + +Item { + width: 100 + height: 100 + + MouseArea { + id: mouseArea + objectName: "mouseArea" + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index f22528a8a0..c8351b9e18 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -59,7 +59,7 @@ static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArr const QSize size = v.size(); const QPoint offset = QPoint(size.width() / 2, size.height() / 2); v.setFramePosition(screenGeometry.center() - offset); -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. if (moveMouseOut) QCursor::setPos(v.geometry().topRight() + QPoint(100, 100)); #else @@ -116,7 +116,7 @@ private slots: void pressedMultipleButtons_data(); void pressedMultipleButtons(); void changeAxis(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursorShape(); #endif void moveAndReleaseWithoutPress(); @@ -127,6 +127,8 @@ private slots: void containsPress(); void ignoreBySource(); void notPressedAfterStolenGrab(); + void pressAndHold_data(); + void pressAndHold(); private: int startDragDistance() const { @@ -1692,7 +1694,7 @@ void tst_QQuickMouseArea::changeAxis() QCOMPARE(blackRect->y(), 94.0); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_QQuickMouseArea::cursorShape() { QQmlEngine engine; @@ -2098,6 +2100,49 @@ void tst_QQuickMouseArea::notPressedAfterStolenGrab() QVERIFY(!ma->pressed()); } +void tst_QQuickMouseArea::pressAndHold_data() +{ + QTest::addColumn<int>("pressAndHoldInterval"); + QTest::addColumn<int>("waitTime"); + + QTest::newRow("default") << -1 << QGuiApplication::styleHints()->mousePressAndHoldInterval(); + QTest::newRow("short") << 500 << 500; + QTest::newRow("long") << 1000 << 1000; +} + +void tst_QQuickMouseArea::pressAndHold() +{ + QFETCH(int, pressAndHoldInterval); + QFETCH(int, waitTime); + + QQuickView window; + QByteArray errorMessage; + QVERIFY2(initView(window, testFileUrl("pressAndHold.qml"), true, &errorMessage), errorMessage.constData()); + window.show(); + window.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QQuickItem *root = window.rootObject(); + QVERIFY(root != 0); + + QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea*>("mouseArea"); + QVERIFY(mouseArea != 0); + + QSignalSpy pressAndHoldSpy(mouseArea, &QQuickMouseArea::pressAndHold); + + if (pressAndHoldInterval > -1) + mouseArea->setPressAndHoldInterval(pressAndHoldInterval); + else + mouseArea->resetPressAndHoldInterval(); + + QElapsedTimer t; + t.start(); + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50)); + QVERIFY(pressAndHoldSpy.wait()); + // should be off by no more than 20% of waitTime + QVERIFY(qAbs(t.elapsed() - waitTime) < (waitTime * 0.2)); + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50)); +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" diff --git a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp index 44d7b40ed9..1716bdeafb 100644 --- a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp +++ b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp @@ -32,7 +32,7 @@ #include <QtQuick/qquickview.h> #include <private/qquickitem_p.h> -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include <private/qsgdefaultpainternode_p.h> #else #include <private/qsgsoftwarepainternode_p.h> @@ -73,7 +73,7 @@ public: ++paintRequests; clipRect = painter->clipBoundingRect(); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { paintNode = static_cast<QSGDefaultPainterNode *>(QQuickPaintedItem::updatePaintNode(oldNode, data)); diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index d013d190ec..ba3d182efc 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1633,8 +1633,8 @@ void tst_QQuickPathView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0)); + QQuickItem *item = findItem<QQuickItem>(rootItem, "listItem", 0); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -1685,7 +1685,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 1); // currentIndex is now 1 - QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1)); + item = findItem<QQuickRectangle>(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1697,7 +1698,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 2); // currentIndex is now 2 - QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2)); + item = findItem<QQuickRectangle>(pathview, "wrapper", 2); + QVERIFY(item); // verify that current item (item 2) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1709,7 +1711,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 3); // currentIndex is now 1 - QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1)); + item = findItem<QQuickRectangle>(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp index 80c6c9e553..e854a109a1 100644 --- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -35,7 +35,7 @@ #include "testhttpserver.h" #include <QtNetwork/QNetworkConfigurationManager> -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) #include <qtconcurrentrun.h> #include <qfuture.h> #endif @@ -57,7 +57,7 @@ private slots: void massive(); void cancelcrash(); void shrinkcache(); -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void networkCrash(); #endif void lockingCrash(); @@ -105,7 +105,7 @@ void tst_qquickpixmapcache::initTestCase() QVERIFY2(server.listen(), qPrintable(server.errorString())); -#ifndef QT_NO_BEARERMANAGEMENT +#if QT_CONFIG(bearermanagement) // This avoids a race condition/deadlock bug in network config // manager when it is accessed by the HTTP server thread before // anything else. Bug report can be found at: @@ -372,7 +372,7 @@ void tst_qquickpixmapcache::shrinkcache() } } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void createNetworkServer(TestHTTPServer *server) { @@ -382,7 +382,7 @@ void createNetworkServer(TestHTTPServer *server) eventLoop.exec(); } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) // QT-3957 void tst_qquickpixmapcache::networkCrash() { diff --git a/tests/auto/quick/qquicktextedit/data/cursorHeight.qml b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml new file mode 100644 index 0000000000..b831a9eb6f --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 300 + color: "white" + + TextEdit { + objectName: "textEditObject" + width: 300 + height: 300 + text: "<span style=\"font-size:20pt;\">Blah</span><br>blah" + textFormat: TextEdit.RichText + cursorDelegate: Rectangle { + objectName: "cursorInstance" + color: "red" + width: 2 + } + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 5ed0e9eea7..ac57a05176 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -140,9 +140,10 @@ private slots: void cursorVisible(); void delegateLoading_data(); void delegateLoading(); + void cursorDelegateHeight(); void navigation(); void readOnly(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void canPaste(); void canPasteEmpty(); @@ -152,7 +153,7 @@ private slots: void inputMethodUpdate(); void openInputPanel(); void geometrySignals(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void pastingRichText_QTBUG_14003(); #endif void implicitSize_data(); @@ -928,7 +929,6 @@ void tst_qquicktextedit::hAlignVisual() const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); - image.save("test3.png"); QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); QVERIFY2(mid < right, msgNotLessThan(mid, right).constData()); } @@ -2848,6 +2848,43 @@ void tst_qquicktextedit::delegateLoading() //QVERIFY(!delegate); } +void tst_qquicktextedit::cursorDelegateHeight() +{ + QQuickView view(testFileUrl("cursorHeight.qml")); + view.show(); + view.requestActivate(); + QTest::qWaitForWindowActive(&view); + QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject"); + QVERIFY(textEditObject); + // Delegate creation is deferred until focus in or cursor visibility is forced. + QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance")); + QVERIFY(!textEditObject->isCursorVisible()); + + // Test that the delegate gets created. + textEditObject->setFocus(true); + QVERIFY(textEditObject->isCursorVisible()); + QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance"); + QVERIFY(delegateObject); + + const int largerHeight = textEditObject->cursorRectangle().height(); + + textEditObject->setCursorPosition(0); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Move the cursor to the next line, which has a smaller font. + textEditObject->setCursorPosition(5); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QVERIFY(textEditObject->cursorRectangle().height() < largerHeight); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Test that the delegate gets deleted + textEditObject->setCursorDelegate(0); + QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance")); +} + /* TextEdit element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. @@ -2886,7 +2923,7 @@ void tst_qquicktextedit::navigation() QCOMPARE(input->hasActiveFocus(), false); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2963,7 +3000,7 @@ void tst_qquicktextedit::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -2981,7 +3018,7 @@ void tst_qquicktextedit::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -2999,7 +3036,7 @@ void tst_qquicktextedit::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3301,7 +3338,7 @@ void tst_qquicktextedit::geometrySignals() delete o; } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::pastingRichText_QTBUG_14003() { QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }"; diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 8dc3053d89..1451f8e2fc 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -145,7 +145,7 @@ private slots: void cursorRectangle(); void navigation(); void navigation_RTL(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void copyAndPasteKeySequence(); void canPasteEmpty(); @@ -2532,7 +2532,7 @@ void tst_qquicktextinput::navigation_RTL() QVERIFY(input->hasActiveFocus()); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2630,7 +2630,7 @@ void tst_qquicktextinput::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPasteKeySequence() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2698,7 +2698,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -2714,7 +2714,7 @@ void tst_qquicktextinput::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -2730,7 +2730,7 @@ void tst_qquicktextinput::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3052,7 +3052,7 @@ void tst_qquicktextinput::cursorRectangle_data() << false; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) #define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \ QCOMPARE((type) input->inputMethodQuery(property).method(), result); #else diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index bfffa6f7f5..300ca392f9 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -284,7 +284,7 @@ public: private slots: void cleanup(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void openglContextCreatedSignal(); #endif void aboutToStopSignal(); @@ -351,7 +351,7 @@ private slots: void qobjectEventFilter_key(); void qobjectEventFilter_mouse(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursor(); #endif @@ -374,14 +374,14 @@ private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_DECLARE_METATYPE(QOpenGLContext *); #endif void tst_qquickwindow::cleanup() { QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickwindow::openglContextCreatedSignal() { qRegisterMetaType<QOpenGLContext *>(); @@ -1346,7 +1346,7 @@ void tst_qquickwindow::headless() if (isGL) QVERIFY(!window->isSceneGraphInitialized()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (QGuiApplication::platformName() == QLatin1String("windows") && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { QSKIP("Crashes on Windows/ANGLE, QTBUG-42967"); @@ -1534,7 +1534,7 @@ void tst_qquickwindow::ownershipRootItem() QVERIFY(!accessor->isRootItemDestroyed()); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_qquickwindow::cursor() { QQuickWindow window; @@ -1707,7 +1707,7 @@ void tst_qquickwindow::hideThenDelete() QTest::qWaitForWindowExposed(&window); const bool threaded = QQuickWindowPrivate::get(&window)->context->thread() != QGuiApplication::instance()->thread(); const bool isGL = window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (isGL) openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); #endif @@ -1736,7 +1736,7 @@ void tst_qquickwindow::hideThenDelete() } QVERIFY(sgInvalidated->size() > 0); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (openglDestroyed) QVERIFY(openglDestroyed->size() > 0); #endif @@ -2147,7 +2147,7 @@ void tst_qquickwindow::defaultSurfaceFormat() QCOMPARE(format.profile(), reqFmt.profile()); QCOMPARE(int(format.options()), int(reqFmt.options())); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Depth and stencil should be >= what has been requested. For real. But use // the context since the window's surface format is only partially updated // on most platforms. @@ -2202,7 +2202,7 @@ public: } static int deleted; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class GlRenderJob : public QRunnable { public: @@ -2273,7 +2273,7 @@ void tst_qquickwindow::testRenderJob() QTRY_COMPARE(RenderJob::deleted, 1); QCOMPARE(completedJobs.size(), 1); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) { // Do a synchronized GL job. GLubyte readPixel[4] = {0, 0, 0, 0}; diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index f6d624d871..2cd3a041c8 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -28,7 +28,7 @@ #include <qtest.h> -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include <QOffscreenSurface> #include <QOpenGLContext> #include <QOpenGLFunctions> @@ -37,7 +37,7 @@ #include <QtQuick> #include <QtQml> -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include <private/qopenglcontext_p.h> #endif @@ -105,7 +105,7 @@ private slots: void render_data(); void render(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void hideWithOtherContext(); #endif void createTextureFromImage_data(); @@ -130,7 +130,7 @@ void tst_SceneGraph::initTestCase() QSGRenderLoop *loop = QSGRenderLoop::instance(); qDebug() << "RenderLoop: " << loop; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext context; context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); context.create(); @@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows_data() QTest::newRow("rects,subwindow,sharing") << QStringLiteral("manyWindows_rects.qml") << false << true; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) struct ShareContextResetter { public: ~ShareContextResetter() { qt_gl_set_global_share_context(0); } @@ -234,7 +234,7 @@ void tst_SceneGraph::manyWindows() QFETCH(QString, file); QFETCH(bool, toplevel); QFETCH(bool, shared); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext sharedGLContext; ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure. if (shared) { @@ -479,7 +479,7 @@ void tst_SceneGraph::render() } } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Testcase for QTBUG-34898. We make another context current on another surface // in the GUI thread and hide the QQuickWindow while the other context is // current on the other window. diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index ab58aee648..cb2b8be97a 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -61,7 +61,7 @@ void QQuickViewTestUtil::centerOnScreen(QQuickView *window) void QQuickViewTestUtil::moveMouseAway(QQuickView *window) { -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); #else Q_UNUSED(window) diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro new file mode 100644 index 0000000000..3b4ec23a64 --- /dev/null +++ b/tests/auto/quicktest/quicktest.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + signalspy diff --git a/tests/auto/quicktest/signalspy/data/signalspy.qml b/tests/auto/quicktest/signalspy/data/signalspy.qml new file mode 100644 index 0000000000..6c365e296a --- /dev/null +++ b/tests/auto/quicktest/signalspy/data/signalspy.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.1 +import MyImport 1.0 + +Rectangle { + id:rect + width: 200 + height: 200 + color:"red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + MyPropertyMap { + id: propertyMap + objectName: "propertyMap" + } + + SignalSpy { + objectName: "mouseSpy" + target: mouseArea + signalName: "pressed" + } + + SignalSpy { + objectName: "propertyMapSpy" + target: propertyMap + signalName: "mySignal" + } +} diff --git a/tests/auto/quicktest/signalspy/mypropertymap.cpp b/tests/auto/quicktest/signalspy/mypropertymap.cpp new file mode 100644 index 0000000000..91bd93dde0 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mypropertymap.h" + +MyPropertyMap::MyPropertyMap(QObject *parent): QQmlPropertyMap(this, parent) +{ +} + +MyPropertyMap::~MyPropertyMap() +{ +} + diff --git a/tests/auto/quicktest/signalspy/mypropertymap.h b/tests/auto/quicktest/signalspy/mypropertymap.h new file mode 100644 index 0000000000..d69548fe88 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QQmlPropertyMap> + +class MyPropertyMap : public QQmlPropertyMap +{ + Q_OBJECT + +public: + MyPropertyMap(QObject *parent = nullptr); + ~MyPropertyMap(); + +Q_SIGNALS: + void mySignal(); +}; diff --git a/tests/auto/quicktest/signalspy/signalspy.pro b/tests/auto/quicktest/signalspy/signalspy.pro new file mode 100644 index 0000000000..c8f9be1f36 --- /dev/null +++ b/tests/auto/quicktest/signalspy/signalspy.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_signalspy +macos:CONFIG -= app_bundle + +SOURCES += tst_signalspy.cpp mypropertymap.cpp +HEADERS += mypropertymap.h +QT += quick testlib + +include (../../shared/util.pri) diff --git a/tests/auto/quicktest/signalspy/tst_signalspy.cpp b/tests/auto/quicktest/signalspy/tst_signalspy.cpp new file mode 100644 index 0000000000..f54da7819c --- /dev/null +++ b/tests/auto/quicktest/signalspy/tst_signalspy.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> + +#include <qqmlengine.h> +#include <qquickitem.h> +#include <qquickview.h> + +#include "../../shared/util.h" +#include "mypropertymap.h" + +class tst_SignalSpy : public QQmlDataTest +{ + Q_OBJECT +public: + tst_SignalSpy(); + +private slots: + void testValid(); + void testCount(); + +private: + QQmlEngine engine; +}; + +tst_SignalSpy::tst_SignalSpy() +{ + qmlRegisterType<MyPropertyMap>("MyImport", 1, 0, "MyPropertyMap"); +} + +void tst_SignalSpy::testValid() +{ + QQuickView window; + window.setSource(testFileUrl("signalspy.qml")); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild<QObject*>("mouseSpy"); + QVERIFY(mouseSpy->property("valid").toBool()); + + QObject *propertyMapSpy = window.rootObject()->findChild<QObject*>("propertyMapSpy"); + QVERIFY(propertyMapSpy->property("valid").toBool()); +} + +void tst_SignalSpy::testCount() +{ + QQuickView window; + window.resize(200, 200); + window.setSource(testFileUrl("signalspy.qml")); + window.show(); + QTest::qWaitForWindowActive(&window); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild<QObject*>("mouseSpy"); + QCOMPARE(mouseSpy->property("count").toInt(), 0); + + QObject *propertyMapSpy = window.rootObject()->findChild<QObject*>("propertyMapSpy"); + QCOMPARE(propertyMapSpy->property("count").toInt(), 0); + + QTest::mouseClick(&window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 100)); + QTRY_COMPARE(mouseSpy->property("count").toInt(), 1); + + MyPropertyMap *propertyMap = static_cast<MyPropertyMap *>(window.rootObject()->findChild<QObject*>("propertyMap")); + Q_EMIT propertyMap->mySignal(); + QCOMPARE(propertyMapSpy->property("count").toInt(), 1); +} + +QTEST_MAIN(tst_SignalSpy) + +#include "tst_signalspy.moc" diff --git a/tests/auto/shared/platformquirks.h b/tests/auto/shared/platformquirks.h index 5e4929230a..5252e8cfe2 100644 --- a/tests/auto/shared/platformquirks.h +++ b/tests/auto/shared/platformquirks.h @@ -39,7 +39,7 @@ struct PlatformQuirks { static inline bool isClipboardAvailable() { -#if defined(QT_NO_CLIPBOARD) +#if !QT_CONFIG(clipboard) return false; #elif defined(Q_OS_OSX) PasteboardRef pasteboard; diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 690e193b53..61339c6f60 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -75,7 +75,7 @@ void tst_compilation::boomblock() QQmlComponent c(&engine); c.setData(data, QUrl()); } -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) QSKIP("boomblock imports Particles which requires OpenGL Support"); #endif QBENCHMARK { diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index a1c09db158..9fc67ada71 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -221,12 +221,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) void tst_creation::itemtree_notree_cpp() { + std::vector<QQuickItem *> kids; + kids.resize(30); QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; - Q_UNUSED(child); + kids[i] = child; } + qDeleteAll(kids); delete item; } } @@ -258,12 +261,13 @@ void tst_creation::itemtree_cpp() void tst_creation::itemtree_data_cpp() { + QQmlEngine engine; QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; QQmlGraphics_setParent_noEvent(child,item); - QQmlListReference ref(item, "data"); + QQmlListReference ref(item, "data", &engine); ref.append(child); } delete item; diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro index 2cf2dff413..f1fe87e532 100644 --- a/tests/benchmarks/qml/qml.pro +++ b/tests/benchmarks/qml/qml.pro @@ -14,5 +14,3 @@ SUBDIRS += \ creation qtHaveModule(opengl): SUBDIRS += painting qquickwindow - -include(../trusted-benchmarks.pri) diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml new file mode 100644 index 0000000000..b8f0458818 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "<img width=16 height=16 src=\"data/logo.png\" />This image is in the start of the text" + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml new file mode 100644 index 0000000000..e5bea08e62 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "<img width=16 height=16 src=\"data/logo.png\" />هو أمّا حكومة" + } +} diff --git a/tests/tests.pro b/tests/tests.pro index f5731b2f34..ab94786b31 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += auto benchmarks +SUBDIRS += auto +contains(QT_CONFIG, release): SUBDIRS += benchmarks |