From 64714ea431f2fd355ed27edc69dba4e992511e75 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 4 Nov 2016 00:11:59 +0100 Subject: QV4String: properly detect overflow when trying to convert to an array index A wrong overflow detection caused strings like "240000000000" to pass the conversion, even though they would not fit into a uint when converted into base-10. This mis-conversion to uint then caused all sorts of side effects (broken comparisons, wrong listing of properties, and so on). So, properly fix the overflow detection by using our numeric private functions. Change-Id: Icbf67ac68cf5785d6c77b433c7a45aed5285a8c2 Task-number: QTBUG-56830 Reviewed-by: Lars Knoll --- tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 27 +++++++++++++++++++++++++++ tests/auto/qml/qjsvalue/tst_qjsvalue.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index bf9bd18807..b9a9fec6d9 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1371,6 +1371,33 @@ void tst_QJSValue::hasProperty_changePrototype() QVERIFY(obj.hasOwnProperty("foo")); } +void tst_QJSValue::hasProperty_QTBUG56830_data() +{ + QTest::addColumn("key"); + QTest::addColumn("lookup"); + + QTest::newRow("bugreport-1") << QStringLiteral("240000000000") << QStringLiteral("3776798720"); + QTest::newRow("bugreport-2") << QStringLiteral("240000000001") << QStringLiteral("3776798721"); + QTest::newRow("biggest-ok-before-bug") << QStringLiteral("238609294221") << QStringLiteral("2386092941"); + QTest::newRow("smallest-bugged") << QStringLiteral("238609294222") << QStringLiteral("2386092942"); + QTest::newRow("biggest-bugged") << QStringLiteral("249108103166") << QStringLiteral("12884901886"); + QTest::newRow("smallest-ok-after-bug") << QStringLiteral("249108103167") << QStringLiteral("12884901887"); +} + +void tst_QJSValue::hasProperty_QTBUG56830() +{ + QFETCH(QString, key); + QFETCH(QString, lookup); + + QJSEngine eng; + const QJSValue value(42); + + QJSValue obj = eng.newObject(); + obj.setProperty(key, value); + QVERIFY(obj.hasProperty(key)); + QVERIFY(!obj.hasProperty(lookup)); +} + void tst_QJSValue::deleteProperty_basic() { QJSEngine eng; diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h index 16667ff344..485577bf97 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h @@ -97,6 +97,8 @@ private slots: void hasProperty_basic(); void hasProperty_globalObject(); void hasProperty_changePrototype(); + void hasProperty_QTBUG56830_data(); + void hasProperty_QTBUG56830(); void deleteProperty_basic(); void deleteProperty_globalObject(); -- cgit v1.2.3 From f4ac007f4a19bc095ff15d415a6629986de78e49 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 9 Nov 2016 16:06:56 +0100 Subject: Fix more cases where DSE would optimize out too many stores GCC5/6 do aggressive dead store elimination on memory passed to placement-new. This resulted in the Heap::Object::prototype being a nullptr. qml.pro already contained the -fno-lifetime-dse flag, but there are other places where we ask the memory manager to allocate data. This is temporary band-aid, and is already fixed in 5.8. Change-Id: Ia61a69f65fab351068a588cfc36b5b3d762ffc9f Task-number: QTBUG-56932 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/qqmlecmascript.pro | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro index 6f3f765aba..21e745f58e 100644 --- a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -13,6 +13,11 @@ RESOURCES += qqmlecmascript.qrc include (../../shared/util.pri) +greaterThan(QT_GCC_MAJOR_VERSION, 5) { + # Our code is bad. Temporary workaround. Fixed in 5.8 + QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse +} + # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -- cgit v1.2.3 From 8161a92b5fe1c0e4818a0fb19ed2177d7a12f731 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 3 Nov 2016 14:34:43 +0100 Subject: Quick: Do not calculate the difference in a geometryChange This difference is only used by the ListView, so calculating it and storing it (on the stack) introduces a penalty for all items. As the new geometry is already applied, the old geometry is passed along. This has the added advantage that the ListView does not have to re-calculate that either. This fixes a performance regression. Change-Id: Id5e67bb663a5b11a55ec15ff24ca5b213d1fcef5 Reviewed-by: Gunnar Sletta --- tests/auto/quick/qquickitem2/tst_qquickitem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 6554d749dd..78322b44a1 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -2726,9 +2726,9 @@ struct TestListener : public QQuickItemChangeListener { TestListener(bool remove = false) : remove(remove) { } - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &diff) override + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &oldGeometry) override { - record(item, QQuickItemPrivate::Geometry, diff); + record(item, QQuickItemPrivate::Geometry, oldGeometry); } void itemSiblingOrderChanged(QQuickItem *item) override { @@ -2810,20 +2810,20 @@ void tst_QQuickItem::changeListener() item->setImplicitWidth(10); QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitWidth), 1); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 1); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,0))); item->setImplicitHeight(20); QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitHeight), 1); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 2); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,20))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0))); item->setWidth(item->width() + 30); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 3); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,30,0))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,20))); item->setHeight(item->height() + 40); QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 4); - QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,40))); + QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,40,20))); item->setOpacity(0.5); QCOMPARE(itemListener.count(QQuickItemPrivate::Opacity), 1); -- cgit v1.2.3 From 769002ffe4a93995447a71393371579b1df41e12 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 14 Sep 2016 10:48:36 +0200 Subject: TextEdit: set cursor delegate's height to match the selected font RichText can have blocks of text with varying font sizes, so we must ensure that the cursor delegate's height is also set when it's moved to a different position in the text. Change-Id: I00691a94a2360c7d3272571fc4ba0da28b01006a Task-number: QTBUG-54934 Reviewed-by: J-P Nurmi --- .../quick/qquicktextedit/data/cursorHeight.qml | 20 ++++++++++++ .../quick/qquicktextedit/tst_qquicktextedit.cpp | 38 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/auto/quick/qquicktextedit/data/cursorHeight.qml (limited to 'tests') diff --git a/tests/auto/quick/qquicktextedit/data/cursorHeight.qml b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml new file mode 100644 index 0000000000..b831a9eb6f --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 300 + color: "white" + + TextEdit { + objectName: "textEditObject" + width: 300 + height: 300 + text: "Blah
blah" + textFormat: TextEdit.RichText + cursorDelegate: Rectangle { + objectName: "cursorInstance" + color: "red" + width: 2 + } + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index cb2a7bfd83..fa5a0a254d 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -139,6 +139,7 @@ private slots: void cursorVisible(); void delegateLoading_data(); void delegateLoading(); + void cursorDelegateHeight(); void navigation(); void readOnly(); #ifndef QT_NO_CLIPBOARD @@ -2779,6 +2780,43 @@ void tst_qquicktextedit::delegateLoading() //QVERIFY(!delegate); } +void tst_qquicktextedit::cursorDelegateHeight() +{ + QQuickView view(testFileUrl("cursorHeight.qml")); + view.show(); + view.requestActivate(); + QTest::qWaitForWindowActive(&view); + QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); + QVERIFY(textEditObject); + // Delegate creation is deferred until focus in or cursor visibility is forced. + QVERIFY(!textEditObject->findChild("cursorInstance")); + QVERIFY(!textEditObject->isCursorVisible()); + + // Test that the delegate gets created. + textEditObject->setFocus(true); + QVERIFY(textEditObject->isCursorVisible()); + QQuickItem* delegateObject = textEditObject->findChild("cursorInstance"); + QVERIFY(delegateObject); + + const int largerHeight = textEditObject->cursorRectangle().height(); + + textEditObject->setCursorPosition(0); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Move the cursor to the next line, which has a smaller font. + textEditObject->setCursorPosition(5); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QVERIFY(textEditObject->cursorRectangle().height() < largerHeight); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Test that the delegate gets deleted + textEditObject->setCursorDelegate(0); + QVERIFY(!textEditObject->findChild("cursorInstance")); +} + /* TextEdit element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. -- cgit v1.2.3 From 47847bebcacef2bbf3b5627ca18966d7d34d6762 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 11 Nov 2016 10:22:33 +0100 Subject: Fix flow text objects in beginning of RTL block If the block is right-to-left and starts with a text object, it should be aligned to the right edge of the QTextLine instead of the left one. [ChangeLog][QtQuick][Text] Fixed placement of flowing text objects in the start of a right-to-left block. Task-number: QTBUG-43133 Change-Id: Id790e88f3464280f124c38b4260386b84cac8826 Reviewed-by: Lars Knoll --- .../data/text/text_flow_image_start_ltr.qml | 14 ++++++++++++++ .../data/text/text_flow_image_start_rtl.qml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml (limited to 'tests') diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml new file mode 100644 index 0000000000..b8f0458818 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "This image is in the start of the text" + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml new file mode 100644 index 0000000000..e5bea08e62 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + text: "هو أمّا حكومة" + } +} -- cgit v1.2.3 From 8ff69297eeddc3f5650c4cc5517c7e2eafaf6c59 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Oct 2016 07:52:24 -0500 Subject: Setting Connection's target to null should disconnect implicit target Change-Id: Id7c8c7080e6db8bb6d09c1df13cddaef047cf611 Task-number: QTBUG-56499 Reviewed-by: J-P Nurmi --- .../data/test-connection-implicit.qml | 9 ++++++++ .../qml/qqmlconnections/tst_qqmlconnections.cpp | 27 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml new file mode 100644 index 0000000000..d5aa0f102a --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + width: 50 + + property bool tested: false + + Connections { onWidthChanged: tested = true } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index e529c74acc..eaf08a2a26 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -56,6 +56,7 @@ private slots: void errors(); void rewriteErrors(); void singletonTypeTarget(); + void clearImplicitTarget(); private: QQmlEngine engine; @@ -329,6 +330,32 @@ void tst_qqmlconnections::singletonTypeTarget() delete object; } +//QTBUG-56499 +void tst_qqmlconnections::clearImplicitTarget() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml")); + QQuickItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + // normal case: fire Connections + item->setWidth(100.); + QCOMPARE(item->property("tested").toBool(), true); + + item->setProperty("tested", false); + // clear the implicit target + QQmlConnections *connections = item->findChild(); + QVERIFY(connections); + connections->setTarget(0); + + // target cleared: no longer fire Connections + item->setWidth(150.); + QCOMPARE(item->property("tested").toBool(), false); + + delete item; +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" -- cgit v1.2.3 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 c56cc0c6c229b01811cf41fe2ea02dc3194feaab Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 20 Oct 2016 15:42:27 +0200 Subject: Introduce qmlRegisterModule() This is particularly useful for keeping the versions of related modules in sync. For example, when QtQuick.Controls introduces new types or revisions and bumps up the minor version, qmlRegisterModule() can be used to make the same version available for QtQuick.Controls.Styles in case it doesn't have new types or revisions to register. [ChangeLog][QtQml] Introduced qmlRegisterModule() that can be used to make a certain module version available, even if no types or revisions are registered for that version. Change-Id: I5ec457465cd778bb0adda55771d195f69cd4b31a Reviewed-by: Mitch Curtis Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlmoduleplugin/data/works22.qml | 3 + .../qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro | 12 ++++ .../qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp | 72 ++++++++++++++++++++ tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir | 1 + .../auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro | 3 +- .../qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | 76 ++++++++++++---------- 6 files changed, 131 insertions(+), 36 deletions(-) create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/works22.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir (limited to 'tests') diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works22.qml b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml new file mode 100644 index 0000000000..571a7e754d --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml @@ -0,0 +1,3 @@ +import org.qtproject.AutoTestQmlPluginType 2.2 + +MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro new file mode 100644 index 0000000000..eec5f23a7b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2.2 + +QT += core-private gui-private qml-private + +IMPORT_FILES = \ + qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp new file mode 100644 index 0000000000..ecec870374 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import2.2 worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + MyPlugin() + { + qWarning("plugin2.2 created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType"); + qmlRegisterType(uri, 2, 0, "MyPluginType"); + qmlRegisterModule(uri, 2, 2); + } +}; + +#include "plugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir new file mode 100644 index 0000000000..0a8b5d46eb --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro index 889968f6cc..0f548aa6f8 100644 --- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -20,7 +20,8 @@ SUBDIRS =\ protectedModule\ plugin/childplugin\ plugin.2/childplugin\ - plugin.2.1/childplugin + plugin.2.1/childplugin\ + plugin.2.2 tst_qqmlmoduleplugin_pro.depends += plugin SUBDIRS += tst_qqmlmoduleplugin.pro diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 265492b435..8600e1e8ab 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -52,8 +52,7 @@ public: private slots: virtual void initTestCase(); void importsPlugin(); - void importsPlugin2(); - void importsPlugin21(); + void importsPlugin_data(); void importsMixedQmlCppPlugin(); void incorrectPluginCase(); void importPluginWithQmlFile(); @@ -70,6 +69,7 @@ private slots: void importStrictModule(); void importStrictModule_data(); void importProtectedModule(); + void importVersionedModule(); void importsChildPlugin(); void importsChildPlugin2(); void importsChildPlugin21(); @@ -130,29 +130,15 @@ void tst_qqmlmoduleplugin::initTestCase() void tst_qqmlmoduleplugin::importsPlugin() { - QQmlEngine engine; - engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin created"); - QTest::ignoreMessage(QtWarningMsg, "import worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); - foreach (QQmlError err, component.errors()) - qWarning() << err; - VERIFY_ERRORS(0); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("value").toInt(),123); - delete object; -} + QFETCH(QString, suffix); + QFETCH(QString, qmlFile); -void tst_qqmlmoduleplugin::importsPlugin2() -{ QQmlEngine engine; engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); - QTest::ignoreMessage(QtWarningMsg, "import2 worked"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("plugin%1 created").arg(suffix))); + QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("import%1 worked").arg(suffix))); QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); + QQmlComponent component(&engine, testFileUrl(qmlFile)); foreach (QQmlError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -162,21 +148,15 @@ void tst_qqmlmoduleplugin::importsPlugin2() delete object; } -void tst_qqmlmoduleplugin::importsPlugin21() +void tst_qqmlmoduleplugin::importsPlugin_data() { - QQmlEngine engine; - engine.addImportPath(m_importsDirectory); - QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); - QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); - QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations."); - QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); - foreach (QQmlError err, component.errors()) - qWarning() << err; - VERIFY_ERRORS(0); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("value").toInt(),123); - delete object; + QTest::addColumn("suffix"); + QTest::addColumn("qmlFile"); + + QTest::newRow("1.0") << "" << "works.qml"; + QTest::newRow("2.0") << "2" << "works2.qml"; + QTest::newRow("2.1") << "2.1" << "works21.qml"; + QTest::newRow("2.2") << "2.2" << "works22.qml"; } void tst_qqmlmoduleplugin::incorrectPluginCase() @@ -578,6 +558,32 @@ void tst_qqmlmoduleplugin::importProtectedModule() QVERIFY(object != 0); } +void tst_qqmlmoduleplugin::importVersionedModule() +{ + qmlRegisterType("org.qtproject.VersionedModule", 1, 0, "TestType"); + qmlRegisterModule("org.qtproject.VersionedModule", 1, 1); + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + QUrl url(testFileUrl("empty.qml")); + + QQmlComponent component(&engine); + component.setData("import org.qtproject.VersionedModule 1.0\n TestType {}\n", url); + QScopedPointer object10(component.create()); + QVERIFY(!object10.isNull()); + + component.setData("import org.qtproject.VersionedModule 1.1\n TestType {}\n", url); + QScopedPointer object11(component.create()); + QVERIFY(!object11.isNull()); + + component.setData("import org.qtproject.VersionedModule 1.2\n TestType {}\n", url); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QScopedPointer object12(component.create()); + QVERIFY(object12.isNull()); + QCOMPARE(component.errorString(), QString("%1:1 module \"org.qtproject.VersionedModule\" version 1.2 is not installed\n").arg(url.toString())); +} + void tst_qqmlmoduleplugin::importsChildPlugin() { QQmlEngine engine; -- cgit v1.2.3 From fbfc433dae873e3cfd1247e020faff4c1303c659 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 21 Nov 2016 07:54:49 +0100 Subject: Fix warning in qml testcase 'root.done' doesn't exist. There is a timer that flips 'when' explicitly when the testcase is ready to run. Change-Id: I8d9b1b36c1e605db43a4c86b5694956c864896a4 Reviewed-by: J-P Nurmi --- tests/auto/qmltest-blacklist/animators/tst_stopped.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml index 56bec4e452..a70da63e13 100644 --- a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml +++ b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml @@ -37,7 +37,7 @@ Item { TestCase { id: testcase name: "animators-stopped" - when: root.done + when: false function test_endresult() { verify(true); } -- 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 d236661940b09194cc6a864ffbe687569922787e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:35:57 +0100 Subject: Fix qrc test Make this test pass when we have the time stamp available in the qrc data (since commit d20773824529d191e7b483b505107dce6c1b1c3d in qtbase) or when not (when the engine falls back to the program executable). Change-Id: Idb9a6951d76515a2482d573b40da99871bc442cd Reviewed-by: Lars Knoll --- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index e2c0055ea1..f8698f0afa 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -563,7 +563,11 @@ void tst_qmldiskcache::cacheResources() QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast(&unit), sizeof(unit)) == sizeof(unit)); - QCOMPARE(qint64(unit.sourceTimeStamp), QFileInfo(QCoreApplication::applicationFilePath()).lastModified().toMSecsSinceEpoch()); + + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); + if (!referenceTimeStamp.isValid()) + referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); + QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); } } -- cgit v1.2.3 From eb7ec4fb9492b51d8371d8689b9538d6d22d13fd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:53:07 +0100 Subject: Fix handling of qrc:/// urls with disk caching Use the right function for converting a qrc:/// url to a local path. QUrl::toLocalFile() gives us an empty path, which prevents us from getting a time stamp and comparing it against the stamp in the cache file. This fixes disk caching with samegame. Change-Id: Id3eb270f1f7a7f25143d2f075a45f32bdb0384c5 Reviewed-by: Lars Knoll --- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index f8698f0afa..8af446173d 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources() { CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml")); - qDebug() << component.errorString(); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QCOMPARE(obj->property("value").toInt(), 20); @@ -558,17 +557,37 @@ void tst_qmldiskcache::cacheResources() const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); QCOMPARE(entries.count(), 1); + QDateTime cacheFileTimeStamp; + { QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()); QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast(&unit), sizeof(unit)) == sizeof(unit)); + cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified(); + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); if (!referenceTimeStamp.isValid()) referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); } + + waitForFileSystem(); + + { + CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml")); + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("value").toInt(), 20); + } + + { + const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); + QCOMPARE(entries.count(), 1); + + QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch()); + } } void tst_qmldiskcache::stableOrderOfDependentCompositeTypes() -- cgit v1.2.3 From 47c84e6b5e1162a6143663723e6b948b01d44c17 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 29 Aug 2016 16:43:48 +0200 Subject: QmlTooling: Retry local client connection on error So far the local client connection would give up if it could not connect to the server on the first try. Considering that you cannot reset the connection, this is very harsh. Instead, retry on failure. Change-Id: I68464b7b99b94a4b0fb2722d718a43a1c0889f40 Reviewed-by: hjk --- tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp index a503da4e4b..8d21a8a45a 100644 --- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp @@ -51,12 +51,6 @@ private: QQmlDebugConnection *m_conn; QQmlDebugTestService *m_service; - bool connect(); - -signals: - void waiting(); - void parallel(); - private slots: void initTestCase(); @@ -75,12 +69,13 @@ void tst_QQmlDebugLocal::initTestCase() const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName); QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData()); + QQmlDebuggingEnabler::connectToLocalDebugger(fileName); + + QTest::qWait(1000); m_conn = new QQmlDebugConnection(this); m_conn->startLocalServer(fileName); - QQmlDebuggingEnabler::connectToLocalDebugger(fileName); - new QQmlEngine(this); QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn); -- cgit v1.2.3 From 7b7fb7fe3ab8ce5db744329b2f138fd8b2a811ea Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Nov 2016 09:47:48 +0100 Subject: Fix support for QML declared default list properties The grammar was not permitting to write default property list myChildren; and instead developers had to work around it with an alias property list myChildrenData; default property alias myChildren: myChildrenData which is not nice. Fortunately this is easy to fix in the grammar. Task-number: QTBUG-10822 Change-Id: I4e914ddb9588913da09e9fb6c6aa154cf8a9e18f Reviewed-by: Lars Knoll --- tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml | 5 +++++ tests/auto/qml/qqmllanguage/data/defaultListProperty.qml | 6 ++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml create mode 100644 tests/auto/qml/qqmllanguage/data/defaultListProperty.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml new file mode 100644 index 0000000000..bb28e22110 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + default property list myChildren; +} diff --git a/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml new file mode 100644 index 0000000000..d68ffd2979 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +QtObjectWithChildren { + QtObject { + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index ad06946b0b..658b4f5852 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -254,6 +254,8 @@ private slots: void arrayBuffer_data(); void arrayBuffer(); + void defaultListProperty(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4233,6 +4235,13 @@ void tst_qqmllanguage::arrayBuffer() QCOMPARE(object->property("ok").toBool(), true); } +void tst_qqmllanguage::defaultListProperty() +{ + QQmlComponent component(&engine, testFileUrl("defaultListProperty.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From af4516ac866cc877c3a033d6b837b30445ee8f1a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 26 Aug 2016 18:19:37 +0200 Subject: QmlDebug: Allow specifying debug connectors on the command line With this change arbitrary debug connector plugins can be loaded by specifying them in the "-qmljsdebugger=..." argument. It was already possible to load them by using startDebugConnector(...), but that requires source code modification. Change-Id: I06ec7f54ec65add7cff2846ed4083ea878a04765 Reviewed-by: Simon Hausmann --- .../qqmldebuggingenabler/data/test.qml | 1 + .../tst_qqmldebuggingenabler.cpp | 96 ++++++++++++++-------- .../qqmldebuggingenablerserver.cpp | 23 +++++- 3 files changed, 83 insertions(+), 37 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml index a36d0cae91..0fa9f1ffd8 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml @@ -36,6 +36,7 @@ Item { var b = {a: "hello", d: 1 } var c var d = 12 + console.log("Component.onCompleted"); } function foo() { var a = [1, 2] diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 8d1a165243..3aa3a5c87e 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -142,24 +142,36 @@ void tst_QQmlDebuggingEnabler::cleanup() void tst_QQmlDebuggingEnabler::data() { + QTest::addColumn("connector"); QTest::addColumn("blockMode"); QTest::addColumn("services"); - QTest::newRow("noblock,all") << false << QStringList(); - QTest::newRow("block,all") << true << QStringList(); - QTest::newRow("noblock,debugger") << false << QQmlDebuggingEnabler::debuggerServices(); - QTest::newRow("block,debugger") << true << QQmlDebuggingEnabler::debuggerServices(); - QTest::newRow("noblock,inspector") << false << QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("block,inspector") << true << QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("noblock,profiler") << false << QQmlDebuggingEnabler::profilerServices(); - QTest::newRow("block,profiler") << true << QQmlDebuggingEnabler::profilerServices(); - QTest::newRow("noblock,debugger+inspector") - << false << QQmlDebuggingEnabler::debuggerServices() + - QQmlDebuggingEnabler::inspectorServices(); - QTest::newRow("block,debugger+inspector") - << true << QQmlDebuggingEnabler::debuggerServices() + - QQmlDebuggingEnabler::inspectorServices(); - + QStringList connectors({ + QLatin1String("QQmlDebugServer"), + QLatin1String("QQmlNativeDebugConnector") + }); + + QList blockModes({ true, false }); + + QList serviceLists({ + QStringList(), + QQmlDebuggingEnabler::nativeDebuggerServices(), + QQmlDebuggingEnabler::debuggerServices(), + QQmlDebuggingEnabler::inspectorServices(), + QQmlDebuggingEnabler::profilerServices(), + QQmlDebuggingEnabler::debuggerServices() + QQmlDebuggingEnabler::inspectorServices() + }); + + foreach (const QString &connector, connectors) { + foreach (bool blockMode, blockModes) { + foreach (const QStringList &serviceList, serviceLists) { + QString name = connector + QLatin1Char(',') + + QLatin1String(blockMode ? "block" : "noblock") + QLatin1Char(',') + + serviceList.join(QLatin1Char('-')); + QTest::newRow(name.toUtf8().constData()) << connector << blockMode << serviceList; + } + } + } } void tst_QQmlDebuggingEnabler::qmlscene_data() @@ -169,27 +181,36 @@ void tst_QQmlDebuggingEnabler::qmlscene_data() void tst_QQmlDebuggingEnabler::qmlscene() { + QFETCH(QString, connector); QFETCH(bool, blockMode); QFETCH(QStringList, services); - connection = new QQmlDebugConnection(); - QList clients = QQmlDebugTest::createOtherClients(connection); process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); process->setMaximumBindErrors(1); process->start(QStringList() - << QString::fromLatin1("-qmljsdebugger=port:5555,5565%1%2%3") + << QString::fromLatin1("-qmljsdebugger=connector:%1%2%3%4") + .arg(connector + (connector == QLatin1String("QQmlDebugServer") ? + QLatin1String(",port:5555,5565") : QString())) .arg(blockMode ? QLatin1String(",block") : QString()) .arg(services.isEmpty() ? QString() : QString::fromLatin1(",services:")) .arg(services.isEmpty() ? QString() : services.join(",")) << testFile(QLatin1String("test.qml"))); - QVERIFY(process->waitForSessionStart()); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) - QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? - QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + if (connector == QLatin1String("QQmlDebugServer")) { + QVERIFY(process->waitForSessionStart()); + connection = new QQmlDebugConnection(); + QList clients = QQmlDebugTest::createOtherClients(connection); + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + foreach (QQmlDebugClient *client, clients) + QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? + QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + } + + QCOMPARE(process->state(), QLatin1String("running")); + if (!blockMode) + QTRY_VERIFY(process->output().contains(QLatin1String("qml: Component.onCompleted"))); } void tst_QQmlDebuggingEnabler::custom_data() @@ -199,13 +220,12 @@ void tst_QQmlDebuggingEnabler::custom_data() void tst_QQmlDebuggingEnabler::custom() { + QFETCH(QString, connector); QFETCH(bool, blockMode); QFETCH(QStringList, services); const int portFrom = 5555; const int portTo = 5565; - connection = new QQmlDebugConnection(); - QList clients = QQmlDebugTest::createOtherClients(connection); process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebuggingenablerserver"), this); process->setMaximumBindErrors(portTo - portFrom); @@ -214,18 +234,28 @@ void tst_QQmlDebuggingEnabler::custom() if (blockMode) args << QLatin1String("-block"); - args << QString::number(portFrom) << QString::number(portTo); + args << QLatin1String("-connector") << connector + << QString::number(portFrom) << QString::number(portTo); + if (!services.isEmpty()) args << QLatin1String("-services") << services; process->start(args); - QVERIFY(process->waitForSessionStart()); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) - QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? - QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + if (connector == QLatin1String("QQmlDebugServer")) { + QVERIFY(process->waitForSessionStart()); + connection = new QQmlDebugConnection(); + QList clients = QQmlDebugTest::createOtherClients(connection); + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + foreach (QQmlDebugClient *client, clients) + QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? + QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); + } + + QCOMPARE(process->state(), QLatin1String("running")); + if (!blockMode) + QTRY_VERIFY(process->output().contains(QLatin1String("QQmlEngine created"))); } QTEST_MAIN(tst_QQmlDebuggingEnabler) diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp index cfbb31f9e1..a064bbbacc 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -40,12 +41,18 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); QStringList arguments = app.arguments(); arguments.removeFirst(); + QString connector = QLatin1String("QQmlDebugServer"); if (arguments.size() && arguments.first() == QLatin1String("-block")) { block = QQmlDebuggingEnabler::WaitForClient; arguments.removeFirst(); } + if (arguments.size() >= 2 && arguments.first() == QLatin1String("-connector")) { + arguments.removeFirst(); + connector = arguments.takeFirst(); + } + if (arguments.size() >= 2) { portFrom = arguments.takeFirst().toInt(); portTo = arguments.takeFirst().toInt(); @@ -54,12 +61,20 @@ int main(int argc, char *argv[]) if (arguments.size() && arguments.takeFirst() == QLatin1String("-services")) QQmlDebuggingEnabler::setServices(arguments); - if (!portFrom || !portTo) - qFatal("Port range has to be specified."); + if (connector == QLatin1String("QQmlDebugServer")) { + if (!portFrom || !portTo) + qFatal("Port range has to be specified."); + + while (portFrom <= portTo) + QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); + } else if (connector == QLatin1String("QQmlNativeDebugConnector")) { + QVariantHash configuration; + configuration[QLatin1String("block")] = (block == QQmlDebuggingEnabler::WaitForClient); + QQmlDebuggingEnabler::startDebugConnector(connector, configuration); + } - while (portFrom <= portTo) - QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); QQmlEngine engine; + qDebug() << "QQmlEngine created\n"; Q_UNUSED(engine); return app.exec(); } -- cgit v1.2.3 From 0cab78f2b208ba1a14802c7c7e5737feea0aa0cd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 28 Nov 2016 09:47:03 +0100 Subject: tst_qquicktextedit: remove useless call to image.save() Change-Id: I433ba9ef0dc403e7b15eeaee1fd682cf443870cf Reviewed-by: J-P Nurmi --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 5d30cc8c94..30d1079df9 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -929,7 +929,6 @@ void tst_qquicktextedit::hAlignVisual() const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); - image.save("test3.png"); QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); QVERIFY2(mid < right, msgNotLessThan(mid, right).constData()); } -- 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 485e9fdf486446fb13012debe10137739b96d8ca Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 10 Aug 2016 21:41:19 -0700 Subject: Add touch event support to qmltest [ChangeLog][QuickTest] Add support for simulating touch events from TestCase. Task-number: QTBUG-23083 Change-Id: Ic045e00a91b8270b6f08d398323e06b576615e79 Reviewed-by: Shawn Rutledge --- tests/auto/qmltest/events/tst_touch.qml | 182 ++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 tests/auto/qmltest/events/tst_touch.qml (limited to 'tests') diff --git a/tests/auto/qmltest/events/tst_touch.qml b/tests/auto/qmltest/events/tst_touch.qml new file mode 100644 index 0000000000..5b209a6d0b --- /dev/null +++ b/tests/auto/qmltest/events/tst_touch.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import QtTest 1.0 + +MultiPointTouchArea { + id: touchArea + width: 100 + height: 100 + + SignalSpy { + id: touchUpdatedSpy + target: touchArea + signalName: "touchUpdated" + } + + SignalSpy { + id: interiorSpy + target: interior + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: interior + width: parent.width / 2 + height: parent.height + anchors.right: parent.right + } + + Window { + width: 100; height: 100 + + SignalSpy { + id: subWindowSpy + target: subWindowTouchArea + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: subWindowTouchArea + anchors.fill: parent + } + } + + TestCase { + when: windowShown + name: "touch" + + function comparePoint(point, id, x, y) { + var retval = true; + var pointId = point.pointId & 0xFFFFFF; //strip device identifier + if (pointId !== id) { + warn("Unexpected pointId: " + pointId + ". Expected " + id); + retval = false; + } + if (point.x !== x) { + warn("Unexpected x: " + point.x + ". Expected " + x); + retval = false; + } + if (point.y !== y) { + warn("Unexpected y: " + point.y + ". Expected " + y); + retval = false; + } + return retval; + } + + function cleanup() { + touchUpdatedSpy.clear(); + interiorSpy.clear(); + subWindowSpy.clear(); + } + + function test_secondWindow() { + var first = 1; + var sequence = touchEvent(subWindowTouchArea); + sequence.press(first, 0, 0, 0); + sequence.commit(); + sequence.release(first, subWindowTouchArea, 0, 0) + sequence.commit(); + compare(subWindowSpy.count, 2); + var touchPoint = subWindowSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, 0, 0)); + } + + function initTestCase() { + waitForRendering(touchArea) // when: windowShown may be insufficient + } + + function test_childMapping() { + var sequence = touchEvent(touchArea); + + var first = 1; + // Test mapping touches to a child item + sequence.press(first, interior, 0, 0); + sequence.commit(); + + // Map touches to the parent at the same point + sequence.move(first, touchArea, interior.x, interior.y); + sequence.commit(); + + sequence.release(first, touchArea, interior.x, interior.y); + sequence.commit(); + + compare(interiorSpy.count, 3); + verify(comparePoint(interiorSpy.signalArguments[0][0][0], first, 0, 0)); + verify(comparePoint(interiorSpy.signalArguments[1][0][0], first, 0, 0)); + } + + function test_fullSequence() { + var sequence = touchEvent(touchArea); + verify(sequence); + + var first = 1; + var second = 2; + + sequence.press(first, null, 0, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 1); + var touchPoints = touchUpdatedSpy.signalArguments[0][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], first, 0, 0)); + + sequence.stationary(first); + sequence.press(second, null, 1, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 2); + touchPoints = touchUpdatedSpy.signalArguments[1][0]; + compare(touchPoints.length, 2); + verify(comparePoint(touchPoints[0], first, 0, 0)); + verify(comparePoint(touchPoints[1], second, 1, 0)); + + sequence.release(first); + sequence.move(second, null, 1, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 3); + touchPoints = touchUpdatedSpy.signalArguments[2][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], second, 1, 1)); + + sequence.release(second, null, 0, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 4); + touchPoints = touchUpdatedSpy.signalArguments[3][0]; + compare(touchPoints.length, 0); + } + + function test_simpleChain() { + var first = 1; + touchEvent(touchArea).press(first).commit().release(first).commit(); + compare(touchUpdatedSpy.count, 2); + var touchPoint = touchUpdatedSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, touchArea.width / 2, touchArea.height / 2)); + } + } +} -- 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 bff7302fc277d18b5bd4ad95d35b9e1bbc2be001 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 7 Dec 2016 14:24:04 +0100 Subject: V4 Debugger: Add an option to pass additional context for evaluate Interpret the "context" option as an ID for a QObject whose QML context is then injected when evaluating the expression. The QObject needs to be tracked by some other debug service for this to work, e.g. the QML debugger or the inspector. Task-number: QTCREATORBUG-17177 Change-Id: I6a9e8b9ae23e8bb67ed1905a2ef73f7c4faeb990 Reviewed-by: Simon Hausmann --- .../qqmldebugjs/qqmldebugjs/qqmldebugjs.pro | 1 + .../qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp | 68 +++++++++++++++++++++- .../qml/debugger/qv4debugger/tst_qv4debugger.cpp | 26 ++++++--- 3 files changed, 85 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro index 79e772c1ee..cbaf3b5309 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro @@ -9,6 +9,7 @@ SOURCES += tst_qqmldebugjs.cpp INCLUDEPATH += ../../shared include(../../../../shared/util.pri) include(../../shared/debugutil.pri) +include(../../shared/qqmlenginedebugclient.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp index d1150be831..31b8d63ec2 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "../../shared/qqmlenginedebugclient.h" #include "../../../../shared/util.h" #include @@ -52,6 +53,7 @@ const char *STEPACTION = "stepaction"; const char *STEPCOUNT = "stepcount"; const char *EXPRESSION = "expression"; const char *FRAME = "frame"; +const char *CONTEXT = "context"; const char *GLOBAL = "global"; const char *DISABLEBREAK = "disable_break"; const char *HANDLES = "handles"; @@ -215,6 +217,8 @@ private slots: void evaluateInLocalScope_data() { targetData(); } void evaluateInLocalScope(); + void evaluateInContext(); + void getScripts_data() { targetData(); } void getScripts(); @@ -257,7 +261,7 @@ public: void interrupt(); void continueDebugging(StepAction stepAction); - void evaluate(QString expr, int frame = -1); + void evaluate(QString expr, int frame = -1, int context = -1); void lookup(QList handles, bool includeSource = false); void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); void frame(int number = -1); @@ -280,6 +284,7 @@ signals: void connected(); void interruptRequested(); void result(); + void failure(); void stopped(); private: @@ -340,13 +345,14 @@ void QJSDebugClient::continueDebugging(StepAction action) sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::evaluate(QString expr, int frame) +void QJSDebugClient::evaluate(QString expr, int frame, int context) { // { "seq" : , // "type" : "request", // "command" : "evaluate", // "arguments" : { "expression" : , - // "frame" : + // "frame" : , + // "context" : // } // } VARIANTMAPINIT; @@ -358,6 +364,9 @@ void QJSDebugClient::evaluate(QString expr, int frame) if (frame != -1) args.setProperty(QLatin1String(FRAME),QJSValue(frame)); + if (context != -1) + args.setProperty(QLatin1String(CONTEXT), QJSValue(context)); + if (!args.isUndefined()) { jsonVal.setProperty(QLatin1String(ARGUMENTS),args); } @@ -684,6 +693,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data) if (type == "response") { if (!value.value("success").toBool()) { + emit failure(); qDebug() << "Received success == false response from application"; return; } @@ -1394,6 +1404,58 @@ void tst_QQmlDebugJS::evaluateInLocalScope() QCOMPARE(body.value("value").toInt(),10); } +void tst_QQmlDebugJS::evaluateInContext() +{ + connection = new QQmlDebugConnection(); + process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + + "/qmlscene", this); + client = new QJSDebugClient(connection); + QScopedPointer engineClient(new QQmlEngineDebugClient(connection)); + process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE)); + + QVERIFY(process->waitForSessionStart()); + + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + + QTRY_COMPARE(client->state(), QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(engineClient->state(), QQmlEngineDebugClient::Enabled); + client->connect(); + + // "a" not accessible without extra context + client->evaluate(QLatin1String("a + 10"), -1, -1); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(failure()))); + + bool success = false; + engineClient->queryAvailableEngines(&success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + QVERIFY(engineClient->engines().count()); + engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + auto contexts = engineClient->rootContext().contexts; + QCOMPARE(contexts.count(), 1); + auto objects = contexts[0].objects; + QCOMPARE(objects.count(), 1); + engineClient->queryObjectRecursive(objects[0], &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + auto object = engineClient->object(); + + // "a" accessible in context of surrounding object + client->evaluate(QLatin1String("a + 10"), -1, object.debugId); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + QString jsonString = client->response; + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QTRY_COMPARE(body.value("value").toInt(), 20); +} + void tst_QQmlDebugJS::getScripts() { //void scripts(int types = -1, QList ids = QList(), bool includeSource = false, QVariant filter = QVariant()); diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index a23b7e37eb..6793596174 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -41,6 +41,7 @@ #include #include #include +#include using namespace QV4; using namespace QV4::Debugging; @@ -203,8 +204,8 @@ public slots: while (!m_expressionRequests.isEmpty()) { Q_ASSERT(debugger->state() == QV4Debugger::Paused); ExpressionRequest request = m_expressionRequests.takeFirst(); - ExpressionEvalJob job(debugger->engine(), request.frameNr, request.expression, - &collector); + ExpressionEvalJob job(debugger->engine(), request.frameNr, request.context, + request.expression, &collector); debugger->runInEngine(&job); m_expressionResults << job.returnValue(); m_expressionRefs << job.refs(); @@ -276,6 +277,7 @@ public: struct ExpressionRequest { QString expression; int frameNr; + int context; }; QVector m_expressionRequests; QList m_expressionResults; @@ -726,24 +728,34 @@ void tst_qv4debugger::evaluateExpression() TestAgent::ExpressionRequest request; request.expression = "x"; request.frameNr = 0; + request.context = -1; // no extra context m_debuggerAgent->m_expressionRequests << request; request.expression = "x"; request.frameNr = 1; m_debuggerAgent->m_expressionRequests << request; + request.context = 5355; // invalid context object + m_debuggerAgent->m_expressionRequests << request; + + QObject object; // some object without QML context + request.context = QQmlDebugService::idForObject(&object); + m_debuggerAgent->m_expressionRequests << request; + debugger()->addBreakPoint("evaluateExpression", 3); evaluateJavaScript(script, "evaluateExpression"); - QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 2); + QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 4); QCOMPARE(m_debuggerAgent->m_expressionRefs[0].size(), 1); QJsonObject result0 = m_debuggerAgent->m_expressionRefs[0].first().toObject(); QCOMPARE(result0.value("type").toString(), QStringLiteral("number")); QCOMPARE(result0.value("value").toInt(), 10); - QCOMPARE(m_debuggerAgent->m_expressionRefs[1].size(), 1); - QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); - QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); - QCOMPARE(result1.value("value").toInt(), 20); + for (int i = 1; i < 4; ++i) { + QCOMPARE(m_debuggerAgent->m_expressionRefs[i].size(), 1); + QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); + QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); + QCOMPARE(result1.value("value").toInt(), 20); + } } QTEST_MAIN(tst_qv4debugger) -- 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 From 7aaebe557476c088d339f1b4b114a671885c4ea8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 17 Nov 2016 15:18:17 +0100 Subject: TestCase: add createTemporaryObject(), createTemporaryQmlObject() A typical pattern with QML tests is to dynamically create an item and then destroy it at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = Qt.createQmlObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... item.destroy(); } } The problem with this pattern is that any failures in the test function will cause the call to item.destroy() to be skipped, leaving the item hanging around in the scene until the test case has finished. This can result in interference with future tests; for example, by blocking input events or producing unrelated debug output that makes it difficult to follow the code's execution. By calling e.g. createTemporaryQmlObject() instead, the object is guaranteed to be destroyed at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = createTemporaryObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... // Don't need to worry about destroying "item" here. } } [ChangeLog][TestCase] Added createTemporaryObject() and createTemporaryQmlObject() functions that can be used to ensure that dynamically created objects are destroyed at the end of each test function. Change-Id: I483342052462aa86464c86bf2082892712dceb58 Task-number: QTBUG-56361 Reviewed-by: Shawn Rutledge Reviewed-by: Michael Brasser --- .../selftests/tst_createTemporaryObject.qml | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 tests/auto/qmltest/selftests/tst_createTemporaryObject.qml (limited to 'tests') diff --git a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml new file mode 100644 index 0000000000..c4912c7388 --- /dev/null +++ b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.8 +import QtQuick.Window 2.2 +import QtTest 1.2 + +TestCase { + id: testCase + name: "tst_createTemporaryObject" + width: 100 + height: 100 + when: windowShown + + property var createdObjectNames: [] + + function verifyNoChildren() { + for (var i = 0; i < createdObjectNames.length; ++i) { + verify(!findChild(testCase, createdObjectNames[i])); + } + } + + function init() { + // The items are destroyed after cleanup(), so we check here after every test, + // and once for the last test in cleanupTestCase(). + verifyNoChildren(); + } + + function cleanupTestCase() { + verifyNoChildren(); + } + + function test_fromQml_data() { + return [ + { tag: "QtObject", qml: "import QtQml 2.0; QtObject {}" }, + { tag: "Item", qml: "import QtQuick 2.0; Item {}" }, + ]; + } + + function test_fromQml(data) { + var object = createTemporaryQmlObject(data.qml, testCase); + verify(object); + + object.objectName = data.tag + "FromQml"; + compare(findChild(testCase, object.objectName), object); + + createdObjectNames.push(object.objectName); + } + + Component { + id: objectComponent + + QtObject {} + } + + Component { + id: itemComponent + + Item {} + } + + Component { + id: windowComponent + + Window {} + } + + function test_fromComponent_data() { + return [ + { tag: "QtObject", component: objectComponent }, + { tag: "Item", component: itemComponent }, + { tag: "Window", component: windowComponent }, + ]; + } + + function test_fromComponent(data) { + var object = createTemporaryObject(data.component, testCase); + verify(object); + + object.objectName = data.tag + "FromComponent"; + compare(findChild(testCase, object.objectName), object); + + if (object.hasOwnProperty("contentItem")) + object.contentItem.objectName = "WindowContentItemFromComponent"; + + createdObjectNames.push(object.objectName); + } +} -- cgit v1.2.3 From 17a1c12a4520c4ae756e7dd5c08b2386ef84673a Mon Sep 17 00:00:00 2001 From: Olivier JG Date: Wed, 7 Dec 2016 11:57:03 -0600 Subject: Add pressAndHoldInterval to MouseArea Introduce pressAndHoldInterval to allow setting the pressAndHold delay per-MouseArea. [ChangeLog][QtQml][MouseArea] Introduce pressAndHoldInterval property, which controls the elapsed time before pressAndHold is emitted. Task-Id: QTBUG-47662 Change-Id: Ic2173335033a6ed0d4b652333020f030de63a8e7 Reviewed-by: Michael Brasser --- .../quick/qquickmousearea/data/pressAndHold.qml | 12 ++++++ .../quick/qquickmousearea/tst_qquickmousearea.cpp | 45 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/auto/quick/qquickmousearea/data/pressAndHold.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickmousearea/data/pressAndHold.qml b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml new file mode 100644 index 0000000000..bde195965e --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml @@ -0,0 +1,12 @@ +import QtQuick 2.9 + +Item { + width: 100 + height: 100 + + MouseArea { + id: mouseArea + objectName: "mouseArea" + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index e1f903123b..c8351b9e18 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -127,6 +127,8 @@ private slots: void containsPress(); void ignoreBySource(); void notPressedAfterStolenGrab(); + void pressAndHold_data(); + void pressAndHold(); private: int startDragDistance() const { @@ -2098,6 +2100,49 @@ void tst_QQuickMouseArea::notPressedAfterStolenGrab() QVERIFY(!ma->pressed()); } +void tst_QQuickMouseArea::pressAndHold_data() +{ + QTest::addColumn("pressAndHoldInterval"); + QTest::addColumn("waitTime"); + + QTest::newRow("default") << -1 << QGuiApplication::styleHints()->mousePressAndHoldInterval(); + QTest::newRow("short") << 500 << 500; + QTest::newRow("long") << 1000 << 1000; +} + +void tst_QQuickMouseArea::pressAndHold() +{ + QFETCH(int, pressAndHoldInterval); + QFETCH(int, waitTime); + + QQuickView window; + QByteArray errorMessage; + QVERIFY2(initView(window, testFileUrl("pressAndHold.qml"), true, &errorMessage), errorMessage.constData()); + window.show(); + window.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QQuickItem *root = window.rootObject(); + QVERIFY(root != 0); + + QQuickMouseArea *mouseArea = window.rootObject()->findChild("mouseArea"); + QVERIFY(mouseArea != 0); + + QSignalSpy pressAndHoldSpy(mouseArea, &QQuickMouseArea::pressAndHold); + + if (pressAndHoldInterval > -1) + mouseArea->setPressAndHoldInterval(pressAndHoldInterval); + else + mouseArea->resetPressAndHoldInterval(); + + QElapsedTimer t; + t.start(); + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50)); + QVERIFY(pressAndHoldSpy.wait()); + // should be off by no more than 20% of waitTime + QVERIFY(qAbs(t.elapsed() - waitTime) < (waitTime * 0.2)); + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50)); +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" -- cgit v1.2.3 From c4eefa4a8d6d3e95062deb78229940460a7ef605 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 22 Nov 2016 11:25:46 +0100 Subject: Keys: add shortcutOverride signal This allows an item to accept the shortcutOverride event, preventing e.g. Shortcut from stealing key events. The original use case that prompted the creation of this patch was using a Popup from Controls 2 to create a keyboard shortcut editor. When the user wanted to cancel the shortcut that they were editing, they could press escape, but Popup would grab the shortcut and close itself. As the test case demonstrates, the same problem occurs with the Shortcut type in Qt Quick. [ChangeLog][QtQuick][Keys] Added shortcutOverride signal to Keys attached object to allow prevention of e.g. Shortcut from stealing key events. Task-number: QTBUG-57098 Change-Id: I594e4ea17ec417d8c7d93c6cf347c1a1a2e62b93 Reviewed-by: Shawn Rutledge Reviewed-by: Robin Burchell --- .../quick/qquickitem/data/shortcutOverride.qml | 65 ++++++++++++++++++++++ tests/auto/quick/qquickitem/tst_qquickitem.cpp | 35 ++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 tests/auto/quick/qquickitem/data/shortcutOverride.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickitem/data/shortcutOverride.qml b/tests/auto/quick/qquickitem/data/shortcutOverride.qml new file mode 100644 index 0000000000..fab9175c17 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/shortcutOverride.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.8 +import QtQuick.Window 2.1 + +Item { + property int escapeHandlerActivationCount: 0 + property int shortcutActivationCount: 0 + property alias escapeItem: escapeItem + + Item { + id: escapeItem + objectName: "escapeItem" + focus: true + + // By accepting shortcut override events when the key is Qt.Key_Escape, + // we can ensure that our Keys.onEscapePressed handler (below) will be called. + Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape) + + Keys.onEscapePressed: { + // Pretend that we just did some really important stuff that was triggered + // by the escape key (like might occur in a popup that has a keyboard shortcut editor, for example). + // Now that we're done, we no longer need focus, so we won't accept future shorcut override events. + focus = false; + event.accepted = true; + ++escapeHandlerActivationCount; + } + } + + Shortcut { + sequence: "Escape" + onActivated: ++shortcutActivationCount + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index d0139b6cdf..8d974f4d17 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -172,6 +172,8 @@ private slots: void ignoreButtonPressNotInAcceptedMouseButtons(); + void shortcutOverride(); + private: enum PaintOrderOp { @@ -2036,6 +2038,39 @@ void tst_qquickitem::ignoreButtonPressNotInAcceptedMouseButtons() QCOMPARE(item.releaseCount, 1); } +void tst_qquickitem::shortcutOverride() +{ + QQuickView view; + view.setSource(testFileUrl("shortcutOverride.qml")); + ensureFocus(&view); + + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 0); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + + QQuickItem *escapeItem = view.rootObject()->property("escapeItem").value(); + QVERIFY(escapeItem); + QVERIFY(escapeItem->hasActiveFocus()); + + // escapeItem's onEscapePressed handler should accept the first escape press event. + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + // Now it shouldn't have focus, so it can't handle the next escape press event. + QVERIFY(!escapeItem->hasActiveFocus()); + + QTest::keyRelease(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0); + + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1); + + QTest::keyRelease(&view, Qt::Key_Escape); + QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1); + QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1); +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" -- cgit v1.2.3