From 12b7e6bfe5a8fb7666a929090483921c3f99ae8a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 15 Nov 2016 14:44:21 +0100 Subject: Fix reading of enum properties from gadgets QMetaProperty::type() maps an un-registered enum to QMetaType::Int, and so if a property cache is created for a gadget with enum properties, then their type will be int and we'll correctly read enum properties as ints in JavaScript. However if the enum is registered at the time we create the cache, then the property type will be the specific type and not QMetaType::Int. The property reading code in QV4::QObjectWrapper can deal with that, but the property reading code in the gadget value type wrapper code did not. [ChangeLog][Qt][Qml] Fix reading of enum properties from gadgets / value types when the enum was registered with qRegisterMetaType(). Change-Id: I7812b216a276dcc95c36e313507e1a1142250d0b Reviewed-by: Erik Verbruggen --- .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 04abe0bfcb..e82df79acb 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -94,6 +94,7 @@ private slots: void customValueTypeInQml(); void gadgetInheritance(); void toStringConversion(); + void enumProperties(); private: QQmlEngine engine; @@ -1652,6 +1653,39 @@ void tst_qqmlvaluetypes::toStringConversion() QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g)); } +struct GadgetWithEnum +{ + Q_GADGET +public: + + enum MyEnum { FirstValue, SecondValue }; + + Q_ENUM(MyEnum) + Q_PROPERTY(MyEnum enumProperty READ enumProperty) + + MyEnum enumProperty() const { return SecondValue; } +}; + +void tst_qqmlvaluetypes::enumProperties() +{ + QJSEngine engine; + + // When creating the property cache for the gadget when MyEnum is _not_ a registered + // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently + // property-read meta-calls will return an int (as expected in this test). However if we + // explicitly register the gadget, then QMetaProperty::type() will return the user-type + // and QQmlValueTypeWrapper should still handle that and return an integer/number for the + // enum property when it is read. + qRegisterMetaType(); + + GadgetWithEnum g; + QJSValue value = engine.toScriptValue(g); + + QJSValue enumValue = value.property("enumProperty"); + QVERIFY(enumValue.isNumber()); + QCOMPARE(enumValue.toInt(), int(g.enumProperty())); +} + QTEST_MAIN(tst_qqmlvaluetypes) -- cgit v1.2.3 From 835eac4ea0ded27c16e319177ef3087058808b0f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:06:01 +0100 Subject: QML: Change C++ benchmark to reflect QML benchmark The QQmlListReference will build a property cache entry, but it won't assign it to an engine when none is available (meaning: it would create the entry every time a QQmlListReference is created). QML won't do that, because it (obviously) has an engine available. Change-Id: I46eeaf3dffcb690902dd3d78be48c8509be6e84d Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/creation/tst_creation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index dbda07be5a..6c8d1eb21a 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -256,12 +256,13 @@ void tst_creation::itemtree_cpp() void tst_creation::itemtree_data_cpp() { + QQmlEngine engine; QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; QQmlGraphics_setParent_noEvent(child,item); - QQmlListReference ref(item, "data"); + QQmlListReference ref(item, "data", &engine); ref.append(child); } delete item; -- cgit v1.2.3 From 5718dac919c16e9c6c7b98043e1ecb74117af268 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:04:04 +0100 Subject: QML: Fix memory leak in a benchmark Change-Id: I64b671243a107c518da2000e2ffd964f441af037 Reviewed-by: Simon Hausmann Reviewed-by: Robin Burchell --- tests/benchmarks/qml/creation/tst_creation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 6c8d1eb21a..b9df0ca8b5 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -219,12 +219,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) void tst_creation::itemtree_notree_cpp() { + std::vector kids; + kids.resize(30); QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; - Q_UNUSED(child); + kids[i] = child; } + qDeleteAll(kids); delete item; } } -- cgit v1.2.3 From 1969991c4a4bd39ee224b0fa3c8cffa51f061757 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 1 Sep 2016 16:46:29 +0200 Subject: Fix binding re-evaluation when list model properties change This is a regression from commit 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e, which avoided returning an expensive QObject when calling get() but also lost the ability to perform binding captures when accessing the properties. This change restores the captures by performing them by hand in get() and also triggering the notifiers directly when the values change, without creating the QObject. Task-number: QTBUG-52356 Change-Id: Ia429ffafd4032b63d3e592aa63bb0864a24e0965 Reviewed-by: Michael Brasser Reviewed-by: Lars Knoll --- .../qml/qqmllistmodel/data/bindingsOnGetResult.qml | 27 ++++++++++++++++++++++ tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 13 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml new file mode 100644 index 0000000000..6bf750dcda --- /dev/null +++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property ListModel model: ListModel { + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + } + + property bool isModified: { + for (var i = 0; i < model.count; ++i) { + if (model.get(i).modified) + return true; + } + return false; + } + + property bool success: false + Component.onCompleted: { + // trigger read and setup of property captures + success = isModified + model.setProperty(0, "modified", true) + success = isModified + } +} diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 6b1deceaf2..8a90be601a 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -127,6 +127,7 @@ private slots: void datetime_data(); void about_to_be_signals(); void modify_through_delegate(); + void bindingsOnGetResult(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1474,6 +1475,18 @@ void tst_qqmllistmodel::modify_through_delegate() QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); } +void tst_qqmllistmodel::bindingsOnGetResult() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml")); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); + + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + + QVERIFY(obj->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" -- cgit v1.2.3 From c4ebe96c34c2179d0ebdc555afdce179e3de52e8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:16:09 +0100 Subject: Improved robustness of the optimizer when removing expressions For example during dead code elimination we may invalidate statements, but at the same time there may still be instances left in the work list of optimizeSSA(). When we encounter then, we should not process them any further. Task-number: QTBUG-56255 Change-Id: I4c24b1a225ce1bde112172e9606f91c426c19f19 Reviewed-by: Erik Verbruggen --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 6cbafbf055..781f3f93e4 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -197,6 +197,8 @@ private slots: void withNoContext(); void holeInPropertyData(); + void malformedExpression(); + signals: void testSignal(); }; @@ -3872,6 +3874,12 @@ void tst_QJSEngine::holeInPropertyData() QVERIFY(ok.toBool()); } +void tst_QJSEngine::malformedExpression() +{ + QJSEngine engine; + engine.evaluate("5%55555&&5555555\n7-0"); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3 From e579076bb36e6594003b2ade7f3d062944ef6f47 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 16 Nov 2016 14:22:36 +0100 Subject: Get rid of most QT_NO_FOO usages Instead use QT_CONFIG(foo). This change actually detected a few mis-spelled macros and invalid usages. Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85 Reviewed-by: Simon Hausmann --- .../tst_qqmlprofilerservice.cpp | 2 +- .../tst_qqmlapplicationengine.cpp | 6 +++--- .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 4 ++-- tests/auto/quick/examples/tst_examples.cpp | 2 +- tests/auto/quick/nokeywords/tst_nokeywords.cpp | 2 +- .../qquickborderimage/tst_qquickborderimage.cpp | 4 ++-- .../quick/qquickflickable/tst_qquickflickable.cpp | 2 +- .../qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp | 4 ++-- tests/auto/quick/qquickitem2/tst_qquickitem.cpp | 4 ++-- .../quick/qquickitemlayer/tst_qquickitemlayer.cpp | 6 +++--- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 6 +++--- .../qquickpainteditem/tst_qquickpainteditem.cpp | 4 ++-- .../qquickpixmapcache/tst_qquickpixmapcache.cpp | 10 +++++----- .../quick/qquicktextedit/tst_qquicktextedit.cpp | 14 +++++++------- .../quick/qquicktextinput/tst_qquicktextinput.cpp | 14 +++++++------- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 22 +++++++++++----------- tests/auto/quick/scenegraph/tst_scenegraph.cpp | 14 +++++++------- tests/auto/quick/shared/viewtestutil.cpp | 2 +- tests/auto/shared/platformquirks.h | 2 +- .../benchmarks/qml/compilation/tst_compilation.cpp | 2 +- 20 files changed, 63 insertions(+), 63 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index c4b17aa60a..692e70d7da 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -618,7 +618,7 @@ void tst_QQmlProfilerService::scenegraphData() // if the clocks are acting up. qint64 contextFrameTime = -1; qint64 renderFrameTime = -1; -#ifndef QT_NO_OPENGL //Software renderer doesn't have context frames +#if QT_CONFIG(opengl) //Software renderer doesn't have context frames foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) { if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) { diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index a401e04020..98b92e5fab 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -96,7 +96,7 @@ void tst_qqmlapplicationengine::application() Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; @@ -114,9 +114,9 @@ void tst_qqmlapplicationengine::application() QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); delete testProcess; QDir::setCurrent(srcDir); -#else // !QT_NO_PROCESS +#else // process QSKIP("No process support"); -#endif // QT_NO_PROCESS +#endif // process } void tst_qqmlapplicationengine::applicationProperties() diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 9e915ac451..163ce11cb8 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -323,7 +323,7 @@ void tst_qqmlvaluetypes::locale() QScopedPointer object(component.create()); QVERIFY(!object.isNull()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVERIFY(QQml_guiProvider()->inputMethod()); QInputMethod *inputMethod = qobject_cast(QQml_guiProvider()->inputMethod()); QLocale locale = inputMethod->locale(); @@ -350,7 +350,7 @@ void tst_qqmlvaluetypes::locale() } QCOMPARE(weekDays, locale.weekdays()); QCOMPARE(object->property("zeroDigit").toString().at(0), locale.zeroDigit()); -#endif // QT_NO_IM +#endif // im } } diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 872a71011d..1ca809c05f 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -103,7 +103,7 @@ tst_examples::tst_examples() excludedFiles << "views/visualdatamodel/slideshow.qml"; #endif -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) //No support for Particles excludedFiles << "examples/qml/dynamicscene/dynamicscene.qml"; excludedFiles << "examples/quick/animation/basics/color-animation.qml"; diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp index 6c94b484ae..ad77743ddd 100644 --- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp +++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp @@ -48,7 +48,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 5d242fab9e..71b0160c8e 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -76,7 +76,7 @@ private slots: void statusChanges_data(); void sourceSizeChanges(); void progressAndStatusChanges(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void borderImageMesh(); #endif @@ -583,7 +583,7 @@ void tst_qquickborderimage::progressAndStatusChanges() delete obj; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickborderimage::borderImageMesh() { QQuickView *window = new QQuickView; diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index b774481592..942e99018f 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1225,7 +1225,7 @@ void tst_qquickflickable::flickOnRelease() QTRY_VERIFY(!flickable->isMoving()); #ifdef Q_OS_MAC -# ifndef QT_NO_OPENGL +# if QT_CONFIG(opengl) QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue); # endif #endif diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp index 256fa43d2e..650892d650 100644 --- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp +++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp @@ -35,7 +35,7 @@ #include "../../shared/util.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #endif @@ -67,7 +67,7 @@ void tst_QQuickGraphicsInfo::testProperties() QCOMPARE(obj->property("api").toInt(), expectedAPI); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (expectedAPI == QSGRendererInterface::OpenGL) { QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL)); QVERIFY(view.openglContext()); diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 78322b44a1..cc74b7e07d 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -3133,7 +3133,7 @@ void tst_QQuickItem::parentLoop() { QQuickView *window = new QQuickView(0); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression msgRegexp = QRegularExpression("QQuickItem::setParentItem: Parent QQuickItem\\(.*\\) is already part of the subtree of QQuickItem\\(.*\\)"); QTest::ignoreMessage(QtWarningMsg, msgRegexp); #endif @@ -3304,7 +3304,7 @@ void tst_QQuickItem::grab() QVERIFY(root); QQuickItem *item = root->findChild("myItem"); QVERIFY(item); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) { // Default size (item is 100x100) QSharedPointer result = item->grabToImage(); QSignalSpy spy(result.data(), SIGNAL(ready())); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 2576a1b0fc..44310008d6 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -61,7 +61,7 @@ private slots: void initTestCase() Q_DECL_OVERRIDE; void layerEnabled(); void layerSmooth(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void layerMipmap(); void layerEffect(); #endif @@ -105,7 +105,7 @@ tst_QQuickItemLayer::tst_QQuickItemLayer() void tst_QQuickItemLayer::initTestCase() { QQmlDataTest::initTestCase(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QWindow window; QOpenGLContext context; window.setSurfaceType(QWindow::OpenGLSurface); @@ -177,7 +177,7 @@ void tst_QQuickItemLayer::layerEnabled() QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1)); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // The test draws a one pixel wide line and scales it down by more than a a factor 2 // If mipmpping works, the pixels should be gray, not white or black diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index f22528a8a0..e1f903123b 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -59,7 +59,7 @@ static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArr const QSize size = v.size(); const QPoint offset = QPoint(size.width() / 2, size.height() / 2); v.setFramePosition(screenGeometry.center() - offset); -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. if (moveMouseOut) QCursor::setPos(v.geometry().topRight() + QPoint(100, 100)); #else @@ -116,7 +116,7 @@ private slots: void pressedMultipleButtons_data(); void pressedMultipleButtons(); void changeAxis(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursorShape(); #endif void moveAndReleaseWithoutPress(); @@ -1692,7 +1692,7 @@ void tst_QQuickMouseArea::changeAxis() QCOMPARE(blackRect->y(), 94.0); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_QQuickMouseArea::cursorShape() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp index 44d7b40ed9..1716bdeafb 100644 --- a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp +++ b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp @@ -32,7 +32,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #else #include @@ -73,7 +73,7 @@ public: ++paintRequests; clipRect = painter->clipBoundingRect(); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { paintNode = static_cast(QQuickPaintedItem::updatePaintNode(oldNode, data)); diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp index 80c6c9e553..e854a109a1 100644 --- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -35,7 +35,7 @@ #include "testhttpserver.h" #include -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) #include #include #endif @@ -57,7 +57,7 @@ private slots: void massive(); void cancelcrash(); void shrinkcache(); -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void networkCrash(); #endif void lockingCrash(); @@ -105,7 +105,7 @@ void tst_qquickpixmapcache::initTestCase() QVERIFY2(server.listen(), qPrintable(server.errorString())); -#ifndef QT_NO_BEARERMANAGEMENT +#if QT_CONFIG(bearermanagement) // This avoids a race condition/deadlock bug in network config // manager when it is accessed by the HTTP server thread before // anything else. Bug report can be found at: @@ -372,7 +372,7 @@ void tst_qquickpixmapcache::shrinkcache() } } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void createNetworkServer(TestHTTPServer *server) { @@ -382,7 +382,7 @@ void createNetworkServer(TestHTTPServer *server) eventLoop.exec(); } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) // QT-3957 void tst_qquickpixmapcache::networkCrash() { diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 5d30cc8c94..765523316f 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -143,7 +143,7 @@ private slots: void cursorDelegateHeight(); void navigation(); void readOnly(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void canPaste(); void canPasteEmpty(); @@ -153,7 +153,7 @@ private slots: void inputMethodUpdate(); void openInputPanel(); void geometrySignals(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void pastingRichText_QTBUG_14003(); #endif void implicitSize_data(); @@ -2924,7 +2924,7 @@ void tst_qquicktextedit::navigation() QCOMPARE(input->hasActiveFocus(), false); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3001,7 +3001,7 @@ void tst_qquicktextedit::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -3019,7 +3019,7 @@ void tst_qquicktextedit::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -3037,7 +3037,7 @@ void tst_qquicktextedit::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3339,7 +3339,7 @@ void tst_qquicktextedit::geometrySignals() delete o; } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::pastingRichText_QTBUG_14003() { QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }"; diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 8dc3053d89..1451f8e2fc 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -145,7 +145,7 @@ private slots: void cursorRectangle(); void navigation(); void navigation_RTL(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void copyAndPasteKeySequence(); void canPasteEmpty(); @@ -2532,7 +2532,7 @@ void tst_qquicktextinput::navigation_RTL() QVERIFY(input->hasActiveFocus()); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2630,7 +2630,7 @@ void tst_qquicktextinput::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPasteKeySequence() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2698,7 +2698,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -2714,7 +2714,7 @@ void tst_qquicktextinput::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -2730,7 +2730,7 @@ void tst_qquicktextinput::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3052,7 +3052,7 @@ void tst_qquicktextinput::cursorRectangle_data() << false; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) #define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \ QCOMPARE((type) input->inputMethodQuery(property).method(), result); #else diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index acccac8eca..8d021d92da 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -284,7 +284,7 @@ public: private slots: void cleanup(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void openglContextCreatedSignal(); #endif void aboutToStopSignal(); @@ -350,7 +350,7 @@ private slots: void qobjectEventFilter_key(); void qobjectEventFilter_mouse(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursor(); #endif @@ -373,14 +373,14 @@ private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_DECLARE_METATYPE(QOpenGLContext *); #endif void tst_qquickwindow::cleanup() { QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickwindow::openglContextCreatedSignal() { qRegisterMetaType(); @@ -1327,7 +1327,7 @@ void tst_qquickwindow::headless() if (isGL) QVERIFY(!window->isSceneGraphInitialized()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (QGuiApplication::platformName() == QLatin1String("windows") && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { QSKIP("Crashes on Windows/ANGLE, QTBUG-42967"); @@ -1515,7 +1515,7 @@ void tst_qquickwindow::ownershipRootItem() QVERIFY(!accessor->isRootItemDestroyed()); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_qquickwindow::cursor() { QQuickWindow window; @@ -1688,7 +1688,7 @@ void tst_qquickwindow::hideThenDelete() QTest::qWaitForWindowExposed(&window); const bool threaded = QQuickWindowPrivate::get(&window)->context->thread() != QGuiApplication::instance()->thread(); const bool isGL = window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (isGL) openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); #endif @@ -1717,7 +1717,7 @@ void tst_qquickwindow::hideThenDelete() } QVERIFY(sgInvalidated->size() > 0); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (openglDestroyed) QVERIFY(openglDestroyed->size() > 0); #endif @@ -2128,7 +2128,7 @@ void tst_qquickwindow::defaultSurfaceFormat() QCOMPARE(format.profile(), reqFmt.profile()); QCOMPARE(int(format.options()), int(reqFmt.options())); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Depth and stencil should be >= what has been requested. For real. But use // the context since the window's surface format is only partially updated // on most platforms. @@ -2183,7 +2183,7 @@ public: } static int deleted; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class GlRenderJob : public QRunnable { public: @@ -2254,7 +2254,7 @@ void tst_qquickwindow::testRenderJob() QTRY_COMPARE(RenderJob::deleted, 1); QCOMPARE(completedJobs.size(), 1); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) { // Do a synchronized GL job. GLubyte readPixel[4] = {0, 0, 0, 0}; diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index f6d624d871..2cd3a041c8 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -28,7 +28,7 @@ #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include @@ -37,7 +37,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #endif @@ -105,7 +105,7 @@ private slots: void render_data(); void render(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void hideWithOtherContext(); #endif void createTextureFromImage_data(); @@ -130,7 +130,7 @@ void tst_SceneGraph::initTestCase() QSGRenderLoop *loop = QSGRenderLoop::instance(); qDebug() << "RenderLoop: " << loop; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext context; context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); context.create(); @@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows_data() QTest::newRow("rects,subwindow,sharing") << QStringLiteral("manyWindows_rects.qml") << false << true; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) struct ShareContextResetter { public: ~ShareContextResetter() { qt_gl_set_global_share_context(0); } @@ -234,7 +234,7 @@ void tst_SceneGraph::manyWindows() QFETCH(QString, file); QFETCH(bool, toplevel); QFETCH(bool, shared); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext sharedGLContext; ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure. if (shared) { @@ -479,7 +479,7 @@ void tst_SceneGraph::render() } } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Testcase for QTBUG-34898. We make another context current on another surface // in the GUI thread and hide the QQuickWindow while the other context is // current on the other window. diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index ab58aee648..cb2b8be97a 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -61,7 +61,7 @@ void QQuickViewTestUtil::centerOnScreen(QQuickView *window) void QQuickViewTestUtil::moveMouseAway(QQuickView *window) { -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); #else Q_UNUSED(window) diff --git a/tests/auto/shared/platformquirks.h b/tests/auto/shared/platformquirks.h index 5e4929230a..5252e8cfe2 100644 --- a/tests/auto/shared/platformquirks.h +++ b/tests/auto/shared/platformquirks.h @@ -39,7 +39,7 @@ struct PlatformQuirks { static inline bool isClipboardAvailable() { -#if defined(QT_NO_CLIPBOARD) +#if !QT_CONFIG(clipboard) return false; #elif defined(Q_OS_OSX) PasteboardRef pasteboard; diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 690e193b53..61339c6f60 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -75,7 +75,7 @@ void tst_compilation::boomblock() QQmlComponent c(&engine); c.setData(data, QUrl()); } -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) QSKIP("boomblock imports Particles which requires OpenGL Support"); #endif QBENCHMARK { -- cgit v1.2.3 From 6ed23b91b949b7edaf96cdb0f2bba7b21a02de89 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Nov 2016 14:45:46 +0100 Subject: Fix support for namespaced types in property/signal declarations Declarations such as property Namespace.Item foo or property list foo would get rejected by the grammar due to the lack of productions. This is now encapsulated in the UiPropertyType, which used to be merely an identifier but is now changed to produce a UiQualifiedId - the same type that's also used for MyNamespace.Item { ... } object declarations for example. Task-number: QTBUG-10822 Change-Id: Ic3ac1adbe17c83b24b67950c2f089e267b73b99b Reviewed-by: Lars Knoll --- tests/auto/qml/qmlmin/tst_qmlmin.cpp | 1 - tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml | 2 +- tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml | 8 ++++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 10 +++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml (limited to 'tests') diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 7e4a643ffa..3ed0aa7446 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -86,7 +86,6 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; - invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml"; diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml index 319e1f5bc5..f028e5dcac 100644 --- a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml +++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtQuick 2.0 as Qt47 -Qt.QtObject { +Qt47.QtObject { property Qt47.QtObject objectProperty property list objectPropertyList diff --git a/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml new file mode 100644 index 0000000000..5ad62edab3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 as MyQuick + +MyQuick.Item { + property MyQuick.Item myProp; + property list myList; + default property list myDefaultList; + signal mySignal(MyQuick.Item someItem) +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 658b4f5852..f586f7d429 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -255,6 +255,7 @@ private slots: void arrayBuffer(); void defaultListProperty(); + void namespacedPropertyTypes(); private: QQmlEngine engine; @@ -1397,7 +1398,6 @@ void tst_qqmllanguage::dynamicObjectProperties() } { QQmlComponent component(&engine, testFileUrl("dynamicObjectProperties.2.qml")); - QEXPECT_FAIL("", "QTBUG-10822", Abort); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -4242,6 +4242,14 @@ void tst_qqmllanguage::defaultListProperty() QScopedPointer o(component.create()); } +void tst_qqmllanguage::namespacedPropertyTypes() +{ + QQmlComponent component(&engine, testFileUrl("namespacedPropertyTypes.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From b19ebe1d23e1f2fd334cef4ec2731ab5cc69dbd7 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 22 Nov 2016 12:26:54 +0100 Subject: Fix SignalSpy with QQmlPropertyMap signals 2e7d4ecdc59942b484159ca827f5d5dbc8787a1b caused the regression. To fix the regression I try accessing the signal name first and if it is not a function try accessing the handler name. Comes with a unit test to test both cases. Change-Id: I3897f344df9c6219636c70259eed503d9b76f09e Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann --- tests/auto/auto.pro | 1 + tests/auto/quicktest/quicktest.pro | 3 + tests/auto/quicktest/signalspy/data/signalspy.qml | 60 ++++++++++++++ tests/auto/quicktest/signalspy/mypropertymap.cpp | 38 +++++++++ tests/auto/quicktest/signalspy/mypropertymap.h | 41 ++++++++++ tests/auto/quicktest/signalspy/signalspy.pro | 9 +++ tests/auto/quicktest/signalspy/tst_signalspy.cpp | 95 +++++++++++++++++++++++ 7 files changed, 247 insertions(+) create mode 100644 tests/auto/quicktest/quicktest.pro create mode 100644 tests/auto/quicktest/signalspy/data/signalspy.qml create mode 100644 tests/auto/quicktest/signalspy/mypropertymap.cpp create mode 100644 tests/auto/quicktest/signalspy/mypropertymap.h create mode 100644 tests/auto/quicktest/signalspy/signalspy.pro create mode 100644 tests/auto/quicktest/signalspy/tst_signalspy.cpp (limited to 'tests') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 556f5ddc7a..f25742fb14 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs SUBDIRS=\ qml \ quick \ + quicktest \ qmltest \ qmldevtools \ cmake \ diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro new file mode 100644 index 0000000000..3b4ec23a64 --- /dev/null +++ b/tests/auto/quicktest/quicktest.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + signalspy diff --git a/tests/auto/quicktest/signalspy/data/signalspy.qml b/tests/auto/quicktest/signalspy/data/signalspy.qml new file mode 100644 index 0000000000..6c365e296a --- /dev/null +++ b/tests/auto/quicktest/signalspy/data/signalspy.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.1 +import MyImport 1.0 + +Rectangle { + id:rect + width: 200 + height: 200 + color:"red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + MyPropertyMap { + id: propertyMap + objectName: "propertyMap" + } + + SignalSpy { + objectName: "mouseSpy" + target: mouseArea + signalName: "pressed" + } + + SignalSpy { + objectName: "propertyMapSpy" + target: propertyMap + signalName: "mySignal" + } +} diff --git a/tests/auto/quicktest/signalspy/mypropertymap.cpp b/tests/auto/quicktest/signalspy/mypropertymap.cpp new file mode 100644 index 0000000000..91bd93dde0 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mypropertymap.h" + +MyPropertyMap::MyPropertyMap(QObject *parent): QQmlPropertyMap(this, parent) +{ +} + +MyPropertyMap::~MyPropertyMap() +{ +} + diff --git a/tests/auto/quicktest/signalspy/mypropertymap.h b/tests/auto/quicktest/signalspy/mypropertymap.h new file mode 100644 index 0000000000..d69548fe88 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class MyPropertyMap : public QQmlPropertyMap +{ + Q_OBJECT + +public: + MyPropertyMap(QObject *parent = nullptr); + ~MyPropertyMap(); + +Q_SIGNALS: + void mySignal(); +}; diff --git a/tests/auto/quicktest/signalspy/signalspy.pro b/tests/auto/quicktest/signalspy/signalspy.pro new file mode 100644 index 0000000000..c8f9be1f36 --- /dev/null +++ b/tests/auto/quicktest/signalspy/signalspy.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_signalspy +macos:CONFIG -= app_bundle + +SOURCES += tst_signalspy.cpp mypropertymap.cpp +HEADERS += mypropertymap.h +QT += quick testlib + +include (../../shared/util.pri) diff --git a/tests/auto/quicktest/signalspy/tst_signalspy.cpp b/tests/auto/quicktest/signalspy/tst_signalspy.cpp new file mode 100644 index 0000000000..f54da7819c --- /dev/null +++ b/tests/auto/quicktest/signalspy/tst_signalspy.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +#include "../../shared/util.h" +#include "mypropertymap.h" + +class tst_SignalSpy : public QQmlDataTest +{ + Q_OBJECT +public: + tst_SignalSpy(); + +private slots: + void testValid(); + void testCount(); + +private: + QQmlEngine engine; +}; + +tst_SignalSpy::tst_SignalSpy() +{ + qmlRegisterType("MyImport", 1, 0, "MyPropertyMap"); +} + +void tst_SignalSpy::testValid() +{ + QQuickView window; + window.setSource(testFileUrl("signalspy.qml")); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild("mouseSpy"); + QVERIFY(mouseSpy->property("valid").toBool()); + + QObject *propertyMapSpy = window.rootObject()->findChild("propertyMapSpy"); + QVERIFY(propertyMapSpy->property("valid").toBool()); +} + +void tst_SignalSpy::testCount() +{ + QQuickView window; + window.resize(200, 200); + window.setSource(testFileUrl("signalspy.qml")); + window.show(); + QTest::qWaitForWindowActive(&window); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild("mouseSpy"); + QCOMPARE(mouseSpy->property("count").toInt(), 0); + + QObject *propertyMapSpy = window.rootObject()->findChild("propertyMapSpy"); + QCOMPARE(propertyMapSpy->property("count").toInt(), 0); + + QTest::mouseClick(&window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 100)); + QTRY_COMPARE(mouseSpy->property("count").toInt(), 1); + + MyPropertyMap *propertyMap = static_cast(window.rootObject()->findChild("propertyMap")); + Q_EMIT propertyMap->mySignal(); + QCOMPARE(propertyMapSpy->property("count").toInt(), 1); +} + +QTEST_MAIN(tst_SignalSpy) + +#include "tst_signalspy.moc" -- cgit v1.2.3 From 92ba955a84c733422c02090602f7053260a8301e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2016 15:48:52 +0100 Subject: Remove reference to trusted-benchmarks.pri It appears to be legacy that is no longer found. Change-Id: Id7fa8555e32d917da617100fb8720a18eab69ae1 Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/qml.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro index 2cf2dff413..f1fe87e532 100644 --- a/tests/benchmarks/qml/qml.pro +++ b/tests/benchmarks/qml/qml.pro @@ -14,5 +14,3 @@ SUBDIRS += \ creation qtHaveModule(opengl): SUBDIRS += painting qquickwindow - -include(../trusted-benchmarks.pri) -- cgit v1.2.3 From aabeeda52c3b4d2e3327bfd00642d2d7c980719b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2016 15:47:36 +0100 Subject: Build benchmarks only in release mode Otherwise, a debug build will fail due to not find the release mode libraries: LINK : fatal error LNK1181: cannot open input file 'D:\dev\5-vs15-58-static\qt-58s\qtbase\lib\Qt5Gui.lib' Change-Id: I1b942db5ad0cf5fb3a949f9d39b8cf55a2dbd69a Reviewed-by: Robin Burchell Reviewed-by: Simon Hausmann --- tests/tests.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tests.pro b/tests/tests.pro index f5731b2f34..ab94786b31 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += auto benchmarks +SUBDIRS += auto +contains(QT_CONFIG, release): SUBDIRS += benchmarks -- cgit v1.2.3 From 8a6383775a301c8dd8c917a936655c534932a726 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Nov 2016 15:33:48 +0100 Subject: Start cleaning up the QmlContextWrapper The class should get merged with the QV4::QmlContext class. Simplify the cleanup by moving both classes into a common file. Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 1 + tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 723f575330..690b1cdf24 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "../../shared/util.h" #include "testhttpserver.h" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index be04ec2bf3..c3845178a7 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "testtypes.h" #include "testhttpserver.h" #include "../../shared/util.h" -- cgit v1.2.3 From f2a9579375bf5ae6f70747b9209082e504a16397 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Nov 2016 16:04:01 +0100 Subject: Inline the qmlScope and urlScope methods They are only a couple of lines and used only in one place. Change-Id: Iee9139e78d5d7fd385cae39d6dd5fad7e5d461b5 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c3845178a7..88a8886ecb 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3986,7 +3986,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { { QV4::Scope scope(QV8Engine::getV4((engine))); - QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(scope.engine, scriptContext, 0)); + QV4::ScopedContext temporaryScope(scope, QV4::QmlContext::create(scope.engine->rootContext(), scriptContext, 0)); Q_UNUSED(temporaryScope) } -- cgit v1.2.3 From e31e72925f857be56c77b494c0fa10e55de72cfc Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Nov 2016 14:58:48 +0100 Subject: Cleanup and reduce the number of overloads for QQmlBinding::create() Change-Id: Ibcd277bc434638e5c6e8e9ccea634aa25cde1643 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 1 + tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 26 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 690b1cdf24..f2b0b9973e 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index fe73610bcc..385ffc523a 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -157,7 +157,7 @@ void tst_qqmlproperty::qmlmetaproperty() QObject *obj = new QObject; - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -399,7 +399,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&object); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -447,7 +447,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&dobject); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -504,7 +504,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&object, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -552,7 +552,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -603,7 +603,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onClicked")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -653,7 +653,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -709,7 +709,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&object, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -757,7 +757,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&dobject, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -814,7 +814,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -862,7 +862,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -913,7 +913,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -963,7 +963,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); -- cgit v1.2.3 From 260f45d539b3ec1b28f593706ce7c164836f814c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 30 Nov 2016 10:29:06 +0100 Subject: tst_QQuickPathView, tst_QQuickListView: Fix compiler warnings Fix warnings about assignment used as truth value in Q[TRY_]VERIFY by generally pulling out the assignment in case of QVERIFY and adding parentheses in case of QTRY_VERIFY. Also fix 2 cases in which apparently QTRY_VERIFY(find()) was intended. Fixes warnings: tst_qquickpathview.cpp: In member function 'void tst_QQuickPathView::creationContext()': tst_qquickpathview.cpp:1637:100: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp: In member function 'void tst_QQuickPathView::currentOffsetOnInsertion()': tst_qquickpathview.cpp:1688:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp:1700:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp:1712:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::sectionsPositioning()': tst_qquicklistview.cpp:2392:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::itemListFlicker()': tst_qquicklistview.cpp:2979:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2981:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2983:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2988:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2990:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2992:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2997:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2999:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:3001:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::creationContext()': tst_qquicklistview.cpp:5339:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5341:98: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5343:98: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5345:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::unrequestedVisibility()': tst_qquicklistview.cpp:5626:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5628:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5631:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5633:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5636:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5638:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5640:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5642:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5650:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5652:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5663:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5665:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5668:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5670:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5673:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5675:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5677:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5679:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5687:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5690:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5692:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5695:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5697:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5699:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5701:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5707:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5709:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5711:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5713:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5719:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5721:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5723:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5725:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5731:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5733:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5735:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5737:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5743:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5745:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5747:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5749:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::displayMargin()': tst_qquicklistview.cpp:7255:100: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7259:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::negativeDisplayMargin()': tst_qquicklistview.cpp:7292:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7295:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7298:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7303:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] Change-Id: Ic069c8336cf15db75860c6f79dfd215a5592ca79 Reviewed-by: Robin Burchell --- .../quick/qquicklistview/tst_qquicklistview.cpp | 218 +++++++++++++-------- .../quick/qquickpathview/tst_qquickpathview.cpp | 13 +- 2 files changed, 144 insertions(+), 87 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index b0d903908f..61ba2caaf7 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2373,7 +2373,7 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header + QTRY_VERIFY((topItem = findVisibleChild(contentItem, "sect_aaa"))); // section header QCOMPARE(topItem->y(), 10.); // remove section boundary @@ -2389,7 +2389,8 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QVERIFY(topItem = findVisibleChild(contentItem, "sect_1")); + topItem = findVisibleChild(contentItem, "sect_1"); + QVERIFY(topItem); QTRY_COMPARE(topItem->y(), 120.); // Change the next section @@ -2974,31 +2975,38 @@ void tst_QQuickListView::itemListFlicker() QTRY_COMPARE(model->count(), 3); QTRY_COMPARE(listview->currentIndex(), 0); - QQuickItem *item; - - QVERIFY(item = findItem(contentItem, "item1")); + QQuickItem *item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(1); - QVERIFY(item = findItem(contentItem, "item1")); + item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(2); - QVERIFY(item = findItem(contentItem, "item1")); + item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); } @@ -5335,14 +5343,17 @@ void tst_QQuickListView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem(rootItem, "listItem")); + QQuickItem *item = findItem(rootItem, "listItem"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("header")); + item = rootItem->findChild("header"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("footer")); + item = rootItem->findChild("footer"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("section")); + item = rootItem->findChild("section"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -5604,42 +5615,49 @@ void tst_QQuickListView::unrequestedVisibility() QVERIFY(QTest::qWaitForWindowExposed(window)); - QQuickListView *leftview = findItem(window->rootObject(), "leftList"); - QTRY_VERIFY(leftview != 0); + QQuickListView *leftview; + QTRY_VERIFY((leftview = findItem(window->rootObject(), "leftList"))); - QQuickListView *rightview = findItem(window->rootObject(), "rightList"); - QTRY_VERIFY(rightview != 0); + QQuickListView *rightview; + QTRY_VERIFY((rightview = findItem(window->rootObject(), "rightList"))); QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); + QTRY_VERIFY((leftContent = leftview->contentItem())); - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); + QQuickItem *rightContent; + QTRY_VERIFY((rightContent = rightview->contentItem())); rightview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 100.0); - QQuickItem *item; - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + const QString wrapperObjectName = QStringLiteral("wrapper"); + QQuickItem *item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 16)); + item = findItem(leftContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 17)); + item = findItem(leftContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 3)); + item = findItem(rightContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 4)); + item = findItem(rightContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); rightview->setCurrentIndex(0); @@ -5647,106 +5665,139 @@ void tst_QQuickListView::unrequestedVisibility() QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); - QVERIFY(!findItem(leftContent, "wrapper", 19)); - QVERIFY(!findItem(rightContent, "wrapper", 19)); + QVERIFY(!findItem(leftContent, wrapperObjectName, 19)); + QVERIFY(!findItem(rightContent, wrapperObjectName, 19)); leftview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 100.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 3)); + item = findItem(leftContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(19, 1, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); + QTRY_VERIFY((item = findItem(leftContent, wrapperObjectName, 1))); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(3, 4, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(4, 3, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(16, 17, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(17, 16, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); delete window; @@ -7249,14 +7300,14 @@ void tst_QQuickListView::displayMargin() QQuickItem *content = listview->contentItem(); QVERIFY(content != 0); - QQuickItem *item0; - QQuickItem *item14; - - QVERIFY(item0 = findItem(content, "delegate", 0)); + QQuickItem *item0 = findItem(content, "delegate", 0); + QVERIFY(item0); QCOMPARE(delegateVisible(item0), true); // the 14th item should be within the end margin - QVERIFY(item14 = findItem(content, "delegate", 13)); + + QQuickItem *item14 = findItem(content, "delegate", 13); + QVERIFY(item14); QCOMPARE(delegateVisible(item14), true); // the 15th item should be outside the end margin @@ -7273,7 +7324,6 @@ void tst_QQuickListView::displayMargin() void tst_QQuickListView::negativeDisplayMargin() { - QQuickItem *item; QScopedPointer window(createView()); window->setSource(testFileUrl("negativeDisplayMargin.qml")); window->show(); @@ -7289,22 +7339,26 @@ void tst_QQuickListView::negativeDisplayMargin() QQuickItem *content = innerList->contentItem(); QVERIFY(content != 0); - QVERIFY(item = findItem(content, "delegate", 0)); + QQuickItem *item = findItem(content, "delegate", 0); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(content, "delegate", 7)); + item = findItem(content, "delegate", 7); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(content, "delegate", 8)); + item = findItem(content, "delegate", 8); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); // Flick until contentY means that delegate8 should be visible listview->setProperty("contentY", 500); - QVERIFY(item = findItem(content, "delegate", 8)); + item = findItem(content, "delegate", 8); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 1000); - QTRY_VERIFY(item = findItem(content, "delegate", 14)); + QTRY_VERIFY((item = findItem(content, "delegate", 14))); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 0); diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index d013d190ec..ba3d182efc 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1633,8 +1633,8 @@ void tst_QQuickPathView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem(rootItem, "listItem", 0)); + QQuickItem *item = findItem(rootItem, "listItem", 0); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -1685,7 +1685,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 1); // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); + item = findItem(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1697,7 +1698,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 2); // currentIndex is now 2 - QVERIFY(item = findItem(pathview, "wrapper", 2)); + item = findItem(pathview, "wrapper", 2); + QVERIFY(item); // verify that current item (item 2) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1709,7 +1711,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 3); // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); + item = findItem(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); -- cgit v1.2.3 From 9de7d0e9f170ed0a4baedaa33b3a68e166901a8a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 09:56:57 +0100 Subject: Change signature of QQmlBinding::create to take a FunctionObject * This is what's in the Value in all cases anyway. Change-Id: I212c4c4076050e8d0ea4cf6f72a1683e132cd51b Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/testtypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 3af7645ff7..91c7cfe305 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -129,7 +129,7 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); + QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); QQmlProperty property(m_target, name, qmlContext(this)); QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, -- cgit v1.2.3 From 82ee8341fba141e2e1e44948d2161a694add1584 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 12:42:41 +0100 Subject: Get rid of FunctionObject::createQmlFunction Instead, simply create a QmlContext, and setup the bindings with the QV4::Function itself. Change-Id: I9db93b15112e43a6d5e275d126fb20f9c8833e8f Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/testtypes.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 91c7cfe305..bc8c192a61 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -128,12 +128,11 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); - QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); - QQmlProperty property(m_target, name, qmlContext(this)); + QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, m_target)); QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, - function, m_target, context); + compilationUnit->runtimeFunctions[bindingId], m_target, context, qmlContext); qmlBinding->setTarget(property); QQmlPropertyPrivate::setBinding(property, qmlBinding); } -- cgit v1.2.3