diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-04-11 14:56:22 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2012-04-11 16:05:03 +0200 |
commit | a896d4b39ec3d45ba708d9b36ea9c864b1df2136 (patch) | |
tree | 45cfe153cce6114c2c76c48dc0bdabde2a8cf3e3 /tests | |
parent | 24fb8dc27eddfdd62bd2c3a6e863cbf433762cd6 (diff) | |
parent | 65bfc35429e845cf6b76d58107360a1360a654fc (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts:
src/qml/debugger/qqmlprofilerservice_p.h
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/v4/qv4bindings.cpp
src/quick/items/qquickshadereffect.cpp
src/quick/particles/qquickcustomparticle.cpp
src/quick/qtquick2.cpp
Change-Id: Ia9c6517035ae912fa75e77473a452bd3383def56
Diffstat (limited to 'tests')
77 files changed, 2010 insertions, 324 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index 2d52ea9f50..036641cdfc 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -81,7 +81,6 @@ void tst_QQmlDebugClient::initTestCase() QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn); QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); - QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); for (int i = 0; i < 50; ++i) { // try for 5 seconds ... m_conn->connectToHost("127.0.0.1", PORT); @@ -173,7 +172,6 @@ void tst_QQmlDebugClient::sequentialConnect() QTest::qWait(100); connection2.connectToHost("127.0.0.1", PORT); - QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); QVERIFY(connection2.waitForConnected()); QVERIFY(connection2.isConnected()); QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled); diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 8eb1523af9..12acb9feae 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -81,8 +81,6 @@ void tst_QQmlDebugService::initTestCase() m_conn = new QQmlDebugConnection(this); - - QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); for (int i = 0; i < 50; ++i) { // try for 5 seconds ... m_conn->connectToHost("127.0.0.1", PORT); diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp index 9639a36065..0c5dfddffa 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp @@ -50,12 +50,14 @@ struct QmlObjectData { QString objectType; int objectId; int contextId; + int parentId; }; QDataStream &operator>>(QDataStream &ds, QmlObjectData &data) { ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; + >> data.objectName >> data.objectType >> data.objectId >> data.contextId + >> data.parentId; return ds; } diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index b66ba289ce..cc1193b0f1 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -205,7 +205,7 @@ void tst_QQmlEngineDebugService::recursiveObjectTest( // signal properties are fake - they are generated from QQmlAbstractBoundSignal children if (p.name.startsWith("on") && p.name.length() > 2 && p.name[2].isUpper()) { QString signal = p.value.toString(); - QQmlExpression *expr = QQmlPropertyPrivate::signalExpression(QQmlProperty(o, p.name)); + QQmlBoundSignalExpression *expr = QQmlPropertyPrivate::signalExpression(QQmlProperty(o, p.name)); QVERIFY(expr && expr->expression() == signal); QVERIFY(p.valueTypeName.isEmpty()); QVERIFY(p.binding.isEmpty()); @@ -328,7 +328,6 @@ void tst_QQmlEngineDebugService::initTestCase() m_conn = new QQmlDebugConnection(this); m_conn->connectToHost("127.0.0.1", 3768); - QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Connection established."); bool ok = m_conn->waitForConnected(); QVERIFY(ok); QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index 497d544390..2961cedd51 100644 --- a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -77,8 +77,11 @@ public: V8MaximumMessage }; + enum ServiceState { NotRunning, Running } serviceState; + QV8ProfilerClient(QQmlDebugConnection *connection) : QQmlDebugClient(QLatin1String("V8Profiler"), connection) + , serviceState(NotRunning) { } @@ -165,12 +168,15 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message) switch (messageType) { case QV8ProfilerClient::V8Entry: { + QCOMPARE(serviceState, Running); QV8ProfilerData entry; stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel; traceMessages.append(entry); break; } case QV8ProfilerClient::V8Complete: + QCOMPARE(serviceState, Running); + serviceState = NotRunning; emit complete(); break; case QV8ProfilerClient::V8SnapshotChunk: { @@ -183,6 +189,8 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message) emit snapshot(); break; case QV8ProfilerClient::V8Started: + QCOMPARE(serviceState, NotRunning); + serviceState = Running; emit started(); break; default: @@ -208,15 +216,16 @@ void tst_QV8ProfilerService::connect(bool block, const QString &testFile) m_process = new QQmlDebugProcess(executable); m_process->start(QStringList() << arguments); if (!m_process->waitForSessionStart()) { - QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg( - executable, m_process->output()); + QString failMsg = QString("Could not launch app '%1'.").arg(executable); QFAIL(qPrintable(failMsg)); } - QQmlDebugConnection *m_connection = new QQmlDebugConnection(); + m_connection = new QQmlDebugConnection(); m_client = new QV8ProfilerClient(m_connection); m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); + if (!m_connection->waitForConnected()) + QFAIL("Could not connect to debugger port."); } void tst_QV8ProfilerService::cleanup() @@ -226,7 +235,6 @@ void tst_QV8ProfilerService::cleanup() delete m_process; delete m_connection; - delete m_client; } void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() @@ -235,8 +243,6 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), - "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -254,8 +260,6 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() QFAIL(qPrintable(failMsg)); } m_client->startProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), - "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -267,8 +271,6 @@ void tst_QV8ProfilerService::nonBlockingConnect() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), - "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -290,9 +292,6 @@ void tst_QV8ProfilerService::profileOnExit() QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->startProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), - "No start signal received in time."); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); //QVERIFY(!m_client->traceMessages.isEmpty()); @@ -305,8 +304,6 @@ void tst_QV8ProfilerService::console() m_client->stopProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())), - "No start signal received in time."); QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); QVERIFY(!m_client->traceMessages.isEmpty()); diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index ac9fa5fae2..925f5372cd 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -123,7 +123,7 @@ bool QQmlDebugProcess::waitForSessionStart() qWarning() << "Could not start up " << m_executable; return false; } - m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + m_eventLoop.exec(); return m_started; } @@ -161,9 +161,6 @@ void QQmlDebugProcess::processAppOutput() m_eventLoop.quit(); continue; } - if (line.contains("Connection established.")) { - continue; - } } } m_mutex.unlock(); diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 3be7919404..6f0b2e45a2 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -158,6 +158,10 @@ with a lower case letter. void tst_qmlmin::qmlMinify_data() { +#if defined(QTEST_CROSS_COMPILED) + return; +#endif + QTest::addColumn<QString>("file"); QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; @@ -173,11 +177,10 @@ void tst_qmlmin::qmlMinify_data() void tst_qmlmin::qmlMinify() { - QFETCH(QString, file); - #if defined(QTEST_CROSS_COMPILED) QSKIP("sources not available when cross compiled"); #endif + QFETCH(QString, file); QProcess qmlminify; qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file); diff --git a/tests/auto/qml/qqmlecmascript/data/InnerObject.qml b/tests/auto/qml/qqmlecmascript/data/InnerObject.qml new file mode 100644 index 0000000000..a8ed9593d1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/InnerObject.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +QtObject { + property int foo1: 100 + property int foo2: 100 + property int foo3: { return 100; } + property int foo4: { return 100; } + + property string bar1: 'Hello' + property string bar2: 'Hello' + property string bar3: { return 'Hello'; } + property string bar4: { return 'Hello'; } +} diff --git a/tests/auto/qml/qqmlecmascript/data/OuterObject.qml b/tests/auto/qml/qqmlecmascript/data/OuterObject.qml new file mode 100644 index 0000000000..da571a9732 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/OuterObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property InnerObject inner: InnerObject {} +} diff --git a/tests/auto/qml/qqmlecmascript/data/deleteLaterObjectMethodCall.qml b/tests/auto/qml/qqmlecmascript/data/deleteLaterObjectMethodCall.qml new file mode 100644 index 0000000000..d1418e57a1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deleteLaterObjectMethodCall.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + property var fn + + property var c: Component { + MyQmlObject { + function go() { + try { methodNoArgs(); } catch(e) { } + } + } + } + + Component.onCompleted: { + var f = c.createObject().go; + + gc(); + + f(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/ownershipQmlIncubated.qml b/tests/auto/qml/qqmlecmascript/data/ownershipQmlIncubated.qml new file mode 100644 index 0000000000..6f536b27ca --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ownershipQmlIncubated.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + id: root + + property QtObject incubatedItem + + Component.onCompleted: { + var component = Qt.createComponent("PropertyVarBaseItem.qml"); + + var incubator = component.incubateObject(root); + if (incubator.status != Component.Ready) { + incubator.onStatusChanged = function(status) { + if (status == Component.Ready) { + incubatedItem = incubator.object; + } + } + } else { + incubatedItem = incubator.object; + } + } + + function deleteIncubatedItem() { + incubatedItem.destroy(); + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/replaceBinding.qml b/tests/auto/qml/qqmlecmascript/data/replaceBinding.qml new file mode 100644 index 0000000000..670231a144 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/replaceBinding.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +OuterObject { + property bool success: false + + inner.foo1: 200 + inner.foo2: { return 200; } + inner.foo3: 200 + inner.foo4: { return 200; } + + inner.bar1: 'Goodbye' + inner.bar2: { return 'Goodbye' } + inner.bar3: 'Goodbye' + inner.bar4: { return 'Goodbye' } + + Component.onCompleted: { + success = (inner.foo1 == 200 && + inner.foo2 == 200 && + inner.foo3 == 200 && + inner.foo4 == 200 && + inner.bar1 == 'Goodbye' && + inner.bar2 == 'Goodbye' && + inner.bar3 == 'Goodbye' && + inner.bar4 == 'Goodbye'); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/singleV8BindingDestroyedDuringEvaluation.qml b/tests/auto/qml/qqmlecmascript/data/singleV8BindingDestroyedDuringEvaluation.qml new file mode 100644 index 0000000000..ae84f028a5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/singleV8BindingDestroyedDuringEvaluation.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + MyQmlObject { + value: if (1) 3 + } + + MyQmlObject { + value: { deleteMe(), 2 } + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index b3bf92fe81..c2d490e3c5 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -135,6 +135,7 @@ private slots: void ownershipCustomReturnValue(); void ownershipRootObject(); void ownershipConsistency(); + void ownershipQmlIncubated(); void qlistqobjectMethods(); void strictlyEquals(); void compiled(); @@ -183,7 +184,7 @@ private slots: void assignSequenceTypes(); void qtbug_22464(); void qtbug_21580(); - + void singleV8BindingDestroyedDuringEvaluation(); void bug1(); void bug2(); void dynamicCreationCrash(); @@ -246,12 +247,13 @@ private slots: void invokableWithQObjectDerived(); void realTypePrecision(); void registeredFlagMethod(); - + void deleteLaterObjectMethodCall(); void automaticSemicolon(); void unaryExpression(); void switchStatement(); void withStatement(); void tryStatement(); + void replaceBinding(); private: static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -1902,6 +1904,16 @@ void tst_qqmlecmascript::qtbug_21580() delete object; } +// Causes a v8 binding, but not all v8 bindings to be destroyed during evaluation +void tst_qqmlecmascript::singleV8BindingDestroyedDuringEvaluation() +{ + QQmlComponent component(&engine, testFileUrl("singleV8BindingDestroyedDuringEvaluation.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + // QTBUG-6781 void tst_qqmlecmascript::bug1() { @@ -3009,6 +3021,24 @@ void tst_qqmlecmascript::ownershipConsistency() delete object; } +void tst_qqmlecmascript::ownershipQmlIncubated() +{ + QQmlComponent component(&engine, testFileUrl("ownershipQmlIncubated.qml")); + QObject *object = component.create(); + QVERIFY(object); + + QTRY_VERIFY(object->property("incubatedItem").value<QObject*>() != 0); + + QMetaObject::invokeMethod(object, "deleteIncubatedItem"); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(object->property("incubatedItem").value<QObject*>() == 0); + + delete object; +} + class QListQObjectMethodsObject : public QObject { Q_OBJECT @@ -6000,6 +6030,13 @@ void tst_qqmlecmascript::dynamicString() QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!")); } +void tst_qqmlecmascript::deleteLaterObjectMethodCall() +{ + QQmlComponent component(&engine, testFileUrl("deleteLaterObjectMethodCall.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + void tst_qqmlecmascript::automaticSemicolon() { QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml")); @@ -6408,6 +6445,18 @@ void tst_qqmlecmascript::registeredFlagMethod() delete object; } +// QTBUG-23138 +void tst_qqmlecmascript::replaceBinding() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("replaceBinding.qml")); + QObject *obj = c.create(); + QVERIFY(obj != 0); + + QVERIFY(obj->property("success").toBool()); + delete obj; +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 837a9d2604..4720269313 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -181,7 +181,7 @@ private slots: private: QQmlEngine engine; - void testType(const QString& qml, const QString& type, const QString& error); + void testType(const QString& qml, const QString& type, const QString& error, bool partialMatch = false); }; #define DETERMINE_ERRORS(errorfile,expected,actual)\ @@ -1480,7 +1480,7 @@ void tst_qqmllanguage::reservedWords() } // Check that first child of qml is of given type. Empty type insists on error. -void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror) +void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror, bool partialMatch) { QQmlComponent component(&engine); component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports @@ -1495,7 +1495,7 @@ void tst_qqmllanguage::testType(const QString& qml, const QString& type, const Q actualerror.append("; "); actualerror.append(e.description()); } - QCOMPARE(actualerror,expectederror); + QCOMPARE(actualerror.left(partialMatch ? expectederror.length(): -1),expectederror); } else { VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1616,13 +1616,13 @@ void tst_qqmllanguage::importsBuiltin_data() "import com.nokia.Test 1.12\n" "Test {}" << (!qmlCheckTypes()?"TestType2":"") - << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test/ in version 1.12 and 1.11"); QTest::newRow("multiversion 2") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "OldTest {}" << (!qmlCheckTypes()?"TestType":"") - << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test/ in version 1.12 and 1.11"); QTest::newRow("qualified multiversion 3") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" @@ -1691,7 +1691,7 @@ void tst_qqmllanguage::importsLocal_data() "import com.nokia.Test 1.0\n" "Test {}" << (!qmlCheckTypes()?"TestType":"") - << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir"); + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test/ and in subdir/"); } void tst_qqmllanguage::importsLocal() @@ -1841,32 +1841,37 @@ void tst_qqmllanguage::importsOrder_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); + QTest::addColumn<bool>("partialMatch"); QTest::newRow("double import") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QQuickText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.4") + << false; QTest::newRow("installed import overrides 1") << "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QQuickText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.0") + << false; QTest::newRow("installed import overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" << (!qmlCheckTypes()?"QQuickRectangle":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.0 and 1.4") + << false; QTest::newRow("installed import re-overrides 1") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QQuickText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.0") + << false; QTest::newRow("installed import re-overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" @@ -1874,41 +1879,47 @@ void tst_qqmllanguage::importsOrder_data() "import com.nokia.installedtest 1.0\n" "InstalledTest {}" << (!qmlCheckTypes()?"QQuickRectangle":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); - + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.0 and 1.4") + << false; QTest::newRow("installed import versus builtin 1") << "import com.nokia.installedtest 1.5\n" "import QtQuick 2.0\n" "Rectangle {}" << (!qmlCheckTypes()?"QQuickRectangle":"") - << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest"); + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in file://") + << true; QTest::newRow("installed import versus builtin 2") << "import QtQuick 2.0\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" << (!qmlCheckTypes()?"QQuickText":"") - << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt"); + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest/ and in file://") + << true; QTest::newRow("namespaces cannot be overridden by types 1") << "import QtQuick 2.0 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << "" - << "Namespace Rectangle cannot be used as a type"; + << "" + << "Namespace Rectangle cannot be used as a type" + << false; QTest::newRow("namespaces cannot be overridden by types 2") << "import QtQuick 2.0 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle.Image {}" - << "QQuickImage" - << ""; + << "QQuickImage" + << "" + << false; QTest::newRow("local last 1") << "LocalLast {}" - << "QQuickText" - << ""; + << "QQuickText" + << "" + << false; QTest::newRow("local last 2") << "import com.nokia.installedtest 1.0\n" "LocalLast {}" << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml - << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory"); + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest/ and in ") + << false; } void tst_qqmllanguage::importsOrder() @@ -1916,7 +1927,8 @@ void tst_qqmllanguage::importsOrder() QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); - testType(qml,type,error); + QFETCH(bool, partialMatch); + testType(qml,type,error,partialMatch); } void tst_qqmllanguage::importIncorrectCase() diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt new file mode 100644 index 0000000000..262193788b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.AutoTestQmlNestedPluginType.Nested" is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml new file mode 100644 index 0000000000..b3f9ac6c3f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.1.qml @@ -0,0 +1,5 @@ +import com.nokia.AutoTestQmlNestedPluginType.Nested 1.0 +import com.nokia.AutoTestQmlNestedPluginType 1.0 + +MyNestedPluginType { +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml new file mode 100644 index 0000000000..cb8e0e33d1 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.2.qml @@ -0,0 +1,5 @@ +import com.nokia.AutoTestQmlNestedPluginType 1.0 +import com.nokia.AutoTestQmlNestedPluginType.Nested 1.0 + +MyNestedPluginType { +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.errors.txt new file mode 100644 index 0000000000..f0c73e336f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.errors.txt @@ -0,0 +1 @@ +3:1:MyNestedPluginType is not a type diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml new file mode 100644 index 0000000000..69c6a34f46 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.3.qml @@ -0,0 +1,4 @@ +import com.nokia.AutoTestQmlNestedPluginType 1.0 + +MyNestedPluginType { +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt new file mode 100644 index 0000000000..9743ae4f68 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.errors.txt @@ -0,0 +1 @@ +2:1:module "com.nokia.AutoTestQmlNestedPluginType.Nested" version 6.66 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml new file mode 100644 index 0000000000..dce8b7564a --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsNested.4.qml @@ -0,0 +1,5 @@ +import com.nokia.AutoTestQmlNestedPluginType 1.0 +import com.nokia.AutoTestQmlNestedPluginType.Nested 6.66 + +MyNestedPluginType { +} diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlNestedPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlNestedPluginType/qmldir new file mode 100644 index 0000000000..f6ed20dda4 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlNestedPluginType/qmldir @@ -0,0 +1 @@ +plugin nestedPlugin diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp new file mode 100644 index 0000000000..2d0af471c2 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QStringList> +#include <QtQml/qqmlextensionplugin.h> +#include <QtQml/qqml.h> +#include <QDebug> + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString value READ value) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) {} + + QString value() const { return "Hello"; } +}; + +class MyNestedPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString value READ value) + +public: + MyNestedPluginType(QObject *parent=0) : QObject(parent) {} + + QString value() const { return "Goodbye"; } +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json") + +public: + MyPlugin() {} + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlNestedPluginType"); + qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); + + QString nestedUri(uri); + nestedUri += QLatin1String(".Nested"); + + qmlRegisterType<MyNestedPluginType>(nestedUri.toLatin1().constData(), 1, 0, "MyNestedPluginType"); + } +}; + +#include "nestedPlugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro new file mode 100644 index 0000000000..94dc236a4c --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += nestedPlugin +SOURCES = nestedPlugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlNestedPluginType + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro index 42eedc20f2..6da88320cd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -1,6 +1,6 @@ QT = core TEMPLATE = subdirs -SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion +SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion nestedPlugin 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 b574bad595..f6c165840d 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -70,6 +70,8 @@ private slots: void versionNotInstalled_data(); void implicitQmldir(); void implicitQmldir_data(); + void importsNested(); + void importsNested_data(); private: QString m_importsDirectory; @@ -347,6 +349,47 @@ void tst_qqmlmoduleplugin::implicitQmldir() delete obj; } +void tst_qqmlmoduleplugin::importsNested_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorFile"); + + // Note: no other test case should import the plugin used for this test, or the + // wrong order test will pass spuriously + QTest::newRow("wrongOrder") << "importsNested.1.qml" << "importsNested.1.errors.txt"; + QTest::newRow("missingImport") << "importsNested.3.qml" << "importsNested.3.errors.txt"; + QTest::newRow("invalidVersion") << "importsNested.4.qml" << "importsNested.4.errors.txt"; + QTest::newRow("correctOrder") << "importsNested.2.qml" << QString(); +} +void tst_qqmlmoduleplugin::importsNested() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + + // Note: because imports are cached between test case data rows (and the plugins remain loaded), + // these tests should really be run in new instances of the app... + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + if (!errorFile.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + } + + QQmlComponent component(&engine, testFile(file)); + QObject *obj = component.create(); + + if (errorFile.isEmpty()) { + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) + qWarning() << "Unexpected Errors:" << component.errors(); + QVERIFY(obj); + delete obj; + } else { + QList<QQmlError> errors = component.errors(); + VERIFY_ERRORS(errorFile.toLatin1().constData()); + QVERIFY(!obj); + } +} QTEST_MAIN(tst_qqmlmoduleplugin) diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index 00b64e04a1..cb42be91d7 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -165,6 +165,10 @@ and ensures that the subnode's source locations are inside parent node's source void tst_qqmlparser::qmlParser_data() { +#if defined(QTEST_CROSS_COMPILED) + return; +#endif + QTest::addColumn<QString>("file"); QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; @@ -180,11 +184,10 @@ void tst_qqmlparser::qmlParser_data() void tst_qqmlparser::qmlParser() { - QFETCH(QString, file); - #if defined(QTEST_CROSS_COMPILED) QSKIP("sources not available when cross compiled"); #endif + QFETCH(QString, file); using namespace QQmlJS; diff --git a/tests/auto/qml/qqmlproperty/data/invalidBinding.qml b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml new file mode 100644 index 0000000000..e2bb1d172d --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + property Text text: myText + + property Rectangle rectangle1: myText + property Rectangle rectangle2: eval('getMyText()') // eval to force non-shared (v8) binding + + function getMyText() { return myText; } + + Text { + id: myText + + anchors.verticalCenter: parent // invalid binding + } +} diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index aa22450bd3..f2521e93ef 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -45,6 +45,7 @@ #include <QtQml/qqmlproperty.h> #include <QtQml/private/qqmlproperty_p.h> #include <private/qqmlbinding_p.h> +#include <private/qqmlboundsignal_p.h> #include <QtWidgets/QLineEdit> #include <QtCore/qfileinfo.h> #include <QtCore/qdir.h> @@ -133,6 +134,7 @@ private slots: void aliasPropertyBindings(); void noContext(); void assignEmptyVariantMap(); + void warnOnInvalidBinding(); void copy(); private: @@ -145,8 +147,9 @@ void tst_qqmlproperty::qmlmetaproperty() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -178,8 +181,8 @@ void tst_qqmlproperty::qmlmetaproperty() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -248,8 +251,9 @@ void tst_qqmlproperty::qmlmetaproperty_object() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -281,8 +285,8 @@ void tst_qqmlproperty::qmlmetaproperty_object() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -295,8 +299,9 @@ void tst_qqmlproperty::qmlmetaproperty_object() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -330,8 +335,8 @@ void tst_qqmlproperty::qmlmetaproperty_object() QVERIFY(binding != 0); QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -349,8 +354,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -382,8 +388,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -396,8 +402,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -431,8 +438,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QVERIFY(binding != 0); QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -445,8 +452,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -478,9 +486,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression != 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(!sigExprWatcher.wasDeleted()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -493,8 +501,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -526,9 +535,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression != 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(!sigExprWatcher.wasDeleted()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -546,8 +555,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -579,8 +589,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -593,8 +603,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -628,8 +639,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QVERIFY(binding != 0); QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -647,8 +658,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -680,8 +692,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -694,8 +706,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -729,8 +742,8 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QVERIFY(binding != 0); QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -743,8 +756,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -776,9 +790,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression != 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(!sigExprWatcher.wasDeleted()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -791,8 +805,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QWeakPointer<QQmlExpression> expression(new QQmlExpression()); - QVERIFY(expression != 0); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -824,9 +839,9 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); QVERIFY(binding == 0); QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); - QVERIFY(expression != 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, sigExpr) == 0); + QVERIFY(!sigExprWatcher.wasDeleted()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -972,7 +987,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -984,7 +999,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -1140,7 +1155,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1154,7 +1169,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1708,6 +1723,29 @@ void tst_qqmlproperty::assignEmptyVariantMap() delete obj; } +void tst_qqmlproperty::warnOnInvalidBinding() +{ + QUrl testUrl(testFileUrl("invalidBinding.qml")); + QString expectedWarning; + + // V4 error message for property-to-property binding + expectedWarning = testUrl.toString() + QString::fromLatin1(":6:36: Unable to assign QQuickText to QQuickRectangle"); + QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); + + // V8 error message for function-to-property binding + expectedWarning = testUrl.toString() + QString::fromLatin1(":7:36: Unable to assign QQuickText to QQuickRectangle"); + QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); + + // V8 error message for invalid binding to anchor + expectedWarning = testUrl.toString() + QString::fromLatin1(":14: Unable to assign QQuickItem_QML_7 to QQuickAnchorLine"); + QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); + + QQmlComponent component(&engine, testUrl); + QObject *obj = component.create(); + QVERIFY(obj); + delete obj; +} + void tst_qqmlproperty::initTestCase() { QQmlDataTest::initTestCase(); diff --git a/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml index 641ba6e1ca..300074dec1 100644 --- a/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml +++ b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml @@ -11,4 +11,10 @@ QtObject { property variant qdatetime4: new Date(2001,1,2) // 2001/02/02 hh:mm:ss.zzz property variant qdatetime5: new Date(1999,0,1,2,3,4) // 1999/01/01 02:03:04.zzz property variant qdatetime6: new Date(2008,1,24,14,15,38,200) // 2008/02/24 14:15:38.200 + + // Use UTC for historical dates to avoid DST issues + property variant qdatetime7: new Date(Date.UTC(1970,0,1,0,0,0,0)) // 1970/01/01 00:00:00.000 + property variant qdatetime8: new Date(Date.UTC(1586,1,2)) // 1586/02/02 hh:mm:ss.zzz + property variant qdatetime9: new Date(Date.UTC(955,0,1,0,0,0,0)) // 955/01/01 00:00:00.000 + property variant qdatetime10: new Date(Date.UTC(113,1,24,14,15,38,200)) // 113/02/24 14:15:38.200 } diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index a1d7291565..c81e6771b8 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -480,6 +480,10 @@ void tst_qqmlqt::dateTimeConversion() QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0)); QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0)); QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200)); + QDateTime dateTime7(QDate(1970,1,1), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime8(QDate(1586,2,2), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime9(QDate(955,1,1), QTime(0,0,0,0), Qt::UTC); + QDateTime dateTime10(QDate(113,2,24), QTime(14,15,38,200), Qt::UTC); QQmlEngine eng; QQmlComponent component(&eng, testFileUrl("dateTimeConversion.qml")); @@ -493,6 +497,10 @@ void tst_qqmlqt::dateTimeConversion() QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4); QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5); QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6); + QCOMPARE(obj->property("qdatetime7").toDateTime(), dateTime7); + QCOMPARE(obj->property("qdatetime8").toDateTime(), dateTime8); + QCOMPARE(obj->property("qdatetime9").toDateTime(), dateTime9); + QCOMPARE(obj->property("qdatetime10").toDateTime(), dateTime10); } void tst_qqmlqt::dateTimeFormatting() diff --git a/tests/auto/qml/v4/data/conversions.1.qml b/tests/auto/qml/v4/data/conversions.1.qml new file mode 100644 index 0000000000..b3abde770a --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.1.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning bool prop to other proptypes. + boolProp: true + intProp: boolProp + floatProp: boolProp + doubleProp: boolProp + qrealProp: boolProp + qstringProp: boolProp + qurlProp: boolProp + vec3Prop: Qt.vector3d(boolProp, boolProp, boolProp) +} diff --git a/tests/auto/qml/v4/data/conversions.2.qml b/tests/auto/qml/v4/data/conversions.2.qml new file mode 100644 index 0000000000..2fd0453ac2 --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.2.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning int prop to other proptypes. + boolProp: intProp + intProp: 4 + floatProp: intProp + doubleProp: intProp + qrealProp: intProp + qstringProp: intProp + qurlProp: intProp + vec3Prop: Qt.vector3d(intProp, intProp, intProp) +} diff --git a/tests/auto/qml/v4/data/conversions.3.qml b/tests/auto/qml/v4/data/conversions.3.qml new file mode 100644 index 0000000000..66f0761a25 --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.3.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning float prop to other proptypes. + boolProp: floatProp + intProp: floatProp + floatProp: 4.4 + doubleProp: floatProp + qrealProp: floatProp + qstringProp: floatProp + qurlProp: floatProp + vec3Prop: Qt.vector3d(floatProp, floatProp, floatProp) +} diff --git a/tests/auto/qml/v4/data/conversions.4.qml b/tests/auto/qml/v4/data/conversions.4.qml new file mode 100644 index 0000000000..ccf0035313 --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.4.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning double prop to other prop types + boolProp: doubleProp + intProp: doubleProp + floatProp: doubleProp + doubleProp: 4.444444444 + qrealProp: doubleProp + qstringProp: doubleProp + qurlProp: doubleProp + vec3Prop: Qt.vector3d(doubleProp, doubleProp, doubleProp) +} diff --git a/tests/auto/qml/v4/data/conversions.5.qml b/tests/auto/qml/v4/data/conversions.5.qml new file mode 100644 index 0000000000..26dc3b7195 --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.5.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning qreal prop to other prop types + boolProp: qrealProp + intProp: qrealProp + floatProp: qrealProp + doubleProp: qrealProp + qrealProp: 4.44 + qstringProp: qrealProp + qurlProp: qrealProp + vec3Prop: Qt.vector3d(qrealProp, qrealProp, qrealProp) +} diff --git a/tests/auto/qml/v4/data/conversions.6.qml b/tests/auto/qml/v4/data/conversions.6.qml new file mode 100644 index 0000000000..573b227ada --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.6.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning string prop to other proptypes. + boolProp: qstringProp + intProp: qstringProp + floatProp: qstringProp + doubleProp: qstringProp + qrealProp: qstringProp + qstringProp: "4" + qurlProp: qstringProp + vec3Prop: Qt.vector3d(qstringProp, qstringProp, qstringProp) +} diff --git a/tests/auto/qml/v4/data/conversions.7.qml b/tests/auto/qml/v4/data/conversions.7.qml new file mode 100644 index 0000000000..5112b06b1e --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.7.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning url prop to other proptypes. + boolProp: qurlProp + intProp: qurlProp + floatProp: qurlProp + doubleProp: qurlProp + qrealProp: qurlProp + qstringProp: qurlProp + qurlProp: "4" + vec3Prop: Qt.vector3d(qurlProp, qurlProp, qurlProp) +} diff --git a/tests/auto/qml/v4/data/conversions.8.qml b/tests/auto/qml/v4/data/conversions.8.qml new file mode 100644 index 0000000000..18bf160e7e --- /dev/null +++ b/tests/auto/qml/v4/data/conversions.8.qml @@ -0,0 +1,13 @@ +import Qt.v4 1.0 + +Conversion { + // test assigning vector prop to other proptypes. + boolProp: vec3Prop + intProp: vec3Prop + floatProp: vec3Prop + doubleProp: vec3Prop + qrealProp: vec3Prop + qstringProp: vec3Prop + qurlProp: vec3Prop + vec3Prop: Qt.vector3d(4, 4, 4) +} diff --git a/tests/auto/qml/v4/data/subscriptions.1.qml b/tests/auto/qml/v4/data/subscriptions.1.qml new file mode 100644 index 0000000000..607233819e --- /dev/null +++ b/tests/auto/qml/v4/data/subscriptions.1.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 400 + height: 400 + + property real targetHeight: menuItems.height + 1 + property real heightValue: if (1) menuItems.height //this must be v8? + property bool boolProp: menuItems.height > heightValue //this must be v4? + + Column { + id: menuItems + Item { height: 200; width: 10 } + } +} diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/qml/v4/testtypes.cpp index c879cf2226..80ccf007a5 100644 --- a/tests/auto/qml/v4/testtypes.cpp +++ b/tests/auto/qml/v4/testtypes.cpp @@ -46,4 +46,5 @@ void registerTypes() { qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result"); qmlRegisterType<NestedObject>(); + qmlRegisterType<ConversionObject>("Qt.v4", 1, 0, "Conversion"); } diff --git a/tests/auto/qml/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h index 18b5b27b36..04dd82e8fe 100644 --- a/tests/auto/qml/v4/testtypes.h +++ b/tests/auto/qml/v4/testtypes.h @@ -42,6 +42,8 @@ #define TESTTYPES_H #include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QVector3D> class NestedObject : public QObject { @@ -80,6 +82,61 @@ private: NestedObject m_nested2; }; +class ConversionObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool boolProp READ boolProp WRITE setBoolProp NOTIFY boolPropChanged) + Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) + Q_PROPERTY(float floatProp READ floatProp WRITE setFloatProp NOTIFY floatPropChanged) + Q_PROPERTY(double doubleProp READ doubleProp WRITE setDoubleProp NOTIFY doublePropChanged) + Q_PROPERTY(qreal qrealProp READ qrealProp WRITE setQrealProp NOTIFY qrealPropChanged) + Q_PROPERTY(QString qstringProp READ qstringProp WRITE setQstringProp NOTIFY qstringPropChanged) + Q_PROPERTY(QUrl qurlProp READ qurlProp WRITE setQurlProp NOTIFY qurlPropChanged) + Q_PROPERTY(QVector3D vec3Prop READ vec3Prop WRITE setVec3Prop NOTIFY vec3PropChanged) + +public: + ConversionObject() : m_boolProp(false), m_intProp(0), m_floatProp(0.0), m_doubleProp(0.0), m_qrealProp(0.0) {} + ~ConversionObject() {} + + bool boolProp() const { return m_boolProp; } + void setBoolProp(bool v) { m_boolProp = v; emit boolPropChanged(); } + int intProp() const { return m_intProp; } + void setIntProp(int v) { m_intProp = v; emit intPropChanged(); } + float floatProp() const { return m_floatProp; } + void setFloatProp(float v) { m_floatProp = v; emit floatPropChanged(); } + double doubleProp() const { return m_doubleProp; } + void setDoubleProp(double v) { m_doubleProp = v; emit doublePropChanged(); } + qreal qrealProp() const { return m_qrealProp; } + void setQrealProp(qreal v) { m_qrealProp = v; emit qrealPropChanged(); } + QString qstringProp() const { return m_qstringProp; } + void setQstringProp(const QString& v) { m_qstringProp = v; emit qstringPropChanged(); } + QUrl qurlProp() const { return m_qurlProp; } + void setQurlProp(const QUrl& v) { m_qurlProp = v; emit qurlPropChanged(); } + QVector3D vec3Prop() const { return m_vec3Prop; } + void setVec3Prop(const QVector3D& v) { m_vec3Prop = v; emit vec3PropChanged(); } + +signals: + void boolPropChanged(); + void intPropChanged(); + void floatPropChanged(); + void doublePropChanged(); + void qrealPropChanged(); + void qstringPropChanged(); + void qurlPropChanged(); + void vec3PropChanged(); + +private: + bool m_boolProp; + int m_intProp; + float m_floatProp; + double m_doubleProp; + qreal m_qrealProp; + QString m_qstringProp; + QUrl m_qurlProp; + QVector3D m_vec3Prop; +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp index 47fa10b595..dfb7cc48c7 100644 --- a/tests/auto/qml/v4/tst_v4.cpp +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -46,6 +46,7 @@ #include <QtQml/qqmlcomponent.h> #include <QtCore/qdebug.h> #include <QtGui/qcolor.h> +#include <QtCore/qnumeric.h> #include <private/qv4compiler_p.h> @@ -83,6 +84,12 @@ private slots: void mathMin(); void moduleApi(); + void conversions_data(); + void conversions(); + void subscriptions(); + + void debuggingDumpInstructions(); // this test should be last. + private: QQmlEngine engine; }; @@ -135,6 +142,14 @@ void tst_v4::qtscript_data() QTest::newRow("unary minus") << "unaryMinus.qml"; QTest::newRow("null qobject") << "nullQObject.qml"; QTest::newRow("qobject -> bool") << "objectToBool.qml"; + QTest::newRow("conversion from bool") << "conversions.1.qml"; // QTBUG-24706 + QTest::newRow("conversion from int") << "conversions.2.qml"; // QTBUG-24706 + QTest::newRow("conversion from float") << "conversions.3.qml"; + QTest::newRow("conversion from double") << "conversions.4.qml"; // QTBUG-24706 + QTest::newRow("conversion from real") << "conversions.5.qml"; // QTBUG-24706 + QTest::newRow("conversion from string") << "conversions.6.qml"; // QTBUG-24706 + QTest::newRow("conversion from url") << "conversions.7.qml"; // QTBUG-24706 + QTest::newRow("conversion from vec3") << "conversions.8.qml"; } void tst_v4::unnecessaryReeval() @@ -630,6 +645,334 @@ void tst_v4::moduleApi() delete o; } +void tst_v4::conversions_data() +{ + QTest::addColumn<QUrl>("file"); + QTest::addColumn<QStringList>("warnings"); + QTest::addColumn<bool>("boolProp"); + QTest::addColumn<int>("intProp"); + QTest::addColumn<float>("floatProp"); + QTest::addColumn<double>("doubleProp"); + QTest::addColumn<qreal>("qrealProp"); + QTest::addColumn<QString>("qstringProp"); + QTest::addColumn<QUrl>("qurlProp"); + QTest::addColumn<QVector3D>("vec3Prop"); + + QTest::newRow("from bool") << testFileUrl("conversions.1.qml") + << (QStringList() << (testFileUrl("conversions.1.qml").toString() + QLatin1String(":11:15: Unable to assign bool to QUrl"))) + << true + << (int)true + << (float)1.0 + << (double)1.0 + << (qreal)1.0 + << QString(QLatin1String("true")) + << QUrl() // cannot assign bool to url. + << QVector3D(1, 1, 1); + + QTest::newRow("from integer") << testFileUrl("conversions.2.qml") + << (QStringList() << (testFileUrl("conversions.2.qml").toString() + QLatin1String(":11:15: Unable to assign int to QUrl"))) + << (bool)4 + << 4 + << (float)4.0 + << (double)4.0 + << (qreal)4.0 + << QString(QLatin1String("4")) + << QUrl() // cannot assign int to url. + << QVector3D(4, 4, 4); + + QTest::newRow("from float") << testFileUrl("conversions.3.qml") + << (QStringList() << (testFileUrl("conversions.3.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) + << (bool)4.4 + << (int)4.4 + << (float)4.4 + << (double)((float)4.4) + << (qreal)((float)4.4) + << QString::number((double)((float)4.4), 'g', 16) + << QUrl() // cannot assign number to url. + << QVector3D(4.4, 4.4, 4.4); + + QTest::newRow("from double") << testFileUrl("conversions.4.qml") + << (QStringList() << (testFileUrl("conversions.4.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) + << (bool)4.444444444 + << (int)4.444444444 + << (float)4.444444444 + << (double)4.444444444 + << (qreal)4.444444444 + << QString::number((double)4.444444444, 'g', 16) + << QUrl() // cannot assign number to url. + << QVector3D(4.444444444, 4.444444444, 4.444444444); + + QTest::newRow("from qreal") << testFileUrl("conversions.5.qml") + << (QStringList() << (testFileUrl("conversions.5.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) + << (bool)4.44 + << (int)4.44 + << (float)4.44 + << (double)4.44 + << (qreal)4.44 + << QString(QLatin1String("4.44")) + << QUrl() // cannot assign number to url. + << QVector3D(4.44, 4.44, 4.44); + + QTest::newRow("from string") << testFileUrl("conversions.6.qml") + << (QStringList()) + << true + << 4 + << (float)4.0 + << (double)4.0 + << (qreal)4.0 + << QString(QLatin1String("4")) + << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) + << QVector3D(4, 4, 4); + + // QTBUG-24706 + QTest::newRow("from url") << testFileUrl("conversions.7.qml") + << (QStringList() << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":6:14: Unable to assign QUrl to int")) + << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":7:16: Unable to assign QUrl to number")) + << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":8:17: Unable to assign QUrl to number")) + << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":9:16: Unable to assign QUrl to number"))) + << true + << 0 + << (float) 0 + << (double) 0 + << (qreal) 0 + << QString(testFileUrl("").toString() + QString(QLatin1String("4"))) + << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) + << QVector3D(qQNaN(), qQNaN(), qQNaN()); + + QTest::newRow("from vector") << testFileUrl("conversions.8.qml") + << (QStringList() << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":11: Unable to assign QVector3D to QUrl")) + << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":10: Unable to assign QVector3D to QString")) + << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":9: Unable to assign QVector3D to double")) + << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":8: Unable to assign QVector3D to double")) + << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":7: Unable to assign QVector3D to float")) + << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":6: Unable to assign QVector3D to int"))) + << true // non-null therefore true + << (int)0 // the other values should be the default-ctor values. + << (float)0 + << (double)0 + << (qreal)0 + << QString() + << QUrl() + << QVector3D(4, 4, 4); // except this one. +} + +#define COMPARE_NUMBER(type, prop, expected) \ + if (qIsNaN(expected)) \ + QVERIFY(qIsNaN(qvariant_cast<type>(prop))); \ + else \ + QCOMPARE((prop), QVariant::fromValue<type>(expected)); + +void tst_v4::conversions() +{ + QFETCH(QUrl, file); + QFETCH(QStringList, warnings); + QFETCH(bool, boolProp); + QFETCH(int, intProp); + QFETCH(float, floatProp); + QFETCH(double, doubleProp); + QFETCH(qreal, qrealProp); + QFETCH(QString, qstringProp); + QFETCH(QUrl, qurlProp); + QFETCH(QVector3D, vec3Prop); + + foreach (const QString &w, warnings) + QTest::ignoreMessage(QtWarningMsg, qPrintable(w)); + + QQmlComponent component(&engine, file); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("boolProp"), QVariant::fromValue<bool>(boolProp)); + QCOMPARE(o->property("intProp"), QVariant::fromValue<int>(intProp)); + COMPARE_NUMBER(float, o->property("floatProp"), floatProp); + COMPARE_NUMBER(double, o->property("doubleProp"), doubleProp); + COMPARE_NUMBER(qreal, o->property("qrealProp"), qrealProp); + QCOMPARE(o->property("qstringProp"), QVariant::fromValue<QString>(qstringProp)); + QCOMPARE(o->property("qurlProp"), QVariant::fromValue<QUrl>(qurlProp)); + + QVector3D vec3 = qvariant_cast<QVector3D>(o->property("vec3Prop")); + COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.x()), vec3Prop.x()); + COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.y()), vec3Prop.y()); + COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.z()), vec3Prop.z()); + delete o; +} + +void tst_v4::subscriptions() +{ + { + QQmlComponent component(&engine, testFileUrl("subscriptions.1.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QObject *ro = qobject_cast<QObject *>(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->property("targetHeight"), QVariant::fromValue<qreal>(201)); + + delete o; + } +} + +static QStringList messages; +static void msgHandler(QtMsgType, const char *msg) +{ + messages << QLatin1String(msg); +} + +static QByteArray getAddress(int address) +{ + return QByteArray::number(address); +} + +static QByteArray getLeading(int address) +{ + QByteArray leading; + if (address != -1) { + leading = getAddress(address); + leading.prepend(QByteArray(8 - leading.count(), ' ')); + } + return leading; +} + +#include <private/qv4instruction_p.h> +void tst_v4::debuggingDumpInstructions() +{ + QStringList expectedPreAddress; + expectedPreAddress << "\t\tNoop"; + expectedPreAddress << "\t0:0:"; + expectedPreAddress << "\t\tSubscribe\t\tObject_Reg(0) Notify_Signal(0) -> Subscribe_Slot(0)"; + expectedPreAddress << "\t\tSubscribeId\t\tId_Offset(0) -> Subscribe_Slot(0)"; + expectedPreAddress << "\t\tFetchAndSubscribe\tObject_Reg(0) Fast_Accessor(0x0) -> Output_Reg(0) Subscription_Slot(0)"; + expectedPreAddress << "\t\tLoadId\t\t\tId_Offset(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadScope\t\t-> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadRoot\t\t-> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadModuleObject\t\t) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadAttached\t\tObject_Reg(0) Attached_Index(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tUnaryNot\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tUnaryMinusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tUnaryMinusInt\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tUnaryPlusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tUnaryPlusInt\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertBoolToInt\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertBoolToNumber\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertBoolToString\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertIntToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertIntToNumber\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertIntToString\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNumberToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNumberToInt\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNumberToString\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToInt\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToNumber\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToUrl\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertStringToColor\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertUrlToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertUrlToString\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertColorToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertColorToString\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertObjectToBool\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tConvertNullToObject\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tResolveUrl\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathSinNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathCosNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathAbsNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathRoundNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathFloorNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathCeilNumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathPINumber\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadNull\t\tConstant(null) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadNumber\t\tConstant(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadInt\t\t\tConstant(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadBool\t\tConstant(false) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLoadString\t\tString_DataIndex(0) String_Length(0) -> Output_Register(0)"; + expectedPreAddress << "\t\tEnableV4Test\t\tString_DataIndex(0) String_Length(0)"; + expectedPreAddress << "\t\tTestV4Store\t\tInput_Reg(0) Reg_Type(0)"; + expectedPreAddress << "\t\tBitAndInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tBitOrInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tBitXorInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tAddNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tAddString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tSubNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMulNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tDivNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tModNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tRShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tURShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tGtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tGeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tNotEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictNotEqualNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tGtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tGeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tLeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tNotEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictNotEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tNotEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStrictNotEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathMaxNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tMathMinNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tNewString\t\tRegister(0)"; + expectedPreAddress << "\t\tNewUrl\t\t\tRegister(0)"; + expectedPreAddress << "\t\tCleanupRegister\t\tRegister(0)"; + expectedPreAddress << "\t\tCopy\t\t\tInput_Reg(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tFetch\t\t\tObject_Reg(0) Property_Index(0) -> Output_Reg(0)"; + expectedPreAddress << "\t\tStore\t\t\tInput_Reg(0) -> Object_Reg(0) Property_Index(0)"; + expectedPreAddress << "\t\tJump\t\t\tAddress(UNIT_TEST_JUMP_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->jump.count) + expectedPreAddress << "\t\tBranchTrue\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if true == Input_Reg(0)]"; //(address + size() + i->branchop.offset) + expectedPreAddress << "\t\tBranchFalse\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->branchop.offset) + expectedPreAddress << "\t\tBranch\t\t\tAddress(UNIT_TEST_BRANCH_ADDRESS)"; //(address + size() + i->branchop.offset) + expectedPreAddress << "\t\tBlock\t\t\tMask(0)"; + expectedPreAddress << "\t\tThrow\t\t\tInputReg(0)"; + expectedPreAddress << "\t\tInitString\t\tString_DataIndex(0) -> String_Slot(0)"; + QStringList expected; + + messages = QStringList(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QQmlJS::Bytecode bc; +#define DUMP_INSTR_IN_UNIT_TEST(I, FMT) { QQmlJS::V4InstrData<QQmlJS::V4Instr::I> i; memset(&i, 0, sizeof(i)); bc.append(i); } + FOR_EACH_V4_INSTR(DUMP_INSTR_IN_UNIT_TEST); +#undef DUMP_INSTR_IN_UNIT_TEST // NOTE: we memset in order to ensure stable output. + const char *start = bc.constData(); + const char *end = start + bc.size(); + const char *codeAddr = start; + int whichExpected = 0; +#define DUMP_INSTR_SIZE_IN_UNIT_TEST(I, FMT) { \ + QString currExpected = whichExpected < expectedPreAddress.size() ? expectedPreAddress.at(whichExpected++) : QString(); \ + currExpected.prepend(getLeading(codeAddr - start)); \ + expected.append(currExpected); \ + codeAddr += QQmlJS::V4Instr::size(static_cast<QQmlJS::V4Instr::Type>(QQmlJS::V4Instr::I)); \ + } + FOR_EACH_V4_INSTR(DUMP_INSTR_SIZE_IN_UNIT_TEST); +#undef DUMP_INSTR_SIZE_IN_UNIT_TEST // so that we generate the correct address for each instruction comparison + bc.dump(start, end); + + // ensure that the output was expected. + qInstallMsgHandler(old); + QCOMPARE(messages.count(), expected.count()); + for (int ii = 0; ii < messages.count(); ++ii) { + // Calculating the destination address of a null jump/branch instruction is tricky + // so instead we simply don't compare that part of those instructions. + QRegExp ignoreAddress("\\bAddress\\((\\w*)\\)"); + ignoreAddress.setMinimal(true); + QString expectOut = expected.at(ii); expectOut.replace(ignoreAddress, ""); + QString actualOut = messages.at(ii); actualOut.replace(ignoreAddress, ""); + QCOMPARE(actualOut, expectOut); + } +} + + QTEST_MAIN(tst_v4) #include "tst_v4.moc" diff --git a/tests/auto/qmltest/selftests/tst_datadriven.qml b/tests/auto/qmltest/selftests/tst_datadriven.qml new file mode 100644 index 0000000000..0686c12c00 --- /dev/null +++ b/tests/auto/qmltest/selftests/tst_datadriven.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Item { + TestCase { + name:"data-driven-empty-init-data" + property int tests:0; + property int init_data_called_times:0; + function init_data() {init_data_called_times++;} + function initTestCase() {tests = 0; init_data_called_times = 0;} + function cleanupTestCase() {compare(tests, 2); compare(init_data_called_times, 2);} + + function test_test1() {tests++;} + function test_test2() {tests++;} + } + TestCase { + name:"data-driven-no-init-data" + property int tests:0; + function initTestCase() {tests = 0;} + function cleanupTestCase() {compare(tests, 2);} + + function test_test1() {tests++;} + function test_test2() {tests++;} + } + TestCase { + name:"data-driven-init-data" + property int tests:0; + property int init_data_called_times:0; + function initTestCase() {tests = 0; init_data_called_times = 0;} + function cleanupTestCase() {compare(tests, 2); compare(init_data_called_times, 1);} + function init_data() {init_data_called_times++; return [{tag:"data1", data:"test data 1"}];} + + function test_test1(row) {tests++; compare(row.data, "test data 1");} + function test_test2_data() {return [{tag:"data2", data:"test data 2"}]; } + function test_test2(row) {tests++; compare(row.data, "test data 2");} + } +} diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro index c320fdad9e..d24fe80498 100644 --- a/tests/auto/quick/examples/examples.pro +++ b/tests/auto/quick/examples/examples.pro @@ -8,5 +8,3 @@ DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test #temporary QT += core-private gui-private qml-private quick-private v8-private testlib - -cross_compile: DEFINES += QTEST_CROSS_COMPILED diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 9a2a800cfd..b019c716b0 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -249,10 +249,6 @@ void tst_examples::sgexamples() { QFETCH(QString, file); -#if defined(QTEST_CROSS_COMPILED) - QSKIP("sources not available when cross compiled"); -#endif - QQmlComponent component(&engine, QUrl::fromLocalFile(file)); if (component.status() == QQmlComponent::Error) qWarning() << component.errors(); @@ -293,10 +289,6 @@ void tst_examples::sgsnippets() { QFETCH(QString, file); -#if defined(QTEST_CROSS_COMPILED) - QSKIP("sources not available when cross compiled"); -#endif - QQmlComponent component(&engine, QUrl::fromLocalFile(file)); if (component.status() == QQmlComponent::Error) qWarning() << component.errors(); diff --git a/tests/auto/quick/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml index a0821cfc4d..7cf1b707a0 100644 --- a/tests/auto/quick/qquickaccessible/data/statictext.qml +++ b/tests/auto/quick/qquickaccessible/data/statictext.qml @@ -10,6 +10,10 @@ Item { width: 200 height: 50 text : "Hello Accessibility" + + // Setting any value of the attached property + // makes an item accessible. + Accessible.name: text } Text { diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 48c07c6e2c..45a9d11c69 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -340,23 +340,25 @@ void tst_QQuickAccessible::hitTest() canvas->setSource(testFileUrl("hittest.qml")); canvas->show(); - QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); - QVERIFY(iface.data()); - QAI rootItem = QAI(iface->child(0)); + QAI canvasIface = QAI(QAccessible::queryAccessibleInterface(canvas)); + QVERIFY(canvasIface.data()); + QAI rootItem = QAI(canvasIface->child(0)); QRect rootRect = rootItem->rect(); - // hit the root item - QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50)); + // check the root item from app + QAI appIface = QAI(QAccessible::queryAccessibleInterface(qApp)); + QVERIFY(appIface); + QAI itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50)); QVERIFY(itemHit); QCOMPARE(rootRect, itemHit->rect()); // hit rect1 - QAI rect1(rootItem->child(1)); + QAI rect1(rootItem->child(0)); QRect rect1Rect = rect1->rect(); - itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); - QVERIFY(itemHit); - QCOMPARE(rect1Rect, itemHit->rect()); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1")); + QAI rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); + QVERIFY(rootItemIface); + QCOMPARE(rect1Rect, rootItemIface->rect()); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1")); // should also work from top level (app) QAI app(QAccessible::queryAccessibleInterface(qApp)); @@ -366,16 +368,20 @@ void tst_QQuickAccessible::hitTest() QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); // hit rect201 - QAI rect2(rootItem->child(2)); - QAI rect20(rect2->child(1)); - QAI rect201(rect20->child(2)); + QAI rect2(rootItem->child(1)); + QVERIFY(rect2); + // FIXME: This is seems broken on mac + // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100)); + QAI rect20(rect2->child(0)); + QVERIFY(rect20); + QAI rect201(rect20->child(1)); QVERIFY(rect201); QRect rect201Rect = rect201->rect(); - itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); - QVERIFY(itemHit); - QCOMPARE(itemHit->rect(), rect201Rect); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201")); + rootItemIface = QAI(canvasIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); + QVERIFY(rootItemIface); + QCOMPARE(rootItemIface->rect(), rect201Rect); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201")); delete canvas; } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml index c33901d294..10bc37e82d 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml @@ -43,7 +43,10 @@ Canvas { ctx.moveTo(100, 0); ctx.arc(100, 0, 150, (512+1/2)*Math.PI, (1024-1)*Math.PI, true); ctx.fill(); + /*FIXME: from: http://www.w3.org/TR/2dcontext/#dom-context-2d-arc + If the anticlockwise argument is omitted or false and endAngle-startAngle is equal to or greater than 2Ï€, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2Ï€, then the arc is the whole circumference of this circle. //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + */ } function test_angle_4() { var ctx = canvas.getContext('2d'); @@ -72,11 +75,10 @@ Canvas { ctx.moveTo(100, 0); ctx.arc(100, 0, 150, (1024-1)*Math.PI, (512+1/2)*Math.PI, false); ctx.fill(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ + /*FIXME: from: http://www.w3.org/TR/2dcontext/#dom-context-2d-arc + If the anticlockwise argument is omitted or false and endAngle-startAngle is equal to or greater than 2Ï€, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2Ï€, then the arc is the whole circumference of this circle. //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + */ } function test_angle_6() { @@ -108,11 +110,7 @@ Canvas { ctx.beginPath(); ctx.arc(200, 25, 5, 0, 2*Math.PI, true); ctx.stroke(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ - //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); } function test_nonempty() { var ctx = canvas.getContext('2d'); @@ -129,7 +127,6 @@ Canvas { verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); } function test_nonfinite() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); @@ -241,13 +238,13 @@ Canvas { verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); } function test_scale_2() { @@ -271,7 +268,7 @@ Canvas { verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_selfintersect_1() { @@ -288,8 +285,8 @@ Canvas { ctx.beginPath(); ctx.arc(0, 0, 25, 0, -Math.PI/2, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); } function test_selfintersect_2() { @@ -307,10 +304,10 @@ Canvas { ctx.arc(100, 0, 25, 0, -Math.PI/2, true); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); verify(Helper.comparePixel(ctx, 2,48, 0,255,0,255)); } @@ -325,12 +322,12 @@ Canvas { ctx.beginPath(); ctx.arc(50, 50, 50, 0, Math.PI, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_shape_2() { @@ -362,11 +359,11 @@ Canvas { ctx.beginPath(); ctx.arc(0, 50, 50, 0, -Math.PI/2, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_shape_4() { @@ -398,11 +395,11 @@ Canvas { ctx.beginPath(); ctx.arc(300, 0, 100, 0, 5*Math.PI, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_twopie() { @@ -416,7 +413,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -436,7 +433,8 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, true); ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + //FIXME:still different behavior from browsers, > 2pi span issue + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -460,7 +458,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 0, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -470,7 +468,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 0, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00' diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml index 84bfc1a8db..188d538d29 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml @@ -118,7 +118,7 @@ Canvas { ctx.beginPath(); ctx.arcTo(100, 50, 200, 50, 0.1); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -152,8 +152,6 @@ Canvas { var ctx = canvas.getContext('2d'); ctx.reset(); - skip("FIXME"); - ctx.moveTo(0, 0); ctx.lineTo(100, 0); ctx.arcTo(Infinity, 50, 0, 50, 0); @@ -221,7 +219,7 @@ Canvas { ctx.lineTo(-1000, 0); ctx.fill(); - skip("FIXME"); + //FIXME //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); @@ -332,7 +330,8 @@ Canvas { ctx.arcTo(200, 25, 200, 50, 10); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //FIXME + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); @@ -354,16 +353,15 @@ Canvas { ctx.lineTo(-100, 0); ctx.fill(); - skip("FIXME"); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); } function test_zero() { var ctx = canvas.getContext('2d'); diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 23d7b719ff..a70c798594 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -271,6 +271,7 @@ Rectangle { ctx = c.getContext('2D'); verify(ctx); compare(ctx.canvas, c); + ignoreWarning(Qt.resolvedUrl("tst_canvas.qml") + ":10:9: QML Canvas: Canvas already initialized with a different context type"); ctx = c.getContext('invalid'); verify(!ctx); c.destroy(); diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml index bdc9d37663..60c63ae04b 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml @@ -133,7 +133,6 @@ Canvas { } function test_solid() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = Qt.rgba(0, 1, 1, 1.0); @@ -230,7 +229,6 @@ Canvas { } function test_transparent() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -279,7 +277,8 @@ Canvas { ctx.globalCompositeOperation = 'lighter'; ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -325,7 +324,6 @@ Canvas { } function test_uncovered() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -334,7 +332,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -343,7 +342,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); @@ -354,7 +354,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -363,7 +364,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -372,7 +374,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_path.qml b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml index f72e5b9eaa..7c88106e5f 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_path.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml @@ -4,7 +4,6 @@ import "testhelper.js" as Helper Canvas { id:canvas; width:100;height:50; renderTarget: Canvas.Image; renderStrategy:Canvas.Threaded - smooth: false TestCase { name: "path"; when: windowShown @@ -102,7 +101,7 @@ Canvas { ctx.reset(); ctx.rect(20, 0, 20, 20); - //verify(ctx.isPointInPath(10, 10)); + verify(!ctx.isPointInPath(10, 10)); verify(ctx.isPointInPath(30, 10)); ctx.reset(); @@ -111,19 +110,19 @@ Canvas { verify(!ctx.isPointInPath(25, 30)); //verify(ctx.isPointInPath(30, 20)); verify(!ctx.isPointInPath(30, 30)); - //verify(!ctx.isPointInPath(40, 2)); + verify(!ctx.isPointInPath(40, 2)); //verify(ctx.isPointInPath(40, 20)); verify(!ctx.isPointInPath(40, 30)); verify(!ctx.isPointInPath(40, 47)); //verify(ctx.isPointInPath(45, 20)); - //verify(!ctx.isPointInPath(45, 30)); + verify(!ctx.isPointInPath(45, 30)); //verify(!ctx.isPointInPath(55, 20)); //verify(ctx.isPointInPath(55, 30)); - verify(!ctx.isPointInPath(60, 2)); + //verify(!ctx.isPointInPath(60, 2)); //verify(!ctx.isPointInPath(60, 20)); verify(ctx.isPointInPath(60, 30)); verify(!ctx.isPointInPath(60, 47)); - verify(!ctx.isPointInPath(70, 20)); + //verify(!ctx.isPointInPath(70, 20)); verify(ctx.isPointInPath(70, 30)); verify(!ctx.isPointInPath(75, 20)); verify(!ctx.isPointInPath(75, 30)); @@ -131,8 +130,8 @@ Canvas { ctx.reset(); ctx.arc(50, 25, 10, 0, 7, false); verify(!ctx.isPointInPath(50, 10)); - //verify(ctx.isPointInPath(50, 20)); - //verify(ctx.isPointInPath(50, 30)); + verify(ctx.isPointInPath(50, 20)); + verify(ctx.isPointInPath(50, 30)); verify(!ctx.isPointInPath(50, 40)); verify(!ctx.isPointInPath(30, 20)); verify(!ctx.isPointInPath(70, 20)); @@ -143,16 +142,16 @@ Canvas { ctx.rect(0, 0, 20, 20); verify(ctx.isPointInPath(0, 0)); verify(ctx.isPointInPath(10, 0)); - //verify(ctx.isPointInPath(20, 0)); - //verify(ctx.isPointInPath(20, 10)); - //verify(ctx.isPointInPath(20, 20)); - //verify(ctx.isPointInPath(10, 20)); - //verify(ctx.isPointInPath(0, 20)); + verify(ctx.isPointInPath(20, 0)); + verify(ctx.isPointInPath(20, 10)); + verify(ctx.isPointInPath(20, 20)); + verify(ctx.isPointInPath(10, 20)); + verify(ctx.isPointInPath(0, 20)); verify(ctx.isPointInPath(0, 10)); verify(!ctx.isPointInPath(10, -0.01)); verify(!ctx.isPointInPath(10, 20.01)); verify(!ctx.isPointInPath(-0.01, 10)); - //verify(!ctx.isPointInPath(20.01, 10)); + verify(!ctx.isPointInPath(20.01, 10)); ctx.reset(); verify(!ctx.isPointInPath(0, 0)); @@ -160,13 +159,13 @@ Canvas { ctx.reset(); ctx.rect(-100, -50, 200, 100); - //verify(ctx.isPointInPath(Infinity, 0)); - //verify(ctx.isPointInPath(-Infinity, 0)); - //verify(ctx.isPointInPath(NaN, 0)); - //verify(ctx.isPointInPath(0, Infinity)); - //verify(ctx.isPointInPath(0, -Infinity)); - //verify(ctx.isPointInPath(0, NaN)); - //verify(ctx.isPointInPath(NaN, NaN)); + verify(!ctx.isPointInPath(Infinity, 0)); + verify(!ctx.isPointInPath(-Infinity, 0)); + verify(!ctx.isPointInPath(NaN, 0)); + verify(!ctx.isPointInPath(0, Infinity)); + verify(!ctx.isPointInPath(0, -Infinity)); + verify(!ctx.isPointInPath(0, NaN)); + verify(!ctx.isPointInPath(NaN, NaN)); ctx.reset(); ctx.rect(0, -100, 20, 20); @@ -174,9 +173,9 @@ Canvas { verify(!ctx.isPointInPath(10, -110)); verify(ctx.isPointInPath(10, -90)); verify(!ctx.isPointInPath(10, -70)); - //verify(!ctx.isPointInPath(30, -20)); - //verify(ctx.isPointInPath(30, 0)); - //verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(30, -20)); + verify(ctx.isPointInPath(30, 0)); + verify(!ctx.isPointInPath(30, 20)); ctx.reset(); ctx.rect(0, 0, 20, 20); @@ -193,7 +192,7 @@ Canvas { ctx.rect(0, 0, 20, 20); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -203,7 +202,7 @@ Canvas { ctx.translate(50, 0); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -213,7 +212,7 @@ Canvas { ctx.rect(-70, 0, 20, 20); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -224,7 +223,7 @@ Canvas { ctx.lineTo(20, 20); ctx.lineTo(0, 20); verify(ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(30, 10)); + verify(!ctx.isPointInPath(30, 10)); ctx.reset(); ctx.moveTo(0, 0); @@ -279,8 +278,8 @@ Canvas { ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#000'; @@ -292,7 +291,7 @@ Canvas { ctx.rect(10, 10, 80, 30); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); + verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -310,7 +309,7 @@ Canvas { ctx.lineTo(0, 50); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -422,7 +421,7 @@ Canvas { ctx.arc(50, 25, 10, 0, 0, false); ctx.stroke(); - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; ctx.fillRect(0, 0, 100, 50); @@ -457,7 +456,8 @@ Canvas { ctx.lineTo(-100, 1000); ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //FIXME:lineJoin with miterLimit test fail! + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -564,15 +564,15 @@ Canvas { ctx.stroke(); ctx.restore(); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -611,14 +611,14 @@ Canvas { ctx.restore(); //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -847,7 +847,7 @@ Canvas { ctx.beginPath(); ctx.lineTo(100, 50); ctx.stroke(); - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -911,8 +911,8 @@ Canvas { ctx.beginPath(); ctx.bezierCurveTo(100, 50, 200, 50, 200, 50); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -923,7 +923,7 @@ Canvas { ctx.bezierCurveTo(0, 25, 100, 25, 100, 25); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); ctx.reset(); ctx.moveTo(0, 0); @@ -1035,11 +1035,11 @@ Canvas { ctx.moveTo(-2, 3.1); ctx.bezierCurveTo(-2, -1, 2.1, -1, 2.1, 3.1); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1078,8 +1078,8 @@ Canvas { ctx.beginPath(); ctx.quadraticCurveTo(100, 50, 200, 50); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1090,7 +1090,7 @@ Canvas { ctx.quadraticCurveTo(0, 25, 100, 25); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); ctx.reset(); ctx.moveTo(0, 0); @@ -1135,11 +1135,11 @@ Canvas { ctx.moveTo(-1, 1.05); ctx.quadraticCurveTo(0, -1, 1.2, 1.05); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1260,8 +1260,8 @@ Canvas { ctx.lineTo(0, 50); ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); ctx.reset(); @@ -1399,7 +1399,7 @@ Canvas { ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1416,7 +1416,7 @@ Canvas { ctx.rotate(Math.PI/2); ctx.scale(0.1, 0.1); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 2ed42e7f0f..f926dbe8f0 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -443,11 +443,14 @@ void tst_qquickflickable::movingAndDragging() // Vertical with a quick press-move-release: should cause a flick in release. QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged())); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); - QTest::qWait(10); - QTest::mouseMove(canvas, QPoint(50, 40)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 40)); + // Use something that generates a huge velocity just to make it testable. + // In practice this feature matters on touchscreen devices where the + // underlying drivers will hopefully provide a pre-calculated velocity + // (based on more data than what the UI gets), thus making this use case + // working even with small movements. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mouseMove(canvas, QPoint(50, 300), 10); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 100), 10); QCOMPARE(vFlickSpy.count(), 1); diff --git a/tests/auto/quick/qquickflipable/data/flip-flipable.qml b/tests/auto/quick/qquickflipable/data/flip-flipable.qml new file mode 100644 index 0000000000..4f22a0df6d --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/flip-flipable.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Flipable { + id: flipable + width: 640; height: 480 + property bool flipped: false + + front: Rectangle { color: "red"; anchors.fill: flipable } + back: Rectangle { color: "blue"; anchors.fill: flipable } + + transform: Rotation { + id: rotation + origin.x: flipable.width/2 + origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis + angle: 0 // the default angle + } + + states: State { + name: "back" + PropertyChanges { target: rotation; angle: 540 } + when: flipable.flipped + } + + transitions: Transition { + NumberAnimation { target: rotation; property: "angle"; duration: 500 } + } +} diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp index 4fe155168a..8c1c248925 100644 --- a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp +++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp @@ -58,6 +58,7 @@ private slots: void create(); void checkFrontAndBack(); void setFrontAndBack(); + void flipFlipable(); // below here task issues void QTBUG_9161_crash(); @@ -109,6 +110,20 @@ void tst_qquickflipable::setFrontAndBack() delete obj; } +void tst_qquickflipable::flipFlipable() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flip-flipable.qml")); + QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); + QVERIFY(obj != 0); + QVERIFY(obj->side() == QQuickFlipable::Front); + obj->setProperty("flipped", QVariant(true)); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + QTRY_VERIFY(obj->side() == QQuickFlipable::Front); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + delete obj; +} + void tst_qquickflipable::QTBUG_9161_crash() { QQuickView *canvas = new QQuickView; diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index c7b5ca6b40..22c9004ccc 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -2094,15 +2094,17 @@ void tst_QQuickGridView::componentChanges() QTRY_VERIFY(gridView); QQmlComponent component(canvas->engine()); - component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); QQmlComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); + QSignalSpy headerItemSpy(gridView, SIGNAL(headerItemChanged())); + QSignalSpy footerItemSpy(gridView, SIGNAL(footerItemChanged())); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); @@ -2114,10 +2116,15 @@ void tst_QQuickGridView::componentChanges() QTRY_COMPARE(gridView->header(), &component); QTRY_COMPARE(gridView->footer(), &component); + QVERIFY(gridView->headerItem()); + QVERIFY(gridView->footerItem()); + QTRY_COMPARE(highlightSpy.count(),1); QTRY_COMPARE(delegateSpy.count(),1); QTRY_COMPARE(headerSpy.count(),1); QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(headerItemSpy.count(),1); + QTRY_COMPARE(footerItemSpy.count(),1); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); @@ -2128,6 +2135,8 @@ void tst_QQuickGridView::componentChanges() QTRY_COMPARE(delegateSpy.count(),1); QTRY_COMPARE(headerSpy.count(),1); QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(headerItemSpy.count(),1); + QTRY_COMPARE(footerItemSpy.count(),1); delete canvas; } diff --git a/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml b/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml new file mode 100644 index 0000000000..0e50710717 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + FocusScope { + width: 400; height: 400 + focus: true + Item { + width: 400; height: 400 + Item { + id: dummy + objectName: "dummyItem" + focus: true + } + TextInput { + id: ti + objectName: "textInput" + focus: true + } + } + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index abd0da8ac1..a1377694e4 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -139,6 +139,9 @@ private slots: void addedToCanvas(); void changeParent(); void multipleFocusClears(); + void focusSubItemInNonFocusScope(); + void parentItemWithFocus(); + void reparentFocusedItem(); void constructor(); void setParentItem(); @@ -707,6 +710,7 @@ void tst_qquickitem::changeParent() focusState[item].set(true, true); focusState.active(item); FVERIFY(); + delete child2; } } @@ -720,6 +724,133 @@ void tst_qquickitem::multipleFocusClears() QTRY_VERIFY(QGuiApplication::focusWindow() == view); } +void tst_qquickitem::focusSubItemInNonFocusScope() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml")); + view->show(); + qApp->processEvents(); + + QQuickItem *dummyItem = view->rootObject()->findChild<QQuickItem *>("dummyItem"); + QVERIFY(dummyItem); + + QQuickItem *textInput = view->rootObject()->findChild<QQuickItem *>("textInput"); + QVERIFY(textInput); + + QVERIFY(dummyItem->hasFocus()); + QVERIFY(!textInput->hasFocus()); + QVERIFY(dummyItem->hasActiveFocus()); + + QVERIFY(QMetaObject::invokeMethod(textInput, "forceActiveFocus")); + + QVERIFY(!dummyItem->hasFocus()); + QVERIFY(textInput->hasFocus()); + QVERIFY(textInput->hasActiveFocus()); + + delete view; +} + +void tst_qquickitem::parentItemWithFocus() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + { + QQuickItem parent; + QQuickItem child; + + FocusState focusState; + focusState << &parent << &child; + FVERIFY(); + + parent.setFocus(true); + child.setFocus(true); + focusState[&parent].set(true, false); + focusState[&child].set(true, false); + FVERIFY(); + + child.setParentItem(&parent); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + FVERIFY(); + + parent.setParentItem(canvas.rootItem()); + focusState[&parent].set(true, true); + focusState[&child].set(false, false); + focusState.active(&parent); + FVERIFY(); + + child.forceActiveFocus(); + focusState[&parent].set(false, false); + focusState[&child].set(true, true); + focusState.active(&child); + FVERIFY(); + } { + QQuickItem parent; + QQuickItem child; + QQuickItem grandchild(&child); + + FocusState focusState; + focusState << &parent << &child << &grandchild; + FVERIFY(); + + parent.setFocus(true); + grandchild.setFocus(true); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(true, false); + FVERIFY(); + + child.setParentItem(&parent); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(false, false); + FVERIFY(); + + parent.setParentItem(canvas.rootItem()); + focusState[&parent].set(true, true); + focusState[&child].set(false, false); + focusState[&grandchild].set(false, false); + focusState.active(&parent); + FVERIFY(); + + grandchild.forceActiveFocus(); + focusState[&parent].set(false, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(true, true); + focusState.active(&grandchild); + FVERIFY(); + } +} + +void tst_qquickitem::reparentFocusedItem() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem parent(canvas.rootItem()); + QQuickItem child(&parent); + QQuickItem sibling(&parent); + QQuickItem grandchild(&child); + + FocusState focusState; + focusState << &parent << &child << &sibling << &grandchild; + FVERIFY(); + + grandchild.setFocus(true); + focusState[&parent].set(false, false); + focusState[&child].set(false, false); + focusState[&sibling].set(false, false); + focusState[&grandchild].set(true, true); + focusState.active(&grandchild); + FVERIFY(); + + // Parenting the item to another item within the same focus scope shouldn't change it's focus. + child.setParentItem(&sibling); + FVERIFY(); +} + void tst_qquickitem::constructor() { QQuickItem *root = new QQuickItem; diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 1218d3cfcb..1ef895d111 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2120,13 +2120,13 @@ void tst_QQuickListView::sectionsPositioning() QVERIFY(bottomItem); QCOMPARE(bottomItem->y(), 380.); - // Change current section + // Change current section, and verify case insensitive comparison listview->setContentY(10); model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "Two", "aaa"); - model.modifyItem(2, "Three", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Five", "aaa"); + model.modifyItem(1, "Two", "AAA"); + model.modifyItem(2, "Three", "aAa"); + model.modifyItem(3, "Four", "aaA"); + model.modifyItem(4, "Five", "Aaa"); QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); QTRY_COMPARE(listview->currentSection(), QString("aaa")); diff --git a/tests/auto/quick/qquickloader/data/RedRect.qml b/tests/auto/quick/qquickloader/data/RedRect.qml new file mode 100644 index 0000000000..0eec9b56b7 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/RedRect.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "red" + width: 100 + height: 100 + color: "red" +} diff --git a/tests/auto/quick/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml index 5c8c8348ed..ae8c0b8b30 100644 --- a/tests/auto/quick/qquickloader/data/implicitSize.qml +++ b/tests/auto/quick/qquickloader/data/implicitSize.qml @@ -3,12 +3,17 @@ import QtQuick 2.0 Rectangle { property real implWidth: 0 property real implHeight: 0 + function changeImplicitSize () { + loader.item.implicitWidth = 200 + loader.item.implicitHeight = 300 + } color: "green" width: loader.implicitWidth+50 height: loader.implicitHeight+50 Loader { id: loader + objectName: "loader" sourceComponent: Item { anchors.centerIn: parent diff --git a/tests/auto/quick/qquickloader/data/loadedSignal.2.qml b/tests/auto/quick/qquickloader/data/loadedSignal.2.qml new file mode 100644 index 0000000000..a4a663c71f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/loadedSignal.2.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + id: root + + width: 200 + height: 200 + + property bool success: true + property int loadCount: 0 + + Loader { + id: loader + anchors.fill: parent + asynchronous: true + active: false + source: "TestComponent.qml" + onLoaded: { + if (status !== Loader.Ready) { + root.success = false; + } + root.loadCount++; + } + } + + function triggerLoading() { + // we set source to a valid path (but which is an invalid / erroneous component) + // we should not get onLoaded, since the status should not be Ready. + loader.source = "GreenRect.qml" // causes reference error. + } +} diff --git a/tests/auto/quick/qquickloader/data/loadedSignal.qml b/tests/auto/quick/qquickloader/data/loadedSignal.qml new file mode 100644 index 0000000000..7cc0fed001 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/loadedSignal.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +Item { + id: root + + width: 200 + height: 200 + + property bool success: true + property int loadCount: 0 + + Loader { + id: loader + anchors.fill: parent + asynchronous: true + active: false + source: "TestComponent.qml" + onLoaded: { + if (status !== Loader.Ready) { + root.success = false; + } + root.loadCount++; + } + } + + function triggerLoading() { + // we set active to true, which triggers loading. + // we then immediately set active to false. + // this should clear the incubator and stop loading. + loader.active = true; + loader.active = false; + } + + function activate() { + loader.active = true; + } + + function deactivate() { + loader.active = false; + } + + function triggerMultipleLoad() { + loader.active = false; // deactivate as a precondition. + loader.source = "BlueRect.qml" + loader.active = true; // should trigger loading to begin + loader.source = "RedRect.qml"; // should clear the incubator and restart loading + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 01781f7b54..3bb06f737b 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -92,7 +92,7 @@ private slots: void noResize(); void networkRequestUrl(); void failNetworkRequest(); -// void networkComponent(); + void networkComponent(); void active(); void initialPropertyValues_data(); void initialPropertyValues(); @@ -111,6 +111,7 @@ private slots: void asynchronous(); void asynchronous_clear(); void simultaneousSyncAsync(); + void loadedSignal(); void parented(); void sizeBound(); @@ -442,21 +443,21 @@ void tst_QQuickLoader::networkRequestUrl() delete loader; } -/* XXX Component waits until all dependencies are loaded. Is this actually possible? +/* XXX Component waits until all dependencies are loaded. Is this actually possible? */ void tst_QQuickLoader::networkComponent() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("slowdata", TestHTTPServer::Delay); + server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQmlComponent component(&engine); component.setData(QByteArray( "import QtQuick 2.0\n" "import \"http://127.0.0.1:14450/\" as NW\n" "Item {\n" - " Component { id: comp; NW.SlowRect {} }\n" + " Component { id: comp; NW.Rect120x60 {} }\n" " Loader { sourceComponent: comp } }") - , dataDirectoryUrl()); + , dataDirectory()); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -472,7 +473,6 @@ void tst_QQuickLoader::networkComponent() delete loader; } -*/ void tst_QQuickLoader::failNetworkRequest() { @@ -842,6 +842,18 @@ void tst_QQuickLoader::implicitSize() QCOMPARE(item->property("implHeight").toReal(), 100.); QCOMPARE(item->property("implWidth").toReal(), 100.); + QQuickLoader *loader = item->findChild<QQuickLoader*>("loader"); + QSignalSpy implWidthSpy(loader, SIGNAL(implicitWidthChanged())); + QSignalSpy implHeightSpy(loader, SIGNAL(implicitHeightChanged())); + + QMetaObject::invokeMethod(item, "changeImplicitSize"); + + QCOMPARE(loader->property("implicitWidth").toReal(), 200.); + QCOMPARE(loader->property("implicitHeight").toReal(), 300.); + + QCOMPARE(implWidthSpy.count(), 1); + QCOMPARE(implHeightSpy.count(), 1); + delete item; } @@ -988,6 +1000,47 @@ void tst_QQuickLoader::simultaneousSyncAsync() delete root; } +void tst_QQuickLoader::loadedSignal() +{ + { + // ensure that triggering loading (by setting active = true) + // and then immediately setting active to false, causes the + // loader to be deactivated, including disabling the incubator. + QQmlComponent component(&engine, testFileUrl("loadedSignal.qml")); + QObject *obj = component.create(); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); // ensure that loading would have finished if it wasn't deactivated + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + QMetaObject::invokeMethod(obj, "triggerMultipleLoad"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 1); // only one loaded signal should be emitted. + QVERIFY(obj->property("success").toBool()); + + delete obj; + } + + { + // ensure that an error doesn't result in the onLoaded signal being emitted. + QQmlComponent component(&engine, testFileUrl("loadedSignal.2.qml")); + QObject *obj = component.create(); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + delete obj; + } +} + void tst_QQuickLoader::parented() { QQmlComponent component(&engine, testFileUrl("parented.qml")); diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index a4b04bb88a..f072b005bc 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -796,13 +796,11 @@ void tst_QQuickMouseArea::hoverVisible() mouseTracker->setVisible(true); - QTest::mouseMove(canvas,QPoint(10,31)); - QCOMPARE(mouseTracker->hovered(), true); QCOMPARE(enteredSpy.count(), 1); QEXPECT_FAIL("", "QTBUG-24282", Continue); - QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32)); + QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33)); delete canvas; } diff --git a/tests/auto/quick/qquickpathview/data/panels.qml b/tests/auto/quick/qquickpathview/data/panels.qml new file mode 100644 index 0000000000..a111e45736 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/panels.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + id: root + property bool snapOne: false + property bool enforceRange: false + width: 320; height: 480 + + VisualItemModel { + id: itemModel + + Rectangle { + width: root.width + height: root.height + color: "blue" + } + Rectangle { + width: root.width + height: root.height + color: "yellow" + } + Rectangle { + width: root.width + height: root.height + color: "green" + } + } + + PathView { + id: view + objectName: "view" + anchors.fill: parent + model: itemModel + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + flickDeceleration: 30 + highlightRangeMode: enforceRange ? PathView.StrictlyEnforceRange : PathView.NoHighlightRange + snapMode: root.snapOne ? PathView.SnapOneItem : PathView.SnapToItem + path: Path { + startX: -root.width; startY: root.height/2 + PathLine { x: root.width*2; y: root.height/2 } + } + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 85d2c3b6ea..fbe96bf672 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -125,6 +125,10 @@ private slots: void asynchronous(); void cancelDrag(); void maximumFlickVelocity(); + void snapToItem(); + void snapToItem_data(); + void snapOneItem(); + void snapOneItem_data(); }; class TestObject : public QObject @@ -1541,6 +1545,89 @@ void tst_QQuickPathView::maximumFlickVelocity() delete canvas; } +void tst_QQuickPathView::snapToItem() +{ + QFETCH(bool, enforceRange); + + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("panels.qml")); + QQuickPathView *pathview = canvas->rootObject()->findChild<QQuickPathView*>("view"); + QVERIFY(pathview != 0); + + canvas->rootObject()->setProperty("enforceRange", enforceRange); + QTRY_VERIFY(!pathview->isMoving()); // ensure stable + + int currentIndex = pathview->currentIndex(); + + QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged())); + + flick(canvas, QPoint(200,10), QPoint(10,10), 180); + + QVERIFY(pathview->isMoving()); + QTRY_VERIFY(!pathview->isMoving()); + + QVERIFY(pathview->offset() == qFloor(pathview->offset())); + + if (enforceRange) + QVERIFY(pathview->currentIndex() != currentIndex); + else + QVERIFY(pathview->currentIndex() == currentIndex); +} + +void tst_QQuickPathView::snapToItem_data() +{ + QTest::addColumn<bool>("enforceRange"); + + QTest::newRow("no enforce range") << false; + QTest::newRow("enforce range") << true; +} + +void tst_QQuickPathView::snapOneItem() +{ + QFETCH(bool, enforceRange); + + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("panels.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(canvas, qGuiApp->focusWindow()); + + QQuickPathView *pathview = canvas->rootObject()->findChild<QQuickPathView*>("view"); + QVERIFY(pathview != 0); + + canvas->rootObject()->setProperty("enforceRange", enforceRange); + + QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged())); + + canvas->rootObject()->setProperty("snapOne", true); + QVERIFY(snapModeSpy.count() == 1); + QTRY_VERIFY(!pathview->isMoving()); // ensure stable + + int currentIndex = pathview->currentIndex(); + + double startOffset = pathview->offset(); + flick(canvas, QPoint(200,10), QPoint(10,10), 180); + + QVERIFY(pathview->isMoving()); + QTRY_VERIFY(!pathview->isMoving()); + + // must have moved only one item + QCOMPARE(pathview->offset(), fmodf(3.0 + startOffset - 1.0, 3.0)); + + if (enforceRange) + QVERIFY(pathview->currentIndex() == currentIndex+1); + else + QVERIFY(pathview->currentIndex() == currentIndex); +} + +void tst_QQuickPathView::snapOneItem_data() +{ + QTest::addColumn<bool>("enforceRange"); + + QTest::newRow("no enforce range") << false; + QTest::newRow("enforce range") << true; +} QTEST_MAIN(tst_QQuickPathView) diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index ab24fbe995..ae2bdc7fae 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -636,7 +636,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) QQuickView *canvas = QQuickViewTestUtil::createView(); QQmlContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("enableAddTransition", false); + ctxt->setContextProperty("enableAddTransition", QVariant(false)); ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); diff --git a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp index 00ae8fc76d..1edf511ebf 100644 --- a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp +++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp @@ -257,13 +257,12 @@ void tst_qquickshadereffect::lookThroughShaderCode() if ((presenceFlags & TexCoordPresent) == 0) expected += "Warning: Missing reference to \'qt_MultiTexCoord0\'.\n"; if ((presenceFlags & MatrixPresent) == 0) - expected += "Warning: Missing reference to \'qt_Matrix\'.\n"; + expected += "Warning: Vertex shader is missing reference to \'qt_Matrix\'.\n"; if ((presenceFlags & OpacityPresent) == 0) - expected += "Warning: Missing reference to \'qt_Opacity\'.\n"; + expected += "Warning: Shaders are missing reference to \'qt_Opacity\'.\n"; item.setVertexShader(vertexShader); item.setFragmentShader(fragmentShader); - item.ensureCompleted(); QCOMPARE(item.parseLog(), expected); // If the uniform was successfully parsed, the notify signal has been connected to an update slot. diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index f4ba0864e5..724b24280a 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -1654,7 +1654,7 @@ void tst_qquicktext::implicitSizeBinding() QFETCH(QString, format); QString componentStr = "import QtQuick 2.0\nText { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + "; textFormat: " + format + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickText *textObject = qobject_cast<QQuickText *>(object.data()); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ab21f3bc54..dd9aa0acad 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -1999,15 +1999,16 @@ void tst_qquicktextedit::cursorDelegate() void tst_qquicktextedit::cursorVisible() { + QQuickTextEdit edit; + edit.componentComplete(); + QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit edit; - QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); - QCOMPARE(edit.isCursorVisible(), false); edit.setCursorVisible(true); @@ -2034,7 +2035,7 @@ void tst_qquicktextedit::cursorVisible() QCOMPARE(edit.isCursorVisible(), true); QCOMPARE(spy.count(), 5); - QQuickView alternateView; + QWindow alternateView; alternateView.show(); alternateView.requestActivateWindow(); QTest::qWaitForWindowShown(&alternateView); @@ -2046,6 +2047,47 @@ void tst_qquicktextedit::cursorVisible() QTest::qWaitForWindowShown(&view); QCOMPARE(edit.isCursorVisible(), true); QCOMPARE(spy.count(), 7); + + { // Cursor attribute with 0 length hides cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 8); + + { // Cursor attribute with non zero length shows cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 9); + + + { // If the cursor is hidden by the input method and the text is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 10); + + edit.setText("something"); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 11); + + { // If the cursor is hidden by the input method and the cursor position is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 12); + + edit.setCursorPosition(5); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 13); } void tst_qquicktextedit::delegateLoading_data() @@ -2568,7 +2610,7 @@ void tst_qquicktextedit::implicitSizeBinding() QFETCH(QString, wrap); QFETCH(QString, format); QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + "; textFormat: " + format + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data()); @@ -2682,6 +2724,74 @@ void tst_qquicktextedit::inputMethodComposing() } QCOMPARE(edit->isInputMethodComposing(), false); QCOMPARE(spy.count(), 2); + + // Changing the text while not composing doesn't alter the composing state. + edit->setText(text.mid(0, 16)); + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); + + { + QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>()); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 3); + + // Changing the text while composing cancels composition. + edit->setText(text.mid(0, 12)); + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 4); + + { // Preedit cursor positioned outside (empty) preedit; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, -2, 1, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Cursor hidden; composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Default cursor attributes; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Selections are persisted: not composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 2, 4, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 6); + + edit->setCursorPosition(0); + + { // Formatting applied; composing. + QTextCharFormat format; + format.setUnderlineStyle(QTextCharFormat::SingleUnderline); + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 2, 4, format)); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 7); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 8); } void tst_qquicktextedit::cursorRectangleSize() diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1c8bff9d69..4f2f3cbb62 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -158,9 +158,7 @@ private slots: void focusOutClearSelection(); void echoMode(); -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void passwordEchoDelay(); -#endif void geometrySignals(); void contentSize(); @@ -2368,16 +2366,16 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::cursorVisible() { + QQuickTextInput input; + input.componentComplete(); + QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput input; - input.componentComplete(); - QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); - QCOMPARE(input.isCursorVisible(), false); input.setCursorVisible(true); @@ -2404,7 +2402,7 @@ void tst_qquicktextinput::cursorVisible() QCOMPARE(input.isCursorVisible(), true); QCOMPARE(spy.count(), 5); - QQuickView alternateView; + QWindow alternateView; alternateView.show(); alternateView.requestActivateWindow(); QTest::qWaitForWindowShown(&alternateView); @@ -2416,6 +2414,46 @@ void tst_qquicktextinput::cursorVisible() QTest::qWaitForWindowShown(&view); QCOMPARE(input.isCursorVisible(), true); QCOMPARE(spy.count(), 7); + + { // Cursor attribute with 0 length hides cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 8); + + { // Cursor attribute with non zero length shows cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 9); + + { // If the cursor is hidden by the input method and the text is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 10); + + input.setText("something"); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 11); + + { // If the cursor is hidden by the input method and the cursor position is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 12); + + input.setCursorPosition(5); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 13); } void tst_qquicktextinput::cursorRectangle_data() @@ -2716,9 +2754,11 @@ void tst_qquicktextinput::echoMode() QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); } -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void tst_qquicktextinput::passwordEchoDelay() { + int maskDelay = qGuiApp->styleHints()->passwordMaskDelay(); + if (maskDelay <= 0) + QSKIP("No mask delay in use"); QQuickView canvas(testFileUrl("echoMode.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -2747,7 +2787,7 @@ void tst_qquicktextinput::passwordEchoDelay() QCOMPARE(input->displayText(), QString(4, fillChar)); QTest::keyPress(&canvas, '4'); QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); + QTest::qWait(maskDelay); QTRY_COMPARE(input->displayText(), QString(5, fillChar)); QTest::keyPress(&canvas, '5'); QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); @@ -2772,7 +2812,6 @@ void tst_qquicktextinput::passwordEchoDelay() QTest::keyPress(&canvas, Qt::Key_Backspace); QCOMPARE(input->displayText(), QString(8, fillChar)); } -#endif void tst_qquicktextinput::simulateKey(QWindow *view, int key) @@ -3281,6 +3320,75 @@ void tst_qquicktextinput::inputMethodComposing() } QCOMPARE(input->isInputMethodComposing(), false); QCOMPARE(spy.count(), 2); + + // Changing the text while not composing doesn't alter the composing state. + input->setText(text.mid(0, 16)); + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); + + { + QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>()); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 3); + + // Changing the text while composing cancels composition. + input->setText(text.mid(0, 12)); + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 4); + + { // Preedit cursor positioned outside (empty) preedit; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, -2, 1, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + + { // Cursor hidden; composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Default cursor attributes; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Selections are persisted: not composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, -5, 4, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 6); + + input->setCursorPosition(12); + + { // Formatting applied; composing. + QTextCharFormat format; + format.setUnderlineStyle(QTextCharFormat::SingleUnderline); + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, -5, 4, format)); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 7); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 8); } void tst_qquicktextinput::inputMethodUpdate() @@ -4949,7 +5057,7 @@ void tst_qquicktextinput::implicitSize() QFETCH(QString, text); QFETCH(QString, wrap); QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create()); @@ -4971,7 +5079,7 @@ void tst_qquicktextinput::implicitSizeBinding() QFETCH(QString, text); QFETCH(QString, wrap); QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data()); diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 73a35c1c78..78e9060acb 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -2707,9 +2707,6 @@ void tst_qquickvisualdatamodel::resolve_data() const QUrl stringListSource[] = { testFileUrl("stringlistproperties.qml"), testFileUrl("stringlistproperties-package.qml") }; - const QUrl objectListSource[] = { - testFileUrl("objectlistproperties.qml"), - testFileUrl("objectlistproperties-package.qml") }; for (int i = 0; i < 2; ++i) { // List Model. diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 654b1c86f0..b018fbf14a 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -1,12 +1,13 @@ TEMPLATE = subdirs PUBLICTESTS += \ - examples \ geometry \ nodes \ rendernode \ qquickpixmapcache +!cross_compile: PUBLICTESTS += examples + # This test requires the qtconcurrent module !contains(QT_CONFIG, concurrent):PUBLICTESTS -= qquickpixmapcache diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index d00a0e2a96..1c4319f82f 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -88,12 +88,8 @@ void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPo // send press, five equally spaced moves, and release. QTest::mousePress(canvas, Qt::LeftButton, 0, from); - for (int i = 0; i < pointCount; ++i) { - QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - QTest::qWait(duration/pointCount); - QCoreApplication::processEvents(); - } + for (int i = 0; i < pointCount; ++i) + QTest::mouseMove(canvas, from + (i+1)*diff/pointCount, duration / pointCount); QTest::mouseRelease(canvas, Qt::LeftButton, 0, to); QTest::qWait(50); |