From aa0448cf1882ddb6e4a959718a6fcc399c36990b Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 1 Aug 2011 18:26:57 +1000 Subject: Allow custom parser types to still get signal handlers generated Specifically, QDeclarativeListModelParser ought to have this behaviour. Task-number: QTBUG-19763 Change-Id: I9d6ee07d1e17a027b254b87d20d1a93795c55744 Reviewed-on: http://codereview.qt.nokia.com/2431 Reviewed-by: Martin Jones --- .../qdeclarativelistmodel/data/signalhandlers.qml | 8 ++++++++ .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml b/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml new file mode 100644 index 0000000000..750d99c5a3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +ListModel{ + property bool ok: false + property int foo: 5 + onFooChanged: ok = true + Component.onCompleted: foo = 6 +} diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index fd68933997..946a3a5692 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -107,6 +107,7 @@ private slots: void property_changes_worker(); void property_changes_worker_data(); void clear(); + void signal_handlers(); }; int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName) @@ -1192,6 +1193,18 @@ void tst_qdeclarativelistmodel::clear() QCOMPARE(model.toString(roles[2]), QString("propertyC")); } +void tst_qdeclarativelistmodel::signal_handlers() +{ + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/signalhandlers.qml")); + QObject *model = component.create(); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + QVERIFY(model != 0); + QVERIFY(model->property("ok").toBool()); + + delete model; +} + QTEST_MAIN(tst_qdeclarativelistmodel) #include "tst_qdeclarativelistmodel.moc" -- cgit v1.2.3 From ab40ff7046db2a922ae6959b44f1a52416566b7a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 2 Aug 2011 14:36:12 +1000 Subject: Fix broken GridView moved() test Test values for moving multiple items were incorrect. Change-Id: I184afee6c44df240ef39450c530ff5991cd591e5 Reviewed-on: http://codereview.qt.nokia.com/2485 Reviewed-by: Bea Lam Reviewed-by: Qt Sanity Bot --- tests/auto/declarative/qsggridview/tst_qsggridview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index e7dce4c86d..11d90eca6e 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -641,8 +641,8 @@ void tst_QSGGridView::moved() QSGItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60 + itemsOffsetAfterMove); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); name = findItem(contentItem, "textName", i); QVERIFY(name != 0); @@ -725,17 +725,17 @@ void tst_QSGGridView::moved_data() QTest::newRow("move multiple forwards, within visible items") << 0.0 << 0 << 5 << 3 - << 0.0; + << 60.0; // moved 3 items (i.e. 1 row) down QTest::newRow("move multiple forwards, from non-visible -> visible") << 120.0 // show 6-23 << 1 << 6 << 3 - << 0.0; + << 60.0; // top row moved, all items should shift down by 1 row QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)") << 120.0 // show 6-23 << 0 << 6 << 3 - << 0.0; + << 60.0; // top row moved, all items should shift down by 1 row QTest::newRow("move multiple forwards, from visible -> non-visible") << 0.0 @@ -745,7 +745,7 @@ void tst_QSGGridView::moved_data() QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)") << 0.0 << 0 << 16 << 3 - << 0.0; + << 60.0; QTest::newRow("move multiple backwards, within visible items") -- cgit v1.2.3 From 1b65161042108ee46ca42331dacc2b66b63c6b4e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 1 Aug 2011 16:20:26 +1000 Subject: Allow descendant chains to simultaneously be hovered. Matches GV behaviour. Also fixes a bug in QSGMouseArea, which we aren't fixing for QtQuick 1. Task-number: QTBUG-18175 Change-Id: I4ecac7b908504f28de830732c731281407d7b0bc Reviewed-on: http://codereview.qt.nokia.com/2422 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- .../qsgmousearea/data/hoverPropagation.qml | 54 ++++++++++++++++++++++ .../declarative/qsgmousearea/tst_qsgmousearea.cpp | 26 +++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/auto/declarative/qsgmousearea/data/hoverPropagation.qml (limited to 'tests') diff --git a/tests/auto/declarative/qsgmousearea/data/hoverPropagation.qml b/tests/auto/declarative/qsgmousearea/data/hoverPropagation.qml new file mode 100644 index 0000000000..c47c794132 --- /dev/null +++ b/tests/auto/declarative/qsgmousearea/data/hoverPropagation.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item{ + width: 400 + height: 200 + property bool point1: ma2.containsMouse && !ma1.containsMouse + property bool point2: ma3.containsMouse && ma4.containsMouse + Rectangle{ + width: 200 + height: 200 + color: ma1.containsMouse ? "red" : "white" + MouseArea{ + id: ma1 + hoverEnabled: true + anchors.fill: parent + } + Rectangle{ + width: 100 + height: 100 + color: ma2.containsMouse ? "blue" : "white" + MouseArea{ + id: ma2 + hoverEnabled: true + anchors.fill: parent + } + } + } + + Item{ + x:200 + Rectangle{ + width: 200 + height: 200 + color: ma3.containsMouse ? "yellow" : "white" + Rectangle{ + width: 100 + height: 100 + color: ma4.containsMouse ? "green" : "white" + } + } + MouseArea{ + id: ma3 + hoverEnabled: true + width: 200 + height: 200 + MouseArea{ + id: ma4 + width: 100 + height: 100 + hoverEnabled: true + } + } + } +} diff --git a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp index 8e711e6ceb..e9788cd147 100644 --- a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp +++ b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp @@ -75,6 +75,7 @@ private slots: void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); void hoverPosition(); + void hoverPropagation(); private: QSGView *createView(); @@ -741,6 +742,31 @@ void tst_QSGMouseArea::hoverPosition() delete canvas; } +void tst_QSGMouseArea::hoverPropagation() +{ + //QTBUG-18175, to behave like GV did. + QSGView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/hoverPropagation.qml")); + + QSGItem *root = canvas->rootObject(); + QVERIFY(root != 0); + + QCOMPARE(root->property("point1").toBool(), false); + QCOMPARE(root->property("point2").toBool(), false); + + QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0); + QApplication::sendEvent(canvas, &moveEvent); + QCOMPARE(root->property("point1").toBool(), true); + QCOMPARE(root->property("point2").toBool(), false); + + QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0); + QApplication::sendEvent(canvas, &moveEvent2); + QCOMPARE(root->property("point1").toBool(), false); + QCOMPARE(root->property("point2").toBool(), true); + + delete canvas; +} + QTEST_MAIN(tst_QSGMouseArea) #include "tst_qsgmousearea.moc" -- cgit v1.2.3 From 29e71ca376f48bafc2105b656a702f3edd4501a8 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 1 Aug 2011 16:56:45 +1000 Subject: Fix content position for key navigation with StrictlyEnforceRange If a ListView had highlight ranges and StrictlyEnforceRange, but no highlight item, the content would not move to the correct position when incrementCurrentIndex() and decrementCurrentIndex() were invoked. trackedPositionChanged() shouldn't take the current section pos into account because this is already calculated by FxListItemSG::position() (this wasn't the case when the code in trackedPositionChanged() was originally written). Task-number: QTBUG-20287 Change-Id: I1624b5afd1efbe27630349143b7af2b486cfa260 Reviewed-on: http://codereview.qt.nokia.com/2429 Reviewed-by: Qt Sanity Bot Reviewed-by: Bea Lam Reviewed-by: Martin Jones --- .../data/listview-enforcerange-nohighlight.qml | 60 ++++++++++++++++++++++ .../declarative/qsglistview/tst_qsglistview.cpp | 46 +++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml (limited to 'tests') diff --git a/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml b/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml new file mode 100644 index 0000000000..946f4f2046 --- /dev/null +++ b/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 20 + width: 240 + color: "transparent" + Text { + text: index + } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 120 + id: textNumber + objectName: "textNumber" + text: number + } + Text { + x: 200 + text: wrapper.y + } + } + } + + Rectangle { // current listview item should be always in this area + y: 100 + height: 20 + width: 240 + color: "purple" + } + + ListView { + id: list + objectName: "list" + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + preferredHighlightBegin: 100 + preferredHighlightEnd: 100 + highlightRangeMode: "StrictlyEnforceRange" + + section.property: "number" + section.delegate: Rectangle { width: 240; height: 10; color: "lightsteelblue" } + } +} + diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 5ee13e8724..f4a2384729 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -98,6 +98,7 @@ private slots: void currentIndex(); void noCurrentIndex(); void enforceRange(); + void enforceRange_withoutHighlight(); void spacing(); void sections(); void sectionsDelegate(); @@ -1113,6 +1114,51 @@ void tst_QSGListView::enforceRange() delete canvas; } +void tst_QSGListView::enforceRange_withoutHighlight() +{ + // QTBUG-20287 + // If no highlight is set but StrictlyEnforceRange is used, the content should still move + // to the correct position (i.e. to the next/previous item, not next/previous section) + // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex() + + QSGView *canvas = createView(); + canvas->show(); + + TestModel model; + model.addItem("Item 0", "a"); + model.addItem("Item 1", "b"); + model.addItem("Item 2", "b"); + model.addItem("Item 3", "c"); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange-nohighlight.qml")); + qApp->processEvents(); + + QSGListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + qreal expectedPos = -100.0; + + expectedPos += 10.0; // scroll past 1st section's delegate (10px height) + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section + QTest::keyClick(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20; // scroll past 1st item of 2nd section + QTest::keyClick(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section + QTest::keyClick(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->contentY(), expectedPos); + + delete canvas; +} + void tst_QSGListView::spacing() { QSGView *canvas = createView(); -- cgit v1.2.3 From 0db6db0263defcd6ff84769b7d927d5a51606f6c Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 2 Aug 2011 10:04:16 +1000 Subject: Add support for comparing value-type properties This commit allows value-types to be compared with each other and with variants. It also adds a toString() function for each value type, to allow conversion to (and comparison with) string. Task-number: QTBUG-14731 Change-Id: I5bde2820917b2fe19b581724977398680617de34 Reviewed-on: http://codereview.qt.nokia.com/1636 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- .../qdeclarativevaluetypes/data/font_compare.qml | 31 +++ .../data/matrix4x4_compare.qml | 35 ++++ .../qdeclarativevaluetypes/data/point_compare.qml | 22 ++ .../qdeclarativevaluetypes/data/pointf_compare.qml | 22 ++ .../data/quaternion_compare.qml | 23 +++ .../qdeclarativevaluetypes/data/rect_compare.qml | 25 +++ .../qdeclarativevaluetypes/data/rectf_compare.qml | 25 +++ .../qdeclarativevaluetypes/data/size_compare.qml | 23 +++ .../qdeclarativevaluetypes/data/sizef_compare.qml | 24 +++ .../data/vector2d_compare.qml | 21 ++ .../data/vector3d_compare.qml | 23 +++ .../data/vector4d_compare.qml | 23 +++ .../declarative/qdeclarativevaluetypes/testtypes.h | 18 ++ .../tst_qdeclarativevaluetypes.cpp | 229 +++++++++++++++++++++ 14 files changed, 544 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml new file mode 100644 index 0000000000..efbb0e3d0b --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml @@ -0,0 +1,31 @@ +import Test 1.0 + +MyTypeObject { + property string f_family: font.family + property bool f_bold: font.bold + property int f_weight: font.weight + property bool f_italic: font.italic + property bool f_underline: font.underline + property bool f_overline: font.overline + property bool f_strikeout: font.strikeout + property real f_pointSize: font.pointSize + property int f_pixelSize: font.pixelSize + property int f_capitalization: font.capitalization + property real f_letterSpacing: font.letterSpacing + property real f_wordSpacing: font.wordSpacing; + property variant copy: font + property string tostring: font.toString() + + // compare to string + property bool equalsString: (font == tostring) + + // compare fonts to various value types + property bool equalsColor: (font == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (font == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (font == Qt.size(1912, 1913)) // false + property bool equalsPoint: (font == Qt.point(10, 4)) // false + property bool equalsRect: (font == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (font == font) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml new file mode 100644 index 0000000000..94292302cc --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml @@ -0,0 +1,35 @@ +import Test 1.0 + +MyTypeObject { + property real v_m11: matrix.m11 + property real v_m12: matrix.m12 + property real v_m13: matrix.m13 + property real v_m14: matrix.m14 + property real v_m21: matrix.m21 + property real v_m22: matrix.m22 + property real v_m23: matrix.m23 + property real v_m24: matrix.m24 + property real v_m31: matrix.m31 + property real v_m32: matrix.m32 + property real v_m33: matrix.m33 + property real v_m34: matrix.m34 + property real v_m41: matrix.m41 + property real v_m42: matrix.m42 + property real v_m43: matrix.m43 + property real v_m44: matrix.m44 + property variant copy: matrix + property string tostring: matrix.toString() + + // compare to string + property bool equalsString: (matrix == tostring) + + // compare matrix4x4s to various value types + property bool equalsColor: (matrix == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (matrix == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (matrix == Qt.size(1912, 1913)) // false + property bool equalsPoint: (matrix == Qt.point(10, 4)) // false + property bool equalsRect: (matrix == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (matrix == matrix) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml new file mode 100644 index 0000000000..c0041b4bb1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property int p_x: point.x + property int p_y: point.y + property variant copy: point + property string tostring: point.toString() + + // compare to string + property bool equalsString: (point == tostring) + + // compare points to various value types + property bool equalsColor: (point == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (point == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (point == Qt.size(1912, 1913)) // false + property bool equalsPoint: (point == Qt.point(10, 4)) // true + property bool equalsRect: (point == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (point == point) // true + property bool equalsOther: (point == Qt.point(15, 4)) // false + property bool pointEqualsPointf: (point == pointfpoint) // true +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml new file mode 100644 index 0000000000..0d70137934 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property int p_x: point.x + property int p_y: point.y + property variant copy: point + property string tostring: pointf.toString() + + // compare to string + property bool equalsString: (pointf == tostring) + + // compare pointfs to various value types + property bool equalsColor: (pointf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (pointf == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (pointf == Qt.size(1912, 1913)) // false + property bool equalsPoint: (pointf == Qt.point(11.3, -10.9)) // true + property bool equalsRect: (pointf == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (pointf == pointf) // true + property bool equalsOther: (pointf == Qt.point(6.3, -4.9)) // false + property bool pointfEqualsPoint: (pointfpoint == point) // true +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml new file mode 100644 index 0000000000..0e82f596af --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_scalar: quaternion.scalar + property real v_x: quaternion.x + property real v_y: quaternion.y + property real v_z: quaternion.z + property variant copy: quaternion + property string tostring: quaternion.toString() + + // compare to string + property bool equalsString: (quaternion == tostring) + + // compare quaternions to various value types + property bool equalsColor: (quaternion == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (quaternion == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (quaternion == Qt.size(1912, 1913)) // false + property bool equalsPoint: (quaternion == Qt.point(10, 4)) // false + property bool equalsRect: (quaternion == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (quaternion == quaternion) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml new file mode 100644 index 0000000000..c511c2dfc4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml @@ -0,0 +1,25 @@ +import Test 1.0 + +MyTypeObject { + property int r_x: rect.x + property int r_y: rect.y + property int r_width: rect.width + property int r_height: rect.height + property variant copy: rect + property string tostring: rect.toString() + + // compare to string + property bool equalsString: (rect == tostring) + + // compare rects to various value types + property bool equalsColor: (rect == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (rect == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (rect == Qt.size(1912, 1913)) // false + property bool equalsPoint: (rect == Qt.point(10, 4)) // false + property bool equalsRect: (rect == Qt.rect(2, 3, 109, 102)) // true + + property bool equalsSelf: (rect == rect) // true + property bool equalsOther: (rect == Qt.rect(6, 9, 99, 92)) // false + property bool rectEqualsRectf: (rect == rectfrect) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml new file mode 100644 index 0000000000..6ac4049558 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml @@ -0,0 +1,25 @@ +import Test 1.0 + +MyTypeObject { + property real r_x: rectf.x + property real r_y: rectf.y + property real r_width: rectf.width + property real r_height: rectf.height + property variant copy: rectf + property string tostring: rectf.toString() + + // compare to string + property bool equalsString: (rectf == tostring) + + // compare rectfs to various value types + property bool equalsColor: (rectf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (rectf == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (rectf == Qt.size(1912, 1913)) // false + property bool equalsPoint: (rectf == Qt.point(10, 4)) // false + property bool equalsRect: (rectf == Qt.rect(103.8, 99.2, 88.1, 77.6)) // true + + property bool equalsSelf: (rectf == rectf) // true + property bool equalsOther: (rectf == Qt.rect(13.8, 9.2, 78.7, 96.2)) // false + property bool rectfEqualsRect: (rectfrect == rect) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml new file mode 100644 index 0000000000..1fd4711c15 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: size.width + property int s_height: size.height + property variant copy: size + property string tostring: size.toString() + + // compare to string + property bool equalsString: (size == tostring) + + // compare sizes to various value types + property bool equalsColor: (size == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (size == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (size == Qt.size(1912, 1913)) // true + property bool equalsPoint: (size == Qt.point(10, 4)) // false + property bool equalsRect: (size == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (size == size) // true + property bool equalsOther: (size == Qt.size(1212, 1313)) // false + property bool sizeEqualsSizef: (size == sizefsize) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml new file mode 100644 index 0000000000..c74a049454 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml @@ -0,0 +1,24 @@ +import Test 1.0 + +MyTypeObject { + property real s_width: sizef.width + property real s_height: sizef.height + property variant copy: sizef + property string tostring: sizef.toString() + + // compare to string + property bool equalsString: (sizef == tostring) + + // compare sizefs to various value types + property bool equalsColor: (sizef == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (sizef == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (sizef == Qt.size(0.1, 100923.2)) // true + property bool equalsPoint: (sizef == Qt.point(10, 4)) // false + property bool equalsRect: (sizef == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (sizef == sizef) // true + property bool equalsOther: (size == Qt.size(3.1, 923.2)) // false + property bool sizefEqualsSize: (sizefsize == size) // true +} + + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml new file mode 100644 index 0000000000..eb8fb5bb76 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml @@ -0,0 +1,21 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector2.x + property real v_y: vector2.y + property variant copy: vector2 + property string tostring: vector2.toString() + + // compare to string + property bool equalsString: (vector2 == tostring) + + // compare vector2ds to various value types + property bool equalsColor: (vector2 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector2 == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (vector2 == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector2 == Qt.point(10, 4)) // false + property bool equalsRect: (vector2 == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector2 == vector2) +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml new file mode 100644 index 0000000000..7bda1d17f4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector.x + property real v_y: vector.y + property real v_z: vector.z + property variant copy: vector + property string tostring: vector.toString() + + // compare to string + property bool equalsString: (vector == tostring) + + // compare vector3ds to various value types + property bool equalsColor: (vector == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector == Qt.vector3d(23.88, 3.1, 4.3)) // true + property bool equalsSize: (vector == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector == Qt.point(10, 4)) // false + property bool equalsRect: (vector == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector == vector) // true + property bool equalsOther: (vector == Qt.vector3d(3.1, 2.2, 923.2)) // false +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml new file mode 100644 index 0000000000..3ea42a59ce --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector4.x + property real v_y: vector4.y + property real v_z: vector4.z + property real v_w: vector4.w + property variant copy: vector4 + property string tostring: vector4.toString() + + // compare to string + property bool equalsString: (vector4 == tostring) + + // compare vector4ds to various value types + property bool equalsColor: (vector4 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector4 == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (vector4 == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector4 == Qt.point(10, 4)) // false + property bool equalsRect: (vector4 == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector4 == vector4) // true +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 6d6f868617..1efab0c423 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -65,11 +65,14 @@ class MyTypeObject : public QObject Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed) Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed) + Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed) Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed) + Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed) Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed) Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) + Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed) Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed) Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed) @@ -82,10 +85,13 @@ public: MyTypeObject() : m_point(10, 4), m_pointf(11.3, -10.9), + m_pointfpoint(10.0, 4.0), m_size(1912, 1913), m_sizef(0.1, 100923.2), + m_sizefsize(1912.0, 1913.0), m_rect(2, 3, 109, 102), m_rectf(103.8, 99.2, 88.1, 77.6), + m_rectfrect(2.0, 3.0, 109.0, 102.0), m_vector2(32.88, 1.3), m_vector(23.88, 3.1, 4.3), m_vector4(54.2, 23.88, 3.1, 4.3), @@ -113,6 +119,10 @@ public: QPointF pointf() const { return m_pointf; } void setPointf(const QPointF &v) { m_pointf = v; emit changed(); } + QPointF m_pointfpoint; + QPointF pointfpoint() const { return m_pointfpoint; } + void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); } + QSize m_size; QSize size() const { return m_size; } void setSize(const QSize &v) { m_size = v; emit changed(); } @@ -121,6 +131,10 @@ public: QSizeF sizef() const { return m_sizef; } void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); } + QSizeF m_sizefsize; + QSizeF sizefsize() const { return m_sizefsize; } + void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); } + QRect m_rect; QRect rect() const { return m_rect; } void setRect(const QRect &v) { m_rect = v; emit changed(); } @@ -129,6 +143,10 @@ public: QRectF rectf() const { return m_rectf; } void setRectf(const QRectF &v) { m_rectf = v; emit changed(); } + QRectF m_rectfrect; + QRectF rectfrect() const { return m_rectfrect; } + void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); } + QVector2D m_vector2; QVector2D vector2() const { return m_vector2; } void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index aa4c014d99..5869310ef6 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -134,6 +134,26 @@ void tst_qdeclarativevaluetypes::point() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("point_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QPoint(10, 4)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), true); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("pointEqualsPointf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::pointf() @@ -159,6 +179,26 @@ void tst_qdeclarativevaluetypes::pointf() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("pointf_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QPointF(11.3, -10.9)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), true); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("pointfEqualsPoint").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::size() @@ -184,6 +224,26 @@ void tst_qdeclarativevaluetypes::size() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("size_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QSize(1912, 1913)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), true); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("sizeEqualsSizef").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::sizef() @@ -209,6 +269,26 @@ void tst_qdeclarativevaluetypes::sizef() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizef_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QSizeF(0.1, 100923)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), true); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("sizefEqualsSize").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::variant() @@ -293,6 +373,26 @@ void tst_qdeclarativevaluetypes::rect() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("rect_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QRect(2, 3, 109, 102)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), true); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("rectEqualsRectf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::rectf() @@ -320,6 +420,26 @@ void tst_qdeclarativevaluetypes::rectf() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("rectf_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), true); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("rectfEqualsRect").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::vector2d() @@ -345,6 +465,24 @@ void tst_qdeclarativevaluetypes::vector2d() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("vector2d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector2D(32.88, 1.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::vector3d() @@ -371,6 +509,25 @@ void tst_qdeclarativevaluetypes::vector3d() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("vector3d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), true); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + + delete object; + } } void tst_qdeclarativevaluetypes::vector4d() @@ -398,6 +555,24 @@ void tst_qdeclarativevaluetypes::vector4d() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("vector4d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::quaternion() @@ -425,6 +600,24 @@ void tst_qdeclarativevaluetypes::quaternion() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("quaternion_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::matrix4x4() @@ -471,6 +664,24 @@ void tst_qdeclarativevaluetypes::matrix4x4() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } } void tst_qdeclarativevaluetypes::font() @@ -576,6 +787,24 @@ void tst_qdeclarativevaluetypes::font() delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("font_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QFont(Arial,29,-1,0,63,1,1,1,0,0)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } } // Test bindings can write to value types -- cgit v1.2.3 From 6f146a5d2ea893b13e4cfcd90243e66f7c9a0083 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 12 Jul 2011 15:55:01 +1000 Subject: Ensure that the prototype chain is checked in property Get This commit ensures that the prototype chain is checked during property Get operations on QObjects and other types in QML by returning an empty handle from the property Get interceptor if no valid property with the given name is found. Task-number: QTBUG-20336 Change-Id: I670ee211c74c0fdcb68c3f91b29fcc0ea8b55d6f Reviewed-on: http://codereview.qt.nokia.com/1477 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy Reviewed-by: Kent Hansen --- .../data/declarativeHasOwnProperty.qml | 72 ++++++++++++++++++++++ .../tst_qdeclarativeecmascript.cpp | 50 +++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml new file mode 100644 index 0000000000..12598b3b9f --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml @@ -0,0 +1,72 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import Qt.test.qobjectApi 1.0 as QtTestQObjectApi + +Item { + id: obj + objectName: "objName" + property int someIntProperty: 10 + property bool result: false + + function testHasOwnPropertySuccess() + { + obj.result = obj.hasOwnProperty("someIntProperty"); + } + + function testHasOwnPropertyFailure() + { + obj.result = obj.hasOwnProperty("someNonexistentProperty"); + } + + MyTypeObject { + id: typeObj + objectName: "typeObj" + pointProperty: Qt.point(34, 29) + variantProperty: Qt.vector3d(1, 2, 3) + stringProperty: "test string" + property list listProperty: [ Rectangle { width: 10; height: 10 } ] + property list emptyListProperty + + property bool valueTypeHasOwnProperty + property bool valueTypeHasOwnProperty2 + property bool variantTypeHasOwnProperty + property bool stringTypeHasOwnProperty + property bool listTypeHasOwnProperty + property bool listAtValidHasOwnProperty + property bool emptyListTypeHasOwnProperty + property bool enumTypeHasOwnProperty + property bool typenameHasOwnProperty + property bool typenameHasOwnProperty2 + property bool moduleApiTypeHasOwnProperty + property bool moduleApiPropertyTypeHasOwnProperty + function testHasOwnPropertySuccess() { + valueTypeHasOwnProperty = !typeObj.pointProperty.hasOwnProperty("nonexistentpropertyname"); + valueTypeHasOwnProperty2 = typeObj.pointProperty.hasOwnProperty("x"); // should be true + variantTypeHasOwnProperty = !typeObj.variantProperty.hasOwnProperty("nonexistentpropertyname"); + stringTypeHasOwnProperty = !typeObj.stringProperty.hasOwnProperty("nonexistentpropertyname"); + listTypeHasOwnProperty = !typeObj.listProperty.hasOwnProperty("nonexistentpropertyname"); + listAtValidHasOwnProperty = !typeObj.listProperty[0].hasOwnProperty("nonexistentpropertyname"); + emptyListTypeHasOwnProperty = !typeObj.emptyListProperty.hasOwnProperty("nonexistentpropertyname"); + enumTypeHasOwnProperty = !MyTypeObject.EnumVal1.hasOwnProperty("nonexistentpropertyname"); + typenameHasOwnProperty = !MyTypeObject.hasOwnProperty("nonexistentpropertyname"); + typenameHasOwnProperty2 = MyTypeObject.hasOwnProperty("EnumVal1"); // should be true. + moduleApiTypeHasOwnProperty = !QtTestQObjectApi.hasOwnProperty("nonexistentpropertyname"); + moduleApiPropertyTypeHasOwnProperty = !QtTestQObjectApi.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname"); + } + + property bool enumNonValueHasOwnProperty + function testHasOwnPropertyFailureOne() { + enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname"); + } + + property bool moduleApiNonPropertyHasOwnProperty + function testHasOwnPropertyFailureTwo() { + moduleApiNonPropertyHasOwnProperty = !QtTestQObjectApi.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname"); + } + + property bool listAtInvalidHasOwnProperty + function testHasOwnPropertyFailureThree() { + listAtInvalidHasOwnProperty = !typeObj.listProperty[5].hasOwnProperty("nonexistentpropertyname"); + } + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 6c629a80f7..c5f7ed1b58 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -113,6 +113,7 @@ private slots: void dynamicCreation(); void dynamicDestruction(); void objectToString(); + void objectHasOwnProperty(); void selfDeletingBinding(); void extendedObjectPropertyLookup(); void scriptErrors(); @@ -1140,6 +1141,55 @@ void tst_qdeclarativeecmascript::objectToString() delete object; } +/* + tests that id.hasOwnProperty() works +*/ +void tst_qdeclarativeecmascript::objectHasOwnProperty() +{ + QUrl url = TEST_FILE("declarativeHasOwnProperty.qml"); + QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + + QDeclarativeComponent component(&engine, url); + QObject *object = component.create(); + QVERIFY(object != 0); + + // test QObjects in QML + QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess"); + QVERIFY(object->property("result").value() == true); + QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure"); + QVERIFY(object->property("result").value() == false); + + // now test other types in QML + QObject *child = object->findChild("typeObj"); + QVERIFY(child != 0); + QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess"); + QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true); + QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true); + QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true); + QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true); + + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne"); + QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo"); + QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree"); + QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false); + + delete object; +} + /* Tests bindings that indirectly cause their own deletion work. -- cgit v1.2.3 From 09f4bd20d7514f229338667effdf8519f1722b3f Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 29 Jul 2011 10:38:35 +1000 Subject: Cancel mousearea pressed state when window is deactivated Change-Id: I1cc21c338576a2ac3b1e8e282e8e4de3bc63759a Task-number:QTBUG-19904 Reviewed-on: http://codereview.qt.nokia.com/2357 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../qsgmousearea/data/pressedCanceled.qml | 18 +++++++++ .../declarative/qsgmousearea/tst_qsgmousearea.cpp | 45 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/auto/declarative/qsgmousearea/data/pressedCanceled.qml (limited to 'tests') diff --git a/tests/auto/declarative/qsgmousearea/data/pressedCanceled.qml b/tests/auto/declarative/qsgmousearea/data/pressedCanceled.qml new file mode 100644 index 0000000000..231436d0f2 --- /dev/null +++ b/tests/auto/declarative/qsgmousearea/data/pressedCanceled.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + id: root + color: "#ffffff" + width: 320; height: 240 + property bool pressed:mouse.pressed + property bool canceled: false + property bool released: false + + MouseArea { + id: mouse + anchors.fill: parent + onPressed: { root.canceled = false } + onCanceled: {root.canceled = true} + onReleased: {root.released = true; root.canceled = false} + } +} \ No newline at end of file diff --git a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp index e9788cd147..6e731d1682 100644 --- a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp +++ b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp @@ -67,6 +67,7 @@ private slots: void updateMouseAreaPosOnResize(); void noOnClickedWithPressAndHold(); void onMousePressRejected(); + void pressedCanceledOnWindowDeactivate(); void doubleClick(); void clickTwice(); void pressedOrdering(); @@ -418,7 +419,51 @@ void tst_QSGMouseArea::onMousePressRejected() delete canvas; } +void tst_QSGMouseArea::pressedCanceledOnWindowDeactivate() +{ + QSGView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pressedCanceled.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(canvas, &pressEvent); + + QVERIFY(canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QTest::qWait(200); + + QEvent windowDeactivateEvent(QEvent::WindowDeactivate); + QApplication::sendEvent(canvas, &windowDeactivateEvent); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + QTest::qWait(200); + + //press again + QApplication::sendEvent(canvas, &pressEvent); + QVERIFY(canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QTest::qWait(200); + + //release + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(canvas, &releaseEvent); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(canvas->rootObject()->property("released").toBool()); + + delete canvas; +} void tst_QSGMouseArea::doubleClick() { QSGView *canvas = createView(); -- cgit v1.2.3 From 6494f5c5aaec82cc5bcfd42de559d723edef57b1 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 1 Aug 2011 13:09:10 +1000 Subject: Add a currentItem property to PathView. Task-number: QTBUG-16347 Change-Id: I6df4b2d7c5f325e84d54ed5befd66e20b64cc7e0 Reviewed-on: http://codereview.qt.nokia.com/2421 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../declarative/qsgpathview/data/pathview0.qml | 1 + .../declarative/qsgpathview/tst_qsgpathview.cpp | 58 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsgpathview/data/pathview0.qml b/tests/auto/declarative/qsgpathview/data/pathview0.qml index 72b71a3c80..8b9378163f 100644 --- a/tests/auto/declarative/qsgpathview/data/pathview0.qml +++ b/tests/auto/declarative/qsgpathview/data/pathview0.qml @@ -17,6 +17,7 @@ Rectangle { Rectangle { id: wrapper objectName: "wrapper" + property bool onPath: PathView.onPath height: root.delegateHeight width: root.delegateWidth scale: root.delegateScale diff --git a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp index 91f6491493..00202f7436 100644 --- a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp +++ b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp @@ -423,6 +423,7 @@ void tst_QSGPathView::dataModel() QTRY_COMPARE(findItems(pathview, "wrapper").count(), 14); QVERIFY(pathview->currentIndex() == 0); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); QSGText *text = findItem(pathview, "myText", 4); QVERIFY(text); @@ -433,6 +434,7 @@ void tst_QSGPathView::dataModel() text = findItem(pathview, "myText", 2); QVERIFY(text); QCOMPARE(text->text(), model.name(2)); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); testObject->setPathItemCount(5); QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); @@ -446,12 +448,15 @@ void tst_QSGPathView::dataModel() QVERIFY(testItem == 0); pathview->setCurrentIndex(1); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); + QTest::qWait(100); model.insertItem(2, "pink", "2"); QTest::qWait(100); QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); QVERIFY(pathview->currentIndex() == 1); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); text = findItem(pathview, "myText", 2); QVERIFY(text); @@ -462,6 +467,7 @@ void tst_QSGPathView::dataModel() text = findItem(pathview, "myText", 3); QVERIFY(text); QCOMPARE(text->text(), model.name(3)); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); model.moveItem(3, 5); QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); @@ -469,6 +475,7 @@ void tst_QSGPathView::dataModel() foreach (QSGItem *item, items) { QVERIFY(item->property("onPath").toBool()); } + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); // QTBUG-14199 pathview->setOffset(7); @@ -578,30 +585,81 @@ void tst_QSGPathView::setCurrentIndex() QTRY_COMPARE(firstItem->pos() + offset, start); QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 1); firstItem = findItem(pathview, "wrapper", 1); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 0); firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 3); firstItem = findItem(pathview, "wrapper", 3); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); pathview->incrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 0); firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + // Check the current item is still created when outside the bounds of pathItemCount. + pathview->setPathItemCount(2); + pathview->setHighlightRangeMode(QSGPathView::NoHighlightRange); + QVERIFY(findItem(pathview, "wrapper", 0)); + QVERIFY(findItem(pathview, "wrapper", 1)); + QVERIFY(!findItem(pathview, "wrapper", 2)); + QVERIFY(!findItem(pathview, "wrapper", 3)); + + pathview->setCurrentIndex(2); + firstItem = findItem(pathview, "wrapper", 2); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(false)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem(pathview, "wrapper", 1); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(false)); + + pathview->incrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); delete canvas; } -- cgit v1.2.3 From dfdf7d054f83409c04d963e8aa8d2bb4d47a84c0 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Mon, 1 Aug 2011 12:48:34 +0200 Subject: Enable globalObjectProperties_enumerate test. The test can be enabled because QJSValueIterator is back. Change-Id: I81220ea17470663dab799eb818168480d2df1a54 Reviewed-on: http://codereview.qt.nokia.com/2439 Reviewed-by: Qt Sanity Bot Reviewed-by: Kent Hansen --- tests/auto/declarative/qjsengine/tst_qjsengine.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp index 49febdbf5e..17fe8c2950 100644 --- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -138,9 +139,7 @@ private slots: #endif void globalObjectProperties(); void globalObjectEquals(); -#if 0 // ###FIXME: No QScriptValueIterator API void globalObjectProperties_enumerate(); -#endif void createGlobalObjectProperty(); void globalObjectGetterSetterProperty(); #if 0 // ###FIXME: No support for setting the global object @@ -1560,11 +1559,10 @@ void tst_QJSEngine::globalObjectEquals() QVERIFY(o.equals(eng.globalObject())); } -#if 0 // ###FIXME: No QScriptValueIterator API void tst_QJSEngine::globalObjectProperties_enumerate() { - QScriptEngine eng; - QScriptValue global = eng.globalObject(); + QJSEngine eng; + QJSValue global = eng.globalObject(); QSet expectedNames; expectedNames @@ -1598,10 +1596,6 @@ void tst_QJSEngine::globalObjectProperties_enumerate() << "unescape" << "SyntaxError" << "undefined" - // non-standard - << "gc" - << "version" - << "print" // JavaScriptCore << "JSON" // V8 @@ -1609,7 +1603,7 @@ void tst_QJSEngine::globalObjectProperties_enumerate() ; QSet actualNames; { - QScriptValueIterator it(global); + QJSValueIterator it(global); while (it.hasNext()) { it.next(); actualNames.insert(it.name()); @@ -1627,7 +1621,6 @@ void tst_QJSEngine::globalObjectProperties_enumerate() } QVERIFY(remainingNames.isEmpty()); } -#endif void tst_QJSEngine::createGlobalObjectProperty() { -- cgit v1.2.3 From 1f0c9055daf10df1afce8f722c30415c12802ee4 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Mon, 1 Aug 2011 13:31:19 +0200 Subject: Enable tst_QJSEngine::stacktrace test. The test can be enabled because QJSValueIterator is back. Change-Id: I33a84b0e584137ecff0d65c2a6152ca972e863f1 Reviewed-on: http://codereview.qt.nokia.com/2440 Reviewed-by: Qt Sanity Bot Reviewed-by: Kent Hansen --- tests/auto/declarative/qjsengine/tst_qjsengine.cpp | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp index 17fe8c2950..d2f4b3b6ac 100644 --- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp @@ -202,9 +202,7 @@ private slots: void throwErrorFromProcessEvents(); void disableProcessEventsInterval(); #endif -#if 0 // ###FIXME: No QScriptValueIterator API void stacktrace(); -#endif void numberParsing_data(); void numberParsing(); void automaticSemicolonInsertion(); @@ -3323,7 +3321,7 @@ void tst_QJSEngine::disableProcessEventsInterval() } #endif -#if 0 // ###FIXME: No QScriptValueIterator API + void tst_QJSEngine::stacktrace() { QString script = QString::fromLatin1( @@ -3351,34 +3349,36 @@ void tst_QJSEngine::stacktrace() << "foo(0)@testfile:3" << "()@testfile:12"; - QScriptEngine eng; - QScriptValue result = eng.evaluate(script, fileName); + QJSEngine eng; + QJSValue result = eng.evaluate(script, fileName); QVERIFY(eng.hasUncaughtException()); QVERIFY(result.isError()); - QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); + // QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); // ###FIXME: no uncahgutExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); QVERIFY(eng.hasUncaughtException()); QVERIFY(result.strictlyEquals(eng.uncaughtException())); - QCOMPARE(result.property("fileName").toString(), fileName); - QCOMPARE(result.property("lineNumber").toInt32(), 9); + // FIXME? it is not standard. + //QCOMPARE(result.property("fileName").toString(), fileName); + //QCOMPARE(result.property("lineNumber").toInt32(), 9); - QScriptValue stack = result.property("stack"); - QVERIFY(stack.isArray()); + QJSValue stack = result.property("stack"); - QCOMPARE(stack.property("length").toInt32(), 7); + // FIXME? it is not standard. + // QVERIFY(stack.isArray()); + //QCOMPARE(stack.property("length").toInt32(), 7); - QScriptValueIterator it(stack); + QJSValueIterator it(stack); int counter = 5; while (it.hasNext()) { it.next(); - QScriptValue obj = it.value(); - QScriptValue frame = obj.property("frame"); + QJSValue obj = it.value(); + QJSValue frame = obj.property("frame"); QCOMPARE(obj.property("fileName").toString(), fileName); if (counter >= 0) { - QScriptValue callee = frame.property("arguments").property("callee"); + QJSValue callee = frame.property("arguments").property("callee"); QVERIFY(callee.strictlyEquals(eng.globalObject().property("foo"))); QCOMPARE(obj.property("functionName").toString(), QString("foo")); int line = obj.property("lineNumber").toInt32(); @@ -3394,10 +3394,11 @@ void tst_QJSEngine::stacktrace() --counter; } - { - QScriptValue bt = result.property("backtrace").call(result); - QCOMPARE(qscriptvalue_cast(bt), backtrace); - } +// FIXME? it is not standard. +// { +// QJSValue bt = result.property("backtrace").call(result); +// QCOMPARE(qjsvalue_cast(bt), backtrace); +// } // throw something that isn't an Error object eng.clearExceptions(); @@ -3416,7 +3417,7 @@ void tst_QJSEngine::stacktrace() "}\n" "foo(0);"); - QScriptValue result2 = eng.evaluate(script2, fileName); + QJSValue result2 = eng.evaluate(script2, fileName); QVERIFY(eng.hasUncaughtException()); QVERIFY(!result2.isError()); QVERIFY(result2.isString()); @@ -3428,7 +3429,6 @@ void tst_QJSEngine::stacktrace() QVERIFY(!eng.hasUncaughtException()); // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); } -#endif void tst_QJSEngine::numberParsing_data() { -- cgit v1.2.3 From 5084c274aac111db3f5f0c38258aa06aa9448bda Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 3 Aug 2011 11:01:52 +1000 Subject: Prevent Binding from crashing when its target object is deleted. Task-number: QTBUG-20692 Change-Id: Ia9a3d532c45baf01b8c20c7aac9ef373942a75d8 Reviewed-on: http://codereview.qt.nokia.com/2531 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../qdeclarativebinding/data/deletedObject.qml | 24 ++++++++++++++++++++++ .../tst_qdeclarativebinding.cpp | 17 +++++++++++++++ .../qdeclarativebinding/data/deletedObject.qml | 24 ++++++++++++++++++++++ .../tst_qdeclarativebinding.cpp | 17 +++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml create mode 100644 tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml b/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml new file mode 100644 index 0000000000..f9cf869ba3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 400 + height: 400 + + property bool activateBinding: false + + Binding { + id: binding + target: Qt.createQmlObject('import QtQuick 2.0; Item { property real value: 10 }', wrapper) + property: "value" + when: activateBinding + value: x + y + } + + Component.onCompleted: binding.target.destroy(); + +// MouseArea { +// anchors.fill: parent +// onClicked: activateBinding = true; +// } +} diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp index 2e64fed0ed..3effd68b39 100644 --- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -62,6 +62,7 @@ private slots: void whenAfterValue(); void restoreBinding(); void restoreBindingWithLoop(); + void deletedObject(); private: QDeclarativeEngine engine; @@ -179,6 +180,22 @@ void tst_qdeclarativebinding::restoreBindingWithLoop() delete rect; } +//QTBUG-20692 +void tst_qdeclarativebinding::deletedObject() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/deletedObject.qml")); + QSGRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QApplication::sendPostedEvents(0, QEvent::DeferredDelete); + + //don't crash + rect->setProperty("activateBinding", true); + + delete rect; +} + QTEST_MAIN(tst_qdeclarativebinding) #include "tst_qdeclarativebinding.moc" diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml b/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml new file mode 100644 index 0000000000..ba4c9f6f7c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 400 + height: 400 + + property bool activateBinding: false + + Binding { + id: binding + target: Qt.createQmlObject('import QtQuick 1.0; Item { property real value: 10 }', wrapper) + property: "value" + when: activateBinding + value: x + y + } + + Component.onCompleted: binding.target.destroy(); + +// MouseArea { +// anchors.fill: parent +// onClicked: activateBinding = true; +// } +} diff --git a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp index 776fa528cf..54ff801375 100644 --- a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -60,6 +60,7 @@ public: private slots: void binding(); void whenAfterValue(); + void deletedObject(); private: QDeclarativeEngine engine; @@ -113,6 +114,22 @@ void tst_qdeclarativebinding::whenAfterValue() delete rect; } +//QTBUG-20692 +void tst_qdeclarativebinding::deletedObject() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/deletedObject.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QApplication::sendPostedEvents(0, QEvent::DeferredDelete); + + //don't crash + rect->setProperty("activateBinding", true); + + delete rect; +} + QTEST_MAIN(tst_qdeclarativebinding) #include "tst_qdeclarativebinding.moc" -- cgit v1.2.3 From 02a19405aab1df31a40896de3d928d8878402052 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 3 Aug 2011 15:45:47 +1000 Subject: Fix crash in QDeclarativeProperty This commit ensures that we don't attempt to dereference a null pointer in QDeclarativeProperty. It also fixes a unit test failure by adding appropriate test files. Related to commit 9f9b23fd7943a3d125cb1cc9f333ce430b2706ea Task-number: QTBUG-14697 Change-Id: Ic60521e46401835029e293349a00610342d0d58f Reviewed-on: http://codereview.qt.nokia.com/2538 Reviewed-by: Qt Sanity Bot Reviewed-by: Simon Hausmann Reviewed-by: Aaron Kennedy --- tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml | 5 +++++ tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml create mode 100644 tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml new file mode 100644 index 0000000000..f58967cbb2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property string someString +} diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml new file mode 100644 index 0000000000..4b3672873d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property NoContextTypeA myTypeA +} -- cgit v1.2.3 From 29af49fc979b888f5b5ea20616f3f6da48b009b0 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 4 Aug 2011 10:30:46 +1000 Subject: Add enabled property to Transition. Task-number: QTBUG-14488 Change-Id: I3619a0d26e99e2c19f50a63013dedc151b07154c Reviewed-on: http://codereview.qt.nokia.com/2591 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../data/disabledTransition.qml | 30 ++++++++++++++++ .../tst_qdeclarativeanimations.cpp | 27 ++++++++++++++ .../data/horizontal-animated-disabled.qml | 40 +++++++++++++++++++++ .../qsgpositioners/data/horizontal-animated.qml | 3 ++ .../qsgpositioners/tst_qsgpositioners.cpp | 41 ++++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/horizontal-animated-disabled.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml b/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml new file mode 100644 index 0000000000..0fbafead8b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + enabled: false + NumberAnimation { targets: theRect; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index bd9c3e0d7a..367de014b4 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -77,6 +77,7 @@ private slots: void mixedTypes(); void properties(); void propertiesTransition(); + void disabledTransition(); void invalidDuration(); void attached(); void propertyValueSourceDefaultStart(); @@ -576,6 +577,32 @@ void tst_qdeclarativeanimations::propertiesTransition() } +void tst_qdeclarativeanimations::disabledTransition() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabledTransition.qml")); + QSGRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QSGRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + + QDeclarativeTransition *trans = rect->findChild(); + QVERIFY(trans); + + QCOMPARE(trans->enabled(), false); + + QSGItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + + trans->setEnabled(true); + + QSGItemPrivate::get(rect)->setState(""); + QCOMPARE(myRect->x(),qreal(200)); + QTest::qWait(300); + QTIMED_COMPARE(myRect->x(),qreal(100)); +} + void tst_qdeclarativeanimations::invalidDuration() { QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation; diff --git a/tests/auto/declarative/qsgpositioners/data/horizontal-animated-disabled.qml b/tests/auto/declarative/qsgpositioners/data/horizontal-animated-disabled.qml new file mode 100644 index 0000000000..8723ffc78f --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/horizontal-animated-disabled.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + + Row { + objectName: "row" + add: Transition { + enabled: false + NumberAnimation { properties: "x" } + } + move: Transition { + enabled: false + NumberAnimation { properties: "x" } + } + Rectangle { + objectName: "one" + color: "red" + x: -100; + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + x: -100; + visible: false + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + x: -100; + color: "green" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml b/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml index b9b8591e83..a88c26b66c 100644 --- a/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml +++ b/tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml @@ -4,16 +4,19 @@ Item { width: 640 height: 480 property bool testRightToLeft: false + property bool testEnabled: false Row { objectName: "row" layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight add: Transition { + enabled: testEnabled ? false : true NumberAnimation { properties: "x"; } } move: Transition { + enabled: testEnabled ? false : true NumberAnimation { properties: "x"; } diff --git a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp index a9bdf4249b..3b2a504ff4 100644 --- a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp +++ b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp @@ -68,6 +68,7 @@ private slots: void test_horizontal_spacing_rightToLeft(); void test_horizontal_animated(); void test_horizontal_animated_rightToLeft(); + void test_horizontal_animated_disabled(); void test_vertical(); void test_vertical_spacing(); void test_vertical_animated(); @@ -328,6 +329,46 @@ void tst_qsgpositioners::test_horizontal_animated_rightToLeft() delete canvas; } +void tst_qsgpositioners::test_horizontal_animated_disabled() +{ + QSGView *canvas = createView(SRCDIR "/data/horizontal-animated-disabled.qml"); + + QSGRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QSGRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QSGRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QSGItem *row = canvas->rootObject()->findChild("row"); + QVERIFY(row); + + qApp->processEvents(); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->isVisible(), false); + QCOMPARE(two->x(), -100.0);//Not 'in' yet + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + + //Add 'two' + two->setVisible(true); + QCOMPARE(two->isVisible(), true); + qApp->processEvents(); + QCOMPARE(row->width(), 150.0); + QCOMPARE(row->height(), 50.0); + + qApp->processEvents(); + QCOMPARE(two->x(), 50.0); + QCOMPARE(three->x(), 100.0); + + delete canvas; +} + void tst_qsgpositioners::test_vertical() { QSGView *canvas = createView(SRCDIR "/data/vertical.qml"); -- cgit v1.2.3 From fd68b868aee89f40138492468745f0e5edb3286e Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 12 Jul 2011 14:05:24 +1000 Subject: Honour the resettable flag of aliased properties Previously, alias properties were not considered isResettable even if the property they alias is resettable. This commit ensures that the IsResettable flag is set for alias properties iff the aliased property is resettable, and that it is honoured during property reset operations. Task-number: QTBUG-18182 Change-Id: I9cab11923a952df72e976a48489a78b24a34314f Reviewed-on: http://codereview.qt.nokia.com/1471 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- .../data/aliasreset/AliasPropertyComponent.qml | 17 +++++ .../data/aliasreset/aliasPropertyReset.1.qml | 23 ++++++ .../data/aliasreset/aliasPropertyReset.2.qml | 23 ++++++ .../data/aliasreset/aliasPropertyReset.3.qml | 31 ++++++++ .../data/aliasreset/aliasPropertyReset.4.qml | 26 +++++++ .../data/aliasreset/aliasPropertyReset.5.qml | 14 ++++ .../data/aliasreset/aliasPropertyReset.error.1.qml | 18 +++++ .../tst_qdeclarativeecmascript.cpp | 82 ++++++++++++++++++++++ 8 files changed, 234 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml new file mode 100644 index 0000000000..9135e79469 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Item { + id: apc + property alias sourceComponent: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + objectName: "loader" + sourceComponent: redSquare + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml new file mode 100644 index 0000000000..a27c16dd2e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +Item { + id: first + property bool aliasIsUndefined: false + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + sourceComponent: redSquare + } + + function resetAliased() { + loader.sourceComponent = undefined; + aliasIsUndefined = (sourceComponentAlias == undefined); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml new file mode 100644 index 0000000000..fa2bb5eb6d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +Item { + id: first + property bool loaderSourceComponentIsUndefined: false + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + sourceComponent: redSquare + } + + function resetAlias() { + sourceComponentAlias = undefined; + loaderSourceComponentIsUndefined = (loader.sourceComponent == undefined); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml new file mode 100644 index 0000000000..4fa6861b08 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml @@ -0,0 +1,31 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +Item { + id: first + property bool loaderTwoSourceComponentIsUndefined: false + property bool loaderOneSourceComponentIsUndefined: false + property alias sourceComponentAlias: loaderOne.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loaderOne + sourceComponent: loaderTwo.sourceComponent + } + + Loader { + id: loaderTwo + sourceComponent: redSquare + x: 15 + } + + function resetAlias() { + sourceComponentAlias = undefined; // loaderOne.sourceComponent should be set to undefined instead of l2.sc + loaderOneSourceComponentIsUndefined = (loaderOne.sourceComponent == undefined); // should be true + loaderTwoSourceComponentIsUndefined = (loaderTwo.sourceComponent == undefined); // should be false + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml new file mode 100644 index 0000000000..56fcc2ec7c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +Item { + id: first + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + objectName: "loader" + sourceComponent: redSquare + } + + function resetAlias() { + sourceComponentAlias = undefined; // ensure we don't crash after deletion of loader. + } + + function setAlias() { + sourceComponentAlias = redSquare; + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml new file mode 100644 index 0000000000..a046bbf504 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +Item { + id: root + + AliasPropertyComponent { + sourceComponent: returnsUndefined() + } + + function returnsUndefined() { + return undefined; + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml new file mode 100644 index 0000000000..22311d6bb3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +MyQmlObject { + id: first + property bool aliasedIntIsUndefined: false + property alias intAlias: objprop.intp + + objectProperty: QtObject { + id: objprop + property int intp: 12 + } + + function resetAlias() { + intAlias = undefined; // should error + aliasedIntIsUndefined = (objprop.intp == undefined); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index c5f7ed1b58..3efe18909c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -104,6 +104,7 @@ private slots: void constantsOverrideBindings(); void outerBindingOverridesInnerBinding(); void aliasPropertyAndBinding(); + void aliasPropertyReset(); void nonExistentAttachedObject(); void scope(); void importScope(); @@ -1038,6 +1039,87 @@ void tst_qdeclarativeecmascript::aliasPropertyAndBinding() delete object; } +/* +Ensure that we can write undefined value to an alias property, +and that the aliased property is reset correctly if possible. +*/ +void tst_qdeclarativeecmascript::aliasPropertyReset() +{ + QObject *object = 0; + + // test that a manual write (of undefined) to a resettable aliased property succeeds + QDeclarativeComponent c1(&engine, TEST_FILE("aliasreset/aliasPropertyReset.1.qml")); + object = c1.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("aliasIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAliased"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("aliasIsUndefined"), QVariant(true)); + delete object; + + // test that a manual write (of undefined) to a resettable alias property succeeds + QDeclarativeComponent c2(&engine, TEST_FILE("aliasreset/aliasPropertyReset.2.qml")); + object = c2.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAlias"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true)); + delete object; + + // test that an alias to a bound property works correctly + QDeclarativeComponent c3(&engine, TEST_FILE("aliasreset/aliasPropertyReset.3.qml")); + object = c3.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false)); + QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAlias"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true)); + QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); + delete object; + + // test that a manual write (of undefined) to a resettable alias property + // whose aliased property's object has been deleted, does not crash. + QDeclarativeComponent c4(&engine, TEST_FILE("aliasreset/aliasPropertyReset.4.qml")); + object = c4.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QObject *loader = object->findChild("loader"); + QVERIFY(loader != 0); + delete loader; + QVERIFY(object->property("sourceComponentAlias").value() == 0); // deletion should have caused value unset. + QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash. + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything). + QVERIFY(object->property("sourceComponentAlias").value() == 0); + delete object; + + // test that binding an alias property to an undefined value works correctly + QDeclarativeComponent c5(&engine, TEST_FILE("aliasreset/aliasPropertyReset.5.qml")); + object = c5.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() == 0); // bound to undefined value. + delete object; + + // test that a manual write (of undefined) to a non-resettable property fails properly + QUrl url = TEST_FILE("aliasreset/aliasPropertyReset.error.1.qml"); + QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int"); + QDeclarativeComponent e1(&engine, url); + object = e1.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("intAlias").value(), 12); + QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false)); + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QMetaObject::invokeMethod(object, "resetAlias"); + QCOMPARE(object->property("intAlias").value(), 12); + QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false)); + delete object; +} + void tst_qdeclarativeecmascript::dynamicCreation_data() { QTest::addColumn("method"); -- cgit v1.2.3 From 7964b819aefbee380ca24288c6234f5917211529 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 3 Aug 2011 14:00:57 +1000 Subject: Improve error messages from compiler for signals and slots This commit ensures that correct line and column information is provided in some cases (duplicate signal or method name, etc). Task-number: QTBUG-15076 Change-Id: I483bdc92ef4f1d1d2ff565bb957385fd495672da Reviewed-on: http://codereview.qt.nokia.com/1619 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- .../auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt | 2 +- .../auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt | 2 +- tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt | 2 +- tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt index c5860a2f4b..8226c16a1e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt @@ -1 +1 @@ -3:1:Duplicate signal name +5:12:Duplicate signal name diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt index b293c862b1..18e07456ef 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt @@ -1 +1 @@ -3:1:Duplicate method name +5:5:Duplicate method name diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt index b10984f035..0dab632ff6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt @@ -1 +1 @@ -3:1:Method names cannot begin with an upper case letter +4:5:Method names cannot begin with an upper case letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt index d96f9e3ed9..513ff60ae6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt @@ -1 +1 @@ -3:1:Signal names cannot begin with an upper case letter +4:12:Signal names cannot begin with an upper case letter -- cgit v1.2.3 From b1b50553cf73795e25337d5e5bb70530c90dd350 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 3 Aug 2011 15:40:58 +1000 Subject: Fix ListView refill() where delegate size == 0 When refilling, if a delegate item is positioned at the start of the buffer, it should only be removed if its height is > 0. Otherwise refill() will constantly remove it in removeNonVisibleItems() and add it again in the next frame in addVisibleItems(). Regression from aa99d4f5cb4f1f512d1db90536752b518dbea449 Task-number: QTBUG-20712 Change-Id: I21d25fde21e0b559a378c9e202ace58947417a4d Reviewed-on: http://codereview.qt.nokia.com/2541 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../declarative/qsglistview/tst_qsglistview.cpp | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index f4a2384729..6f19692ad0 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -121,6 +121,7 @@ private slots: void sizeLessThan1(); void QTBUG_14821(); void resizeDelegate(); + void resizeFirstDelegate(); void QTBUG_16037(); void indexAt(); void incrementalModel(); @@ -2717,6 +2718,60 @@ void tst_QSGListView::resizeDelegate() delete canvas; } +void tst_QSGListView::resizeFirstDelegate() +{ + // QTBUG-20712: Content Y jumps constantly if first delegate height == 0 + // and other delegates have height > 0 + + QSGView *canvas = createView(); + canvas->show(); + + // bug only occurs when all items in the model are visible + TestModel model; + for (int i = 0; i < 10; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); + qApp->processEvents(); + + QSGListView *listview = findItem(canvas->rootObject(), "list"); + QVERIFY(listview != 0); + + QSGItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QSGItem *item = 0; + for (int i = 0; i < model.count(); ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QCOMPARE(item->y(), i*20.0); + } + + item = findItem(contentItem, "wrapper", 0); + item->setHeight(0); + + // check the content y has not jumped up and down + QCOMPARE(listview->contentY(), 0.0); + QSignalSpy spy(listview, SIGNAL(contentYChanged())); + QTest::qWait(300); + QCOMPARE(spy.count(), 0); + + for (int i = 1; i < model.count(); ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QTRY_COMPARE(item->y(), (i-1)*20.0); + } + + delete testObject; + delete canvas; +} + void tst_QSGListView::QTBUG_16037() { QSGView *canvas = createView(); -- cgit v1.2.3 From bbe72dadd3ab73a2a3a7dabfb9db3e99b36a272a Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 2 Aug 2011 15:19:06 +1000 Subject: Don't cache model data in VisualDataModel. VisualDataModel doesn't have any way to monitor the lifetime of objects cached other than relying on the source model to emit a changed signal. If the model doesn't do this or a pointer property is referenced after an item has been removed from the model then cache can return a stale pointer. This can be avoided by querying the model directly whenever a property is accessed. Task-number: QTBUG-18036 Change-Id: I7688174c2337cb5c0f77eb7d31a01f4aa958071b Reviewed-on: http://codereview.qt.nokia.com/2647 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- tests/auto/declarative/qsggridview/data/gridview1.qml | 1 + tests/auto/declarative/qsggridview/tst_qsggridview.cpp | 2 +- tests/auto/declarative/qsglistview/tst_qsglistview.cpp | 2 +- tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp | 2 +- tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml | 2 ++ tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml | 2 ++ tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml | 2 +- tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml | 2 +- tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml | 2 +- tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp | 1 - 10 files changed, 11 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qsggridview/data/gridview1.qml b/tests/auto/declarative/qsggridview/data/gridview1.qml index 0f148ed387..e6a3923532 100644 --- a/tests/auto/declarative/qsggridview/data/gridview1.qml +++ b/tests/auto/declarative/qsggridview/data/gridview1.qml @@ -20,6 +20,7 @@ Rectangle { width: 80 height: 60 border.color: "blue" + property string name: model.name Text { text: index } diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index 11d90eca6e..c478f0dab3 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -1344,7 +1344,7 @@ void tst_QSGGridView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); gridView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 6f19692ad0..59847d37f5 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -2008,7 +2008,7 @@ void tst_QSGListView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); listView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp index 00202f7436..96a591f511 100644 --- a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp +++ b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp @@ -835,7 +835,7 @@ void tst_QSGPathView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); QVERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); pathView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml index 6d86cdea2e..73b766f1af 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml @@ -6,6 +6,8 @@ ListView { model: myModel delegate: Item { objectName: "delegate" + width: 100 + height: 2 property variant test1: name property variant test2: model.name property variant test3: modelData diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml index 6a92431cdf..ea5c240b29 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml @@ -15,5 +15,7 @@ ListView { property variant test7: index property variant test8: model.index property variant test9: model.modelData.display + width: 100 + height: 2 } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml index 9086e5ab57..b3952a8a4d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml @@ -10,7 +10,7 @@ ListView { height: 25 width: 100 color: model.modelData.color - Text { objectName: "name"; text: name } + Text { objectName: "name"; text: name; function getText() { return name } } Text { objectName: "section"; text: parent.ListView.section } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml index d5b0fcf09b..c471893e1d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml @@ -5,6 +5,6 @@ ListView { height: 100 model: myModel delegate: Component { - Text { objectName: "name"; text: name } + Text { objectName: "name"; text: name; function getText() { return name; } } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml index c6d3413dfd..ab1798999d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml @@ -5,6 +5,6 @@ ListView { height: 100 model: myModel delegate: Component { - Text { objectName: "name"; text: modelData } + Text { objectName: "name"; text: modelData; function getText() { return modelData } } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp index e56fcb062e..7470153933 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp +++ b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp @@ -460,7 +460,6 @@ void tst_qsgvisualdatamodel::modelProperties() QSGItem *delegate = findItem(contentItem, "delegate", 1); QVERIFY(delegate); QCOMPARE(delegate->property("test1").toString(),QString("Item 2")); - QEXPECT_FAIL("", "QTBUG-13576", Continue); QCOMPARE(delegate->property("test2").toString(),QString("Item 2")); QVERIFY(qobject_cast(delegate->property("test3").value()) != 0); QVERIFY(qobject_cast(delegate->property("test4").value()) != 0); -- cgit v1.2.3 From 97ff5987170460172f9a808193b17af8b3abd6d3 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 4 Aug 2011 17:42:36 +1000 Subject: Add missing license headers. Change-Id: Ib71e988f6a0d87f1f9afe407e206eaa68137a537 Reviewed-on: http://codereview.qt.nokia.com/2604 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- tests/systemtests/declarative/qsgimage/ImageNG.qml | 41 ++++++++++++++++++++++ .../systemtests/declarative/qsgimage/img-align.qml | 41 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) (limited to 'tests') diff --git a/tests/systemtests/declarative/qsgimage/ImageNG.qml b/tests/systemtests/declarative/qsgimage/ImageNG.qml index 4a10910fcf..c95026342b 100644 --- a/tests/systemtests/declarative/qsgimage/ImageNG.qml +++ b/tests/systemtests/declarative/qsgimage/ImageNG.qml @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import QtQuick 2.0 Image { diff --git a/tests/systemtests/declarative/qsgimage/img-align.qml b/tests/systemtests/declarative/qsgimage/img-align.qml index 55ee112ccd..4ca62da044 100644 --- a/tests/systemtests/declarative/qsgimage/img-align.qml +++ b/tests/systemtests/declarative/qsgimage/img-align.qml @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import QtQuick 2.0 Rectangle { -- cgit v1.2.3 From 5a8de45440ad924e5e787e12e2396ffeed6cce80 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 5 Aug 2011 15:48:16 +1000 Subject: Show header/footer if current index is set to first/last item or row Task-number: QTBUG-17853 Change-Id: I1d679cee31d6ee2a4bb2f2bf90f73eb12898189b Reviewed-on: http://codereview.qt.nokia.com/2664 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- .../qsggridview/data/gridview-initCurrent.qml | 13 +++++++++++++ .../declarative/qsggridview/tst_qsggridview.cpp | 22 ++++++++++++++++++++++ .../qsglistview/data/listview-initCurrent.qml | 13 +++++++++++++ .../declarative/qsglistview/tst_qsglistview.cpp | 22 ++++++++++++++++++++++ 4 files changed, 70 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsggridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qsggridview/data/gridview-initCurrent.qml index c012b4c481..e3ec8f2d4a 100644 --- a/tests/auto/declarative/qsggridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qsggridview/data/gridview-initCurrent.qml @@ -1,7 +1,12 @@ import QtQuick 2.0 Rectangle { + id: root + property int current: grid.currentIndex + property bool showHeader: false + property bool showFooter: false + width: 240 height: 320 color: "#ffffff" @@ -37,6 +42,12 @@ Rectangle { } } ] + + Component { + id: headerFooter + Rectangle { height: 30; width: 240; color: "blue" } + } + GridView { id: grid objectName: "grid" @@ -48,5 +59,7 @@ Rectangle { cellHeight: 60 delegate: myDelegate model: testModel + header: root.showHeader ? headerFooter : null + footer: root.showFooter ? headerFooter : null } } diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index c478f0dab3..49c3080a1c 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -880,6 +880,26 @@ void tst_QSGGridView::currentIndex() QTRY_COMPARE(gridview->contentY(), 0.0); + + // footer should become visible if it is out of view, and then current index moves to the first row + canvas->rootObject()->setProperty("showFooter", true); + QTRY_VERIFY(gridview->footerItem()); + gridview->setCurrentIndex(model.count()-3); + QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height()); + gridview->setCurrentIndex(model.count()-2); + QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height()); + canvas->rootObject()->setProperty("showFooter", false); + + // header should become visible if it is out of view, and then current index moves to the last row + canvas->rootObject()->setProperty("showHeader", true); + QTRY_VERIFY(gridview->headerItem()); + gridview->setCurrentIndex(3); + QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY()); + gridview->setCurrentIndex(1); + QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height()); + canvas->rootObject()->setProperty("showHeader", false); + + // Test keys qApp->setActiveWindow(canvas); #ifdef Q_WS_X11 @@ -889,6 +909,8 @@ void tst_QSGGridView::currentIndex() QTRY_VERIFY(canvas->hasFocus()); qApp->processEvents(); + gridview->setCurrentIndex(0); + QTest::keyClick(canvas, Qt::Key_Down); QCOMPARE(gridview->currentIndex(), 3); diff --git a/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml b/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml index ee1a333de0..c4f1860eda 100644 --- a/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml @@ -1,7 +1,12 @@ import QtQuick 2.0 Rectangle { + id: root + property int current: list.currentIndex + property bool showHeader: false + property bool showFooter: false + width: 240 height: 320 color: "#ffffff" @@ -36,6 +41,12 @@ Rectangle { } } ] + + Component { + id: headerFooter + Rectangle { height: 30; width: 240; color: "blue" } + } + ListView { id: list objectName: "list" @@ -47,5 +58,7 @@ Rectangle { delegate: myDelegate highlightMoveSpeed: 1000 model: testModel + header: root.showHeader ? headerFooter : null + footer: root.showFooter ? headerFooter : null } } diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 59847d37f5..e1e6edd53d 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -1478,6 +1478,26 @@ void tst_QSGListView::currentIndex() QTRY_COMPARE(listview->contentY(), 0.0); + + // footer should become visible if it is out of view, and then current index is set to count-1 + canvas->rootObject()->setProperty("showFooter", true); + QTRY_VERIFY(listview->footerItem()); + listview->setCurrentIndex(model.count()-2); + QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height()); + listview->setCurrentIndex(model.count()-1); + QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height()); + canvas->rootObject()->setProperty("showFooter", false); + + // header should become visible if it is out of view, and then current index is set to 0 + canvas->rootObject()->setProperty("showHeader", true); + QTRY_VERIFY(listview->headerItem()); + listview->setCurrentIndex(1); + QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY()); + listview->setCurrentIndex(0); + QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height()); + canvas->rootObject()->setProperty("showHeader", false); + + // Test keys canvas->show(); qApp->setActiveWindow(canvas); @@ -1488,6 +1508,8 @@ void tst_QSGListView::currentIndex() QTRY_VERIFY(canvas->hasFocus()); qApp->processEvents(); + listview->setCurrentIndex(0); + QTest::keyClick(canvas, Qt::Key_Down); QCOMPARE(listview->currentIndex(), 1); -- cgit v1.2.3 From 4e31fd1b22edf934c45813e2f52936fa07d2612e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 8 Aug 2011 11:15:30 +1000 Subject: Fix broken test (view did not have focus set) Change-Id: I25e68df061510deadd946d1a034c114dfd0b4f1c Reviewed-on: http://codereview.qt.nokia.com/2715 Reviewed-by: Bea Lam Reviewed-by: Qt Sanity Bot --- .../declarative/qsglistview/data/listview-enforcerange-nohighlight.qml | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml b/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml index 946f4f2046..1db1096499 100644 --- a/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml +++ b/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml @@ -48,6 +48,7 @@ Rectangle { height: 320 model: testModel delegate: myDelegate + focus: true preferredHighlightBegin: 100 preferredHighlightEnd: 100 -- cgit v1.2.3 From 8c0c89a72a0ad463bde36c3d36f00cc5914721e1 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 8 Aug 2011 11:57:39 +1000 Subject: Revise QDeclarativeChangeSet. Represent moves as associated Removes and Inserts instead of discrete actions. Add API for applying a set of changes to another change set. Change-Id: Id97c1648c7480023dbfef325150bb81c2fea95c0 Reviewed-on: http://codereview.qt.nokia.com/2720 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- .../tst_qdeclarativechangeset.cpp | 1007 ++++++++++++-------- 1 file changed, 589 insertions(+), 418 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp index 018711ac64..4aaefba7c4 100644 --- a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp +++ b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp @@ -43,17 +43,16 @@ #define VERIFY_EXPECTED_OUTPUT - - class tst_qdeclarativemodelchange : public QObject { Q_OBJECT public: struct Signal { - int start; - int end; + int index; + int count; int to; + int moveId; bool isInsert() const { return to == -1; } bool isRemove() const { return to == -2; } @@ -61,10 +60,10 @@ public: bool isChange() const { return to == -3; } }; - static Signal Insert(int start, int end) { Signal signal = { start, end, -1 }; return signal; } - static Signal Remove(int start, int end) { Signal signal = { start, end, -2 }; return signal; } - static Signal Move(int start, int end, int to) { Signal signal = { start, end, to }; return signal; } - static Signal Change(int start, int end) { Signal signal = { start, end, -3 }; return signal; } + static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; } + static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; } + static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; } + static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; } typedef QVector SignalList; @@ -100,16 +99,24 @@ public: QVector applyChanges(const QVector &list, const QVector &changes) { + QHash > removedValues; QVector alteredList = list; foreach (const Signal &signal, changes) { if (signal.isInsert()) { - alteredList.insert(signal.start, signal.end - signal.start, 100); + if (signal.moveId != -1) { + QVector tail = alteredList.mid(signal.index); + alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail; + } else { + alteredList.insert(signal.index, signal.count, 100); + } } else if (signal.isRemove()) { - alteredList.erase(alteredList.begin() + signal.start, alteredList.begin() + signal.end); + if (signal.moveId != -1) + removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count)); + alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count); } else if (signal.isMove()) { - move(signal.start, signal.to, signal.end - signal.start, &alteredList); + move(signal.index, signal.to, signal.count, &alteredList); } else if (signal.isChange()) { - for (int i = signal.start; i < signal.end; ++i) { + for (int i = signal.index; i < signal.index + signal.count; ++i) { if (alteredList[i] < 100) alteredList[i] = 100; } @@ -126,19 +133,19 @@ private slots: }; bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right) { - return left.start == right.start && left.end == right.end && left.to == right.to; } + return left.index == right.index && left.count == right.count && left.to == right.to; } QDebug operator <<(QDebug debug, const tst_qdeclarativemodelchange::Signal &signal) { if (signal.isInsert()) - debug.nospace() << "Insert(" << signal.start << "," << signal.end << ")"; + debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")"; else if (signal.isRemove()) - debug.nospace() << "Remove(" << signal.start << "," << signal.end << ")"; + debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")"; else if (signal.isMove()) - debug.nospace() << "Move(" << signal.start << "," << signal.end << "," << signal.to << ")"; + debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")"; else if (signal.isChange()) - debug.nospace() << "Change(" << signal.start << "," << signal.end << ")"; + debug.nospace() << "Change(" << signal.index << "," << signal.count << ")"; return debug; } @@ -150,405 +157,571 @@ void tst_qdeclarativemodelchange::sequence_data() QTest::addColumn("output"); // Insert - QTest::newRow("i(12-17)") - << (SignalList() << Insert(12, 17)) - << (SignalList() << Insert(12, 17)); - QTest::newRow("i(2-5),i(12-17)") - << (SignalList() << Insert(2, 5) << Insert(12, 17)) - << (SignalList() << Insert(2, 5) << Insert(12, 17)); - QTest::newRow("i(12-17),i(2-5)") - << (SignalList() << Insert(12, 17) << Insert(2, 5)) - << (SignalList() << Insert(2, 5) << Insert(15, 20)); - QTest::newRow("i(12-17),i(12-15)") - << (SignalList() << Insert(12, 17) << Insert(12, 15)) - << (SignalList() << Insert(12, 20)); - QTest::newRow("i(12-17),i(17-20)") - << (SignalList() << Insert(12, 17) << Insert(17, 20)) - << (SignalList() << Insert(12, 20)); - QTest::newRow("i(12-17),i(15-18)") - << (SignalList() << Insert(12, 17) << Insert(15, 18)) - << (SignalList() << Insert(12, 20)); + QTest::newRow("i(12,5)") + << (SignalList() << Insert(12,5)) + << (SignalList() << Insert(12,5)); + QTest::newRow("i(2,3),i(12,5)") + << (SignalList() << Insert(2,3) << Insert(12,5)) + << (SignalList() << Insert(2,3) << Insert(12,5)); + QTest::newRow("i(12,5),i(2,3)") + << (SignalList() << Insert(12,5) << Insert(2,3)) + << (SignalList() << Insert(2,3) << Insert(15,5)); + QTest::newRow("i(12,5),i(12,3)") + << (SignalList() << Insert(12,5) << Insert(12,3)) + << (SignalList() << Insert(12,8)); + QTest::newRow("i(12,5),i(17,3)") + << (SignalList() << Insert(12,5) << Insert(17,3)) + << (SignalList() << Insert(12,8)); + QTest::newRow("i(12,5),i(15,3)") + << (SignalList() << Insert(12,5) << Insert(15,3)) + << (SignalList() << Insert(12,8)); // Remove - QTest::newRow("r(3-12)") - << (SignalList() << Remove(3, 12)) - << (SignalList() << Remove(3, 12)); - QTest::newRow("r(3-7),r(3-5)") - << (SignalList() << Remove(3, 7) << Remove(3, 5)) - << (SignalList() << Remove(3, 9)); - QTest::newRow("r(4-3),r(14-19)") - << (SignalList() << Remove(4, 7) << Remove(14, 19)) - << (SignalList() << Remove(4, 7) << Remove(14, 19)); - QTest::newRow("r(14-19),r(4-7)") - << (SignalList() << Remove(14, 19) << Remove(4, 7)) - << (SignalList() << Remove(4, 7) << Remove(11, 16)); - QTest::newRow("r(4-7),r(2-11)") - << (SignalList() << Remove(4, 7) << Remove(2, 11)) - << (SignalList() << Remove(2, 14)); + QTest::newRow("r(3,9)") + << (SignalList() << Remove(3,9)) + << (SignalList() << Remove(3,9)); + QTest::newRow("r(3,4),r(3,2)") + << (SignalList() << Remove(3,4) << Remove(3,2)) + << (SignalList() << Remove(3,6)); + QTest::newRow("r(4,3),r(14,5)") + << (SignalList() << Remove(4,3) << Remove(14,5)) + << (SignalList() << Remove(4,3) << Remove(14,5)); + QTest::newRow("r(14,5),r(4,3)") + << (SignalList() << Remove(14,5) << Remove(4,3)) + << (SignalList() << Remove(4,3) << Remove(11,5)); + QTest::newRow("r(4,3),r(2,9)") + << (SignalList() << Remove(4,3) << Remove(2,9)) + << (SignalList() << Remove(2,12)); // Move - QTest::newRow("m(8-10,10)") - << (SignalList() << Move(8, 10, 10)) - << (SignalList() << Move(8, 10, 10)); - // No merging of moves yet. -// QTest::newRow("m(5-7,13),m(5-8,12)") -// << (SignalList() << Move(5, 7, 13) << Move(5, 8, 12)) -// << (SignalList() << Move(5, 10, 10)); + QTest::newRow("m(8-10,2)") + << (SignalList() << Move(8,10,2)) + << (SignalList() << Remove(8,2,1) << Insert(10,2,1)); + + QTest::newRow("m(23-12,6),m(13-15,5)") + << (SignalList() << Move(23,12,6) << Move(13,15,5)) + << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1)); + QTest::newRow("m(23-12,6),m(13-15,2)") + << (SignalList() << Move(23,12,6) << Move(13,20,2)) + << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1)); + QTest::newRow("m(23-12,6),m(13-2,2)") + << (SignalList() << Move(23,12,6) << Move(13,2,2)) + << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2)); + QTest::newRow("m(23-12,6),m(12-6,5)") + << (SignalList() << Move(23,12,6) << Move(12,6,5)) + << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1)); + QTest::newRow("m(23-12,6),m(10-5,4)") + << (SignalList() << Move(23,12,6) << Move(10,5,4)) + << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2)); + QTest::newRow("m(23-12,6),m(16-5,4)") + << (SignalList() << Move(23,12,6) << Move(16,5,4)) + << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1)); + QTest::newRow("m(23-12,6),m(13-5,4)") + << (SignalList() << Move(23,12,6) << Move(13,5,4)) + << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2)); + QTest::newRow("m(23-12,6),m(14-5,4)") + << (SignalList() << Move(23,12,6) << Move(14,5,4)) + << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0)); + QTest::newRow("m(23-12,6),m(12-5,4)") + << (SignalList() << Move(23,12,6) << Move(12,5,4)) + << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1)); + QTest::newRow("m(23-12,6),m(11-5,8)") + << (SignalList() << Move(23,12,6) << Move(11,5,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1)); + QTest::newRow("m(23-12,6),m(8-5,4)") + << (SignalList() << Move(23,12,6) << Move(8,5,4)) + << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1)); + QTest::newRow("m(23-12,6),m(2-5,4)") + << (SignalList() << Move(23,12,6) << Move(2,5,4)) + << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1)); + QTest::newRow("m(23-12,6),m(18-5,4)") + << (SignalList() << Move(23,12,6) << Move(18,5,4)) + << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1)); + QTest::newRow("m(23-12,6),m(20-5,4)") + << (SignalList() << Move(23,12,6) << Move(20,5,4)) + << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1)); + + QTest::newRow("m(23-12,6),m(5-13,11)") + << (SignalList() << Move(23,12,6) << Move(5,13,11)) + << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1)); + + QTest::newRow("m(23-12,6),m(12-23,6)") + << (SignalList() << Move(23,12,6) << Move(12,23,6)) + << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out. + QTest::newRow("m(23-12,6),m(10-23,4)") + << (SignalList() << Move(23,12,6) << Move(10,23,4)) + << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1)); + QTest::newRow("m(23-12,6),m(16-23.4)") + << (SignalList() << Move(23,12,6) << Move(16,23,4)) + << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0)); + QTest::newRow("m(23-12,6),m(13-23,4)") + << (SignalList() << Move(23,12,6) << Move(13,23,4)) + << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1)); + QTest::newRow("m(23-12,6),m(14-23,)") + << (SignalList() << Move(23,12,6) << Move(14,23,4)) + << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1)); + QTest::newRow("m(23-12,6),m(12-23,4)") + << (SignalList() << Move(23,12,6) << Move(12,23,4)) + << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(11-23,8)") + << (SignalList() << Move(23,12,6) << Move(11,23,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1)); + QTest::newRow("m(23-12,6),m(8-23,4)") + << (SignalList() << Move(23,12,6) << Move(8,23,4)) + << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(2-23,4)") + << (SignalList() << Move(23,12,6) << Move(2,23,4)) + << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(18-23,4)") + << (SignalList() << Move(23,12,6) << Move(18,23,4)) + << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(20-23,4)") + << (SignalList() << Move(23,12,6) << Move(20,23,4)) + << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1)); + + QTest::newRow("m(23-12,6),m(11-23,10)") + << (SignalList() << Move(23,12,6) << Move(11,23,10)) + << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1)); + + QTest::newRow("m(3-9,12),m(13-5,12)") + << (SignalList() << Move(3,9,12) << Move(13,15,5)) + << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3)); + QTest::newRow("m(3-9,12),m(13-15,20)") + << (SignalList() << Move(3,9,12) << Move(13,15,20)) + << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2)); + QTest::newRow("m(3-9,12),m(13-15,2)") + << (SignalList() << Move(3,9,12) << Move(13,15,2)) + << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3)); + QTest::newRow("m(3-9,12),m(12-5,6)") + << (SignalList() << Move(3,9,12) << Move(12,5,6)) + << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2)); + QTest::newRow("m(3-9,12),m(10-14,5)") + << (SignalList() << Move(3,9,12) << Move(10,14,5)) + << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3)); + QTest::newRow("m(3-9,12),m(16-20,5)") + << (SignalList() << Move(3,9,12) << Move(16,20,5)) + << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1)); + QTest::newRow("m(3-9,12),m(13-17,5)") + << (SignalList() << Move(3,9,12) << Move(13,17,5)) + << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1)); + QTest::newRow("m(3-9,12),m(14-18,5)") + << (SignalList() << Move(3,9,12) << Move(14,18,5)) + << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1)); + QTest::newRow("m(3-9,12),m(12-16,5)") + << (SignalList() << Move(3,9,12) << Move(12,16,5)) + << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1)); + QTest::newRow("m(3-9,12),m(11-19,5)") + << (SignalList() << Move(3,9,12) << Move(11,19,5)) + << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1)); + QTest::newRow("m(3-9,12),m(8-12,5)") + << (SignalList() << Move(3,9,12) << Move(8,12,5)) + << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4)); + QTest::newRow("m(3-9,12),m(2-6,5)") + << (SignalList() << Move(3,9,12) << Move(2,6,5)) + << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3)); + QTest::newRow("m(3-9,12),m(18-22,5)") + << (SignalList() << Move(3,9,12) << Move(18,22,5)) + << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2)); + QTest::newRow("m(3-9,12),m(20-24,5)") + << (SignalList() << Move(3,9,12) << Move(20,24,5)) + << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2)); + + QTest::newRow("m(3-9,12),m(5-11,8)") + << (SignalList() << Move(3,9,12) << Move(5,11,8)) + << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1)); + + QTest::newRow("m(3-9,12),m(12-23,6)") + << (SignalList() << Move(3,9,12) << Move(12,23,6)) + << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1)); + QTest::newRow("m(3-9,12),m(10-23,4)") + << (SignalList() << Move(3,9,12) << Move(10,23,4)) + << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(16-23,4)") + << (SignalList() << Move(3,9,12) << Move(16,23,4)) + << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(13-23,4)") + << (SignalList() << Move(3,9,12) << Move(13,23,4)) + << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(14-23,4)") + << (SignalList() << Move(3,9,12) << Move(14,23,4)) + << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(12-23,4)") + << (SignalList() << Move(3,9,12) << Move(12,23,4)) + << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(11-23,8)") + << (SignalList() << Move(3,9,12) << Move(11,23,8)) + << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1)); + QTest::newRow("m(3-9,12),m(8-23,4)") + << (SignalList() << Move(3,9,12) << Move(8,23,4)) + << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1)); + QTest::newRow("m(3-9,12),m(2-23,4)") + << (SignalList() << Move(3,9,12) << Move(2,23,4)) + << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1)); + QTest::newRow("m(3-9,12),m(18-23,4)") + << (SignalList() << Move(3,9,12) << Move(18,23,4)) + << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1)); + QTest::newRow("m(3-9,12),m(20-23,4)") + << (SignalList() << Move(3,9,12) << Move(20,23,4)) + << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1)); + + QTest::newRow("m(3-9,12),m(11-23,10)") + << (SignalList() << Move(3,9,12) << Move(11,23,10)) + << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1)); // Change - QTest::newRow("c(4-9)") - << (SignalList() << Change(4, 9)) - << (SignalList() << Change(4, 9)); - QTest::newRow("c(4-9),c(12-14)") - << (SignalList() << Change(4, 9) << Change(12, 14)) - << (SignalList() << Change(4, 9) << Change(12, 14)); - QTest::newRow("c(12-14),c(4-9)") - << (SignalList() << Change(12, 14) << Change(4, 9)) - << (SignalList() << Change(4, 9) << Change(12, 14)); - QTest::newRow("c(4-9),c(2-4)") - << (SignalList() << Change(4, 9) << Change(2, 4)) - << (SignalList() << Change(2, 9)); - QTest::newRow("c(4-9),c(9-11)") - << (SignalList() << Change(4, 9) << Change(9, 11)) - << (SignalList() << Change(4, 11)); - QTest::newRow("c(4-9),c(3-5)") - << (SignalList() << Change(4, 9) << Change(3, 5)) - << (SignalList() << Change(3, 9)); - QTest::newRow("c(4-9),c(8-10)") - << (SignalList() << Change(4, 9) << Change(8, 10)) - << (SignalList() << Change(4, 10)); - QTest::newRow("c(4-9),c(3-5)") - << (SignalList() << Change(4, 9) << Change(3, 5)) - << (SignalList() << Change(3, 9)); - QTest::newRow("c(4-9),c(2,11)") - << (SignalList() << Change(4, 9) << Change(2, 11)) - << (SignalList() << Change(2, 11)); - QTest::newRow("c(4-9),c(12-15),c(8-14)") - << (SignalList() << Change(4, 9) << Change(12, 15) << Change(8, 14)) - << (SignalList() << Change(4, 15)); - - // Insert, then remove. - QTest::newRow("i(12-18),r(12-18)") - << (SignalList() << Insert(12, 18) << Remove(12, 18)) + QTest::newRow("c(4,5)") + << (SignalList() << Change(4,5)) + << (SignalList() << Change(4,5)); + QTest::newRow("c(4,5),c(12,2)") + << (SignalList() << Change(4,5) << Change(12,2)) + << (SignalList() << Change(4,5) << Change(12,2)); + QTest::newRow("c(12,2),c(4,5)") + << (SignalList() << Change(12,2) << Change(4,5)) + << (SignalList() << Change(4,5) << Change(12,2)); + QTest::newRow("c(4,5),c(2,2)") + << (SignalList() << Change(4,5) << Change(2,2)) + << (SignalList() << Change(2,7)); + QTest::newRow("c(4,5),c(9,2)") + << (SignalList() << Change(4,5) << Change(9,2)) + << (SignalList() << Change(4,7)); + QTest::newRow("c(4,5),c(3,2)") + << (SignalList() << Change(4,5) << Change(3,2)) + << (SignalList() << Change(3,6)); + QTest::newRow("c(4,5),c(8,2)") + << (SignalList() << Change(4,5) << Change(8,2)) + << (SignalList() << Change(4,6)); + QTest::newRow("c(4,5),c(3,2)") + << (SignalList() << Change(4,5) << Change(3,2)) + << (SignalList() << Change(3,6)); + QTest::newRow("c(4,5),c(2,9)") + << (SignalList() << Change(4,5) << Change(2,9)) + << (SignalList() << Change(2,9)); + QTest::newRow("c(4,5),c(12,3),c(8,6)") + << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6)) + << (SignalList() << Change(4,11)); + + // Insert,then remove. + QTest::newRow("i(12,6),r(12,6)") + << (SignalList() << Insert(12,6) << Remove(12,6)) << (SignalList()); - QTest::newRow("i(12-18),r(10-14)") - << (SignalList() << Insert(12, 18) << Remove(10, 14)) - << (SignalList() << Remove(10, 12) << Insert(10, 14)); - QTest::newRow("i(12-18),r(16-20)") - << (SignalList() << Insert(12, 18) << Remove(16, 20)) - << (SignalList() << Remove(12, 14) << Insert(12, 16)); - QTest::newRow("i(12-18),r(13-17)") - << (SignalList() << Insert(12, 18) << Remove(13, 17)) - << (SignalList() << Insert(12, 14)); - QTest::newRow("i(12-18),r(14,18)") - << (SignalList() << Insert(12, 18) << Remove(14, 18)) - << (SignalList() << Insert(12, 14)); - QTest::newRow("i(12-18),r(12-16)") - << (SignalList() << Insert(12, 18) << Remove(12, 16)) - << (SignalList() << Insert(12, 14)); - QTest::newRow("i(12-18),r(11-19)") - << (SignalList() << Insert(12, 18) << Remove(11, 19)) - << (SignalList() << Remove(11, 13)); - QTest::newRow("i(12-18),r(8-12)") - << (SignalList() << Insert(12, 18) << Remove(8, 12)) - << (SignalList() << Remove(8, 12) << Insert(8, 14)); - QTest::newRow("i(12-18),r(2-6)") - << (SignalList() << Insert(12, 18) << Remove(2, 6)) - << (SignalList() << Remove(2, 6) << Insert(8, 14)); - QTest::newRow("i(12-18),r(18-22)") - << (SignalList() << Insert(12, 18) << Remove(18, 22)) - << (SignalList() << Remove(12, 16) << Insert(12, 18)); - QTest::newRow("i(12-18),r(20-24)") - << (SignalList() << Insert(12, 18) << Remove(20, 24)) - << (SignalList() << Remove(14, 18) << Insert(12, 18)); - - // Insert, then move - QTest::newRow("i(12-18),m(12-18,5)") - << (SignalList() << Insert(12, 18) << Move(12, 18, 5)) - << (SignalList() << Insert(5, 11)); - QTest::newRow("i(12-18),m(10-14,5)") - << (SignalList() << Insert(12, 18) << Move(10, 14, 5)) - << (SignalList() << Insert(5, 7) << Insert(14, 18) << Move(12, 14, 5)); - QTest::newRow("i(12-18),m(16-20,5)") - << (SignalList() << Insert(12, 18) << Move(16, 20, 5)) - << (SignalList() << Insert(5, 7) << Insert(14, 18) << Move(18, 20, 7)); - QTest::newRow("i(12-18),m(13-17,5)") - << (SignalList() << Insert(12, 18) << Move(13, 17, 5)) - << (SignalList() << Insert(5, 9) << Insert(16, 18)); - QTest::newRow("i(12-18),m(14-18,5)") - << (SignalList() << Insert(12, 18) << Move(14, 18, 5)) - << (SignalList() << Insert(5, 9) << Insert(16, 18)); - QTest::newRow("i(12-18),m(12-16,5)") - << (SignalList() << Insert(12, 18) << Move(12, 16, 5)) - << (SignalList() << Insert(5, 9) << Insert(16, 18)); - QTest::newRow("i(12-18),m(11-19,5)") - << (SignalList() << Insert(12, 18) << Move(11, 19, 5)) - << (SignalList() << Insert(5, 11) << Move(17, 18, 5) << Move(18, 19, 12)); - QTest::newRow("i(12-18),m(8-12,5)") - << (SignalList() << Insert(12, 18) << Move(8, 12, 5)) - << (SignalList() << Insert(12, 18) << Move(8, 12, 5)); - QTest::newRow("i(12-18),m(2-6,5)") - << (SignalList() << Insert(12, 18) << Move(2, 6, 5)) - << (SignalList() << Insert(12, 18) << Move(2, 6, 5)); - QTest::newRow("i(12-18),m(18-22,5)") - << (SignalList() << Insert(12, 18) << Move(18, 22, 5)) - << (SignalList() << Insert(12, 18) << Move(18, 22, 5)); - QTest::newRow("i(12-18),m(20-24,5)") - << (SignalList() << Insert(12, 18) << Move(20, 24, 5)) - << (SignalList() << Insert(12, 18) << Move(20, 24, 5)); - - QTest::newRow("i(12-18),m(5-13,11)") - << (SignalList() << Insert(12, 18) << Move(5, 13, 11)) - << (SignalList() << Insert(12, 17) << Insert(18, 19) << Move(5, 12, 11)); - - QTest::newRow("i(12-18),m(12-18,23)") - << (SignalList() << Insert(12, 18) << Move(12, 18, 23)) - << (SignalList() << Insert(23, 29)); - QTest::newRow("i(12-18),m(10-14,23)") - << (SignalList() << Insert(12, 18) << Move(10, 14, 23)) - << (SignalList() << Insert(12, 16) << Insert(25, 27) << Move(10, 12, 23)); - QTest::newRow("i(12-18),m(16-20,23)") - << (SignalList() << Insert(12, 18) << Move(16, 20, 23)) - << (SignalList() << Insert(12, 16) << Insert(25, 27) << Move(16, 18, 25)); - QTest::newRow("i(12-18),m(13-17,23)") - << (SignalList() << Insert(12, 18) << Move(13, 17, 23)) - << (SignalList() << Insert(12, 14) << Insert(23, 27)); - QTest::newRow("i(12-18),m(14-18,23)") - << (SignalList() << Insert(12, 18) << Move(14, 18, 23)) - << (SignalList() << Insert(12, 14) << Insert(23, 27)); - QTest::newRow("i(12-18),m(12-16,23)") - << (SignalList() << Insert(12, 18) << Move(12, 16, 23)) - << (SignalList() << Insert(12, 14) << Insert(23, 27)); - QTest::newRow("i(12-18),m(11-19,23)") - << (SignalList() << Insert(12, 18) << Move(11, 19, 23)) - << (SignalList() << Insert(25, 31) << Move(11, 12, 24) << Move(11, 12, 30)); - QTest::newRow("i(12-18),m(8-12,23)") - << (SignalList() << Insert(12, 18) << Move(8, 12, 23)) - << (SignalList() << Insert(12, 18) << Move(8, 12, 23)); - QTest::newRow("i(12-18),m(2-6,23)") - << (SignalList() << Insert(12, 18) << Move(2, 6, 23)) - << (SignalList() << Insert(12, 18) << Move(2, 6, 23)); - QTest::newRow("i(12-18),m(18-22,23)") - << (SignalList() << Insert(12, 18) << Move(18, 22, 23)) - << (SignalList() << Insert(12, 18) << Move(18, 22, 23)); - QTest::newRow("i(12-18),m(20-24,23)") - << (SignalList() << Insert(12, 18) << Move(20, 24, 23)) - << (SignalList() << Insert(12, 18) << Move(20, 24, 23)); - - QTest::newRow("i(12-18),m(11-21,23)") - << (SignalList() << Insert(12, 18) << Move(11, 21, 23)) - << (SignalList() << Insert(27, 33) << Move(11, 12, 26) << Move(11, 14, 30)); - - // Insert, then change - QTest::newRow("i(12-18),c(12-16)") - << (SignalList() << Insert(12, 18) << Change(12, 6)) - << (SignalList() << Insert(12, 18)); - QTest::newRow("i(12-18),c(10-14)") - << (SignalList() << Insert(12, 18) << Change(10, 16)) - << (SignalList() << Insert(12, 18) << Change(10, 12)); - QTest::newRow("i(12-18),c(16-20)") - << (SignalList() << Insert(12, 18) << Change(16, 20)) - << (SignalList() << Insert(12, 18) << Change(18, 20)); - QTest::newRow("i(12-18),c(13-17)") - << (SignalList() << Insert(12, 18) << Change(13, 17)) - << (SignalList() << Insert(12, 18)); - QTest::newRow("i(12-18),c(14-18)") - << (SignalList() << Insert(12, 18) << Change(14, 18)) - << (SignalList() << Insert(12, 18)); - QTest::newRow("i(12-18),c(12-16)") - << (SignalList() << Insert(12, 18) << Change(12, 16)) - << (SignalList() << Insert(12, 18)); - QTest::newRow("i(12-18),c(11-19)") - << (SignalList() << Insert(12, 18) << Change(11, 19)) - << (SignalList() << Insert(12, 18) << Change(11, 12) << Change(18, 19)); - QTest::newRow("i(12-18),c(8-12)") - << (SignalList() << Insert(12, 18) << Change(8, 12)) - << (SignalList() << Insert(12, 18) << Change(8, 12)); - QTest::newRow("i(12-18),c(2-6)") - << (SignalList() << Insert(12, 18) << Change(2, 6)) - << (SignalList() << Insert(12, 18) << Change(2, 6)); - QTest::newRow("i(12-18),c(18-22)") - << (SignalList() << Insert(12, 18) << Change(18, 22)) - << (SignalList() << Insert(12, 18) << Change(18, 22)); - QTest::newRow("i(12-18),c(20-24)") - << (SignalList() << Insert(12, 18) << Change(20, 24)) - << (SignalList() << Insert(12, 18) << Change(20, 24)); - - // Remove, then insert - QTest::newRow("r(12-18),i(12-18)") - << (SignalList() << Remove(12, 18) << Insert(12, 18)) - << (SignalList() << Remove(12, 18) << Insert(12, 18)); - QTest::newRow("r(12-18),i(10-14)") - << (SignalList() << Remove(12, 18) << Insert(10, 14)) - << (SignalList() << Remove(12, 18) << Insert(10, 14)); - QTest::newRow("r(12-18),i(16-20)") - << (SignalList() << Remove(12, 18) << Insert(16, 20)) - << (SignalList() << Remove(12, 18) << Insert(16, 20)); - QTest::newRow("r(12-18),i(13-17)") - << (SignalList() << Remove(12, 18) << Insert(13, 17)) - << (SignalList() << Remove(12, 18) << Insert(13, 17)); - QTest::newRow("r(12-18),i(14-18)") - << (SignalList() << Remove(12, 18) << Insert(14, 18)) - << (SignalList() << Remove(12, 18) << Insert(14, 18)); - QTest::newRow("r(12-18),i(12-16)") - << (SignalList() << Remove(12, 18) << Insert(12, 16)) - << (SignalList() << Remove(12, 18) << Insert(12, 16)); - QTest::newRow("r(12-18),i(11-19)") - << (SignalList() << Remove(12, 18) << Insert(11, 19)) - << (SignalList() << Remove(12, 18) << Insert(11, 19)); - QTest::newRow("i(12-18),r(8-12)") - << (SignalList() << Remove(12, 18) << Insert(8, 12)) - << (SignalList() << Remove(12, 18) << Insert(8, 12)); - QTest::newRow("i(12-18),r(2-6)") - << (SignalList() << Remove(12, 18) << Insert(2, 6)) - << (SignalList() << Remove(12, 18) << Insert(2, 6)); - QTest::newRow("i(12-18),r(18-22)") - << (SignalList() << Remove(12, 18) << Insert(18, 22)) - << (SignalList() << Remove(12, 18) << Insert(18, 22)); - QTest::newRow("i(12-18),r(20-24)") - << (SignalList() << Remove(12, 18) << Insert(20, 24)) - << (SignalList() << Remove(12, 18) << Insert(20, 24)); - - // Move, then insert - QTest::newRow("m(12-18,5),i(12-18)") - << (SignalList() << Move(12, 18, 5) << Insert(12, 18)) - << (SignalList() << Insert(6, 12) << Move(18, 24, 5)); - QTest::newRow("m(12-18,5),i(10-14)") - << (SignalList() << Move(12, 18, 5) << Insert(10, 14)) - << (SignalList() << Insert(5, 9) << Move(16, 21, 5) << Move(21, 22, 14)); - QTest::newRow("m(12-18,5),i(16-20)") - << (SignalList() << Move(12, 18, 5) << Insert(16, 20)) - << (SignalList() << Insert(10, 14) << Move(16, 22, 5)); - QTest::newRow("m(12-18,5),i(13-17)") - << (SignalList() << Move(12, 18, 5) << Insert(13, 17)) - << (SignalList() << Insert(7, 11) << Move(16, 22, 5)); - QTest::newRow("m(12-18,5),i(14-18)") - << (SignalList() << Move(12, 18, 5) << Insert(14, 18)) - << (SignalList() << Insert(8, 12) << Move(16, 22, 5)); - QTest::newRow("m(12-18,5),i(12-16)") - << (SignalList() << Move(12, 18, 5) << Insert(12, 16)) - << (SignalList() << Insert(6, 10) << Move(16, 22, 5)); - QTest::newRow("m(12-18,5),i(11-19)") - << (SignalList() << Move(12, 18, 5) << Insert(11, 19)) - << (SignalList() << Insert(5, 13) << Move(20, 26, 5)); - QTest::newRow("m(12-18,5),i(8-12)") - << (SignalList() << Move(12, 18, 5) << Insert(8, 12)) - << (SignalList() << Insert(5, 9) << Move(16, 19, 5) << Move(19, 22, 12)); - QTest::newRow("m(12-18,5),i(2-6)") - << (SignalList() << Move(12, 18, 5) << Insert(2, 6)) - << (SignalList() << Insert(2, 6) << Move(16, 22, 9)); - QTest::newRow("m(12-18,5),i(18-22)") - << (SignalList() << Move(12, 18, 5) << Insert(18, 22)) - << (SignalList() << Insert(18, 22) << Move(12, 18, 5)); - QTest::newRow("m(12-18,5),i(20-24)") - << (SignalList() << Move(12, 18, 5) << Insert(20, 24)) - << (SignalList() << Insert(20, 24) << Move(12, 18, 5)); - - QTest::newRow("m(12-18,23),i(12-18)") - << (SignalList() << Move(12, 18, 23) << Insert(12, 18)) - << (SignalList() << Insert(12, 18) << Move(18, 24, 29)); - QTest::newRow("m(12-18,23),i(10-14)") - << (SignalList() << Move(12, 18, 23) << Insert(10, 14)) - << (SignalList() << Insert(10, 14) << Move(16, 22, 27)); - QTest::newRow("m(12-18,23),i(16-20)") - << (SignalList() << Move(12, 18, 23) << Insert(16, 20)) - << (SignalList() << Insert(22, 26) << Move(12, 18, 27)); - QTest::newRow("m(12-18,23),i(13-17)") - << (SignalList() << Move(12, 18, 23) << Insert(13, 17)) - << (SignalList() << Insert(19, 23) << Move(12, 18, 27)); - QTest::newRow("m(12-18,23),i(14-18)") - << (SignalList() << Move(12, 18, 23) << Insert(14, 18)) - << (SignalList() << Insert(20, 24) << Move(12, 18, 27)); - QTest::newRow("m(12-18,23),i(12-16)") - << (SignalList() << Move(12, 18, 23) << Insert(12, 16)) - << (SignalList() << Insert(12, 16) << Move(16, 22, 27)); - QTest::newRow("m(12-18,23),i(11-19)") - << (SignalList() << Move(12, 18, 23) << Insert(11, 19)) - << (SignalList() << Insert(11, 19) << Move(20, 26, 31)); - QTest::newRow("m(12-18,23),i(8-12)") - << (SignalList() << Move(12, 18, 23) << Insert(8, 12)) - << (SignalList() << Insert(8, 12) << Move(16, 22, 27)); - QTest::newRow("m(12-18,23),i(2-6)") - << (SignalList() << Move(12, 18, 23) << Insert(2, 6)) - << (SignalList() << Insert(2, 6) << Move(16, 22, 27)); - QTest::newRow("m(12-18,23),i(18-22)") - << (SignalList() << Move(12, 18, 23) << Insert(18, 22)) - << (SignalList() << Insert(24, 28) << Move(12, 18, 27)); - QTest::newRow("m(12-18,23),i(20-24)") - << (SignalList() << Move(12, 18, 23) << Insert(20, 24)) - << (SignalList() << Insert(26, 30) << Move(12, 18, 27)); - - // Move, then remove - QTest::newRow("m(12-18,5),r(12-18)") - << (SignalList() << Move(12, 18, 5) << Remove(12, 18)) - << (SignalList() << Remove(6, 12) << Move(6, 12, 5)); - QTest::newRow("m(12-18,5),r(10-14)") - << (SignalList() << Move(12, 18, 5) << Remove(10, 14)) - << (SignalList() << Remove(5, 8) << Remove(14, 15) << Move(9, 14, 5)); - QTest::newRow("m(12-18,5),r(16-20)") - << (SignalList() << Move(12, 18, 5) << Remove(16, 20)) - << (SignalList() << Remove(10, 12) << Remove(16, 18) << Move(10, 16, 5)); - QTest::newRow("m(12-18,5),r(13-17)") - << (SignalList() << Move(12, 18, 5) << Remove(13, 17)) - << (SignalList() << Remove(7, 11) << Move(8, 14, 5)); - QTest::newRow("m(12-18,5),r(14-18)") - << (SignalList() << Move(12, 18, 5) << Remove(14, 18)) - << (SignalList() << Remove(8, 12) << Move(8, 14, 5)); - QTest::newRow("m(12-18,5),r(12-16)") - << (SignalList() << Move(12, 18, 5) << Remove(12, 16)) - << (SignalList() << Remove(6, 10) << Move(8, 14, 5)); - QTest::newRow("m(12-18,5),r(11-19)") - << (SignalList() << Move(12, 18, 5) << Remove(11, 19)) - << (SignalList() << Remove(5, 12) << Remove(11, 12)); - QTest::newRow("m(12-18,5),r(8-12)") - << (SignalList() << Move(12, 18, 5) << Remove(8, 12)) - << (SignalList() << Remove(5, 6) << Remove(14, 17) << Move(11, 14, 5)); - QTest::newRow("m(12-18,5),r(2-6)") - << (SignalList() << Move(12, 18, 5) << Remove(2, 6)) - << (SignalList() << Remove(2, 5) << Remove(9, 10) << Move(9, 14, 2)); - QTest::newRow("m(12-18,5),r(6-10)") - << (SignalList() << Move(12, 18, 5) << Remove(6, 10)) - << (SignalList() << Remove(13, 17) << Move(12, 14, 5)); - QTest::newRow("m(12-18,5),r(18-22)") - << (SignalList() << Move(12, 18, 5) << Remove(18, 22)) - << (SignalList() << Remove(18, 22) << Move(12, 18, 5)); - QTest::newRow("m(12-18,5),r(20-24)") - << (SignalList() << Move(12, 18, 5) << Remove(20, 24)) - << (SignalList() << Remove(20, 24) << Move(12, 18, 5)); - - QTest::newRow("m(12-18,23),r(12-18)") - << (SignalList() << Move(12, 18, 23) << Remove(12, 18)) - << (SignalList() << Remove(18, 24) << Move(12, 18, 17)); - QTest::newRow("m(12-18,23),r(10-14)") - << (SignalList() << Move(12, 18, 23) << Remove(10, 14)) - << (SignalList() << Remove(10, 12) << Remove(16, 18) << Move(10, 16, 19)); - QTest::newRow("m(12-18,23),r(16-20)") - << (SignalList() << Move(12, 18, 23) << Remove(16, 20)) - << (SignalList() << Remove(22, 26) << Move(12, 18, 19)); - QTest::newRow("m(12-18,23),r(13-17)") - << (SignalList() << Move(12, 18, 23) << Remove(13, 17)) - << (SignalList() << Remove(19, 23) << Move(12, 18, 19)); - QTest::newRow("m(12-18,23),r(14-18)") - << (SignalList() << Move(12, 18, 23) << Remove(14, 18)) - << (SignalList() << Remove(20, 24) << Move(12, 18, 19)); - QTest::newRow("m(12-18,23),r(12-16)") - << (SignalList() << Move(12, 18, 23) << Remove(12, 16)) - << (SignalList() << Remove(18, 22) << Move(12, 18, 19)); - QTest::newRow("m(12-18,23),r(11-19)") - << (SignalList() << Move(12, 18, 23) << Remove(11, 19)) - << (SignalList() << Remove(11, 12) << Remove(17, 24) << Move(11, 17, 15)); - QTest::newRow("m(12-18,23),r(8-12)") - << (SignalList() << Move(12, 18, 23) << Remove(8, 12)) - << (SignalList() << Remove(8, 12) << Move(8, 14, 19)); - QTest::newRow("m(12-18,23),r(2-6)") - << (SignalList() << Move(12, 18, 23) << Remove(2, 6)) - << (SignalList() << Remove(2, 6) << Move(8, 14, 19)); - QTest::newRow("m(12-18,23),r(18-22)") - << (SignalList() << Move(12, 18, 23) << Remove(18, 22)) - << (SignalList() << Remove(24, 28) << Move(12, 18, 19)); - QTest::newRow("m(12-18,23),r(20-24)") - << (SignalList() << Move(12, 18, 23) << Remove(20, 24)) - << (SignalList() << Remove(12, 13) << Remove(25, 28) << Move(12, 17, 20)); + QTest::newRow("i(12,6),r(10,4)") + << (SignalList() << Insert(12,6) << Remove(10,4)) + << (SignalList() << Remove(10,2) << Insert(10,4)); + QTest::newRow("i(12,6),r(16,4)") + << (SignalList() << Insert(12,6) << Remove(16,4)) + << (SignalList() << Remove(12,2) << Insert(12,4)); + QTest::newRow("i(12,6),r(13,4)") + << (SignalList() << Insert(12,6) << Remove(13,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(14,4)") + << (SignalList() << Insert(12,6) << Remove(14,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(12,4)") + << (SignalList() << Insert(12,6) << Remove(12,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(11,8)") + << (SignalList() << Insert(12,6) << Remove(11,8)) + << (SignalList() << Remove(11,2)); + QTest::newRow("i(12,6),r(8,4)") + << (SignalList() << Insert(12,6) << Remove(8,4)) + << (SignalList() << Remove(8,4) << Insert(8,6)); + QTest::newRow("i(12,6),r(2,4)") + << (SignalList() << Insert(12,6) << Remove(2,4)) + << (SignalList() << Remove(2,4) << Insert(8,6)); + QTest::newRow("i(12,6),r(18,4)") + << (SignalList() << Insert(12,6) << Remove(18,4)) + << (SignalList() << Remove(12,4) << Insert(12,6)); + QTest::newRow("i(12,6),r(20,4)") + << (SignalList() << Insert(12,6) << Remove(20,4)) + << (SignalList() << Remove(14,4) << Insert(12,6)); + + // Insert,then move + QTest::newRow("i(12,6),m(12-5,6)") + << (SignalList() << Insert(12,6) << Move(12,5,6)) + << (SignalList() << Insert(5,6)); + QTest::newRow("i(12,6),m(10-5,4)") + << (SignalList() << Insert(12,6) << Move(10,5,4)) + << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4)); + QTest::newRow("i(12,6),m(16-5,4)") + << (SignalList() << Insert(12,6) << Move(16,5,4)) + << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4)); + QTest::newRow("i(12,6),m(13-5,4)") + << (SignalList() << Insert(12,6) << Move(13,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(14-5,4)") + << (SignalList() << Insert(12,6) << Move(14,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(12-5,4)") + << (SignalList() << Insert(12,6) << Move(12,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(11-5,8)") + << (SignalList() << Insert(12,6) << Move(11,5,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1)); + QTest::newRow("i(12,6),m(8-5,4)") + << (SignalList() << Insert(12,6) << Move(8,5,4)) + << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6)); + QTest::newRow("i(12,6),m(2-5,4)") + << (SignalList() << Insert(12,6) << Move(2,5,4)) + << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6)); + QTest::newRow("i(12,6),m(18-5,4)") + << (SignalList() << Insert(12,6) << Move(18,5,4)) + << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6)); + QTest::newRow("i(12,6),m(20-5,4)") + << (SignalList() << Insert(12,6) << Move(20,5,4)) + << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6)); + + QTest::newRow("i(12,6),m(5-13,11)") + << (SignalList() << Insert(12,6) << Move(5,11,8)) + << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1)); + + QTest::newRow("i(12,6),m(12-23,6)") + << (SignalList() << Insert(12,6) << Move(12,23,6)) + << (SignalList() << Insert(23,6)); + QTest::newRow("i(12,6),m(10-23,4)") + << (SignalList() << Insert(12,6) << Move(10,23,4)) + << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2)); + QTest::newRow("i(12,6),m(16-23,4)") + << (SignalList() << Insert(12,6) << Move(16,23,4)) + << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0)); + QTest::newRow("i(12,6),m(13-23,4)") + << (SignalList() << Insert(12,6) << Move(13,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(14-23,4)") + << (SignalList() << Insert(12,6) << Move(14,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(12-23,4)") + << (SignalList() << Insert(12,6) << Move(12,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(11-23,8)") + << (SignalList() << Insert(12,6) << Move(11,23,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1)); + QTest::newRow("i(12,6),m(8-23,4)") + << (SignalList() << Insert(12,6) << Move(8,23,4)) + << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(2-23,4)") + << (SignalList() << Insert(12,6) << Move(2,23,4)) + << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(18-23,4)") + << (SignalList() << Insert(12,6) << Move(18,23,4)) + << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(20-23,4)") + << (SignalList() << Insert(12,6) << Move(20,23,4)) + << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0)); + + QTest::newRow("i(12,6),m(11-23,10)") + << (SignalList() << Insert(12,6) << Move(11,23,10)) + << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1)); + + // Insert,then change + QTest::newRow("i(12,6),c(12,6)") + << (SignalList() << Insert(12,6) << Change(12,6)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(10,6)") + << (SignalList() << Insert(12,6) << Change(10,6)) + << (SignalList() << Insert(12,6) << Change(10,2)); + QTest::newRow("i(12,6),c(16,4)") + << (SignalList() << Insert(12,6) << Change(16,4)) + << (SignalList() << Insert(12,6) << Change(18,2)); + QTest::newRow("i(12,6),c(13,4)") + << (SignalList() << Insert(12,6) << Change(13,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(14,4)") + << (SignalList() << Insert(12,6) << Change(14,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(12,4)") + << (SignalList() << Insert(12,6) << Change(12,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(11,8)") + << (SignalList() << Insert(12,6) << Change(11,8)) + << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1)); + QTest::newRow("i(12,6),c(8,4)") + << (SignalList() << Insert(12,6) << Change(8,4)) + << (SignalList() << Insert(12,6) << Change(8,4)); + QTest::newRow("i(12,6),c(2,4)") + << (SignalList() << Insert(12,6) << Change(2,4)) + << (SignalList() << Insert(12,6) << Change(2,4)); + QTest::newRow("i(12,6),c(18,4)") + << (SignalList() << Insert(12,6) << Change(18,4)) + << (SignalList() << Insert(12,6) << Change(18,4)); + QTest::newRow("i(12,6),c(20,4)") + << (SignalList() << Insert(12,6) << Change(20,4)) + << (SignalList() << Insert(12,6) << Change(20,4)); + + // Remove,then insert + QTest::newRow("r(12,6),i(12,6)") + << (SignalList() << Remove(12,6) << Insert(12,6)) + << (SignalList() << Remove(12,6) << Insert(12,6)); + QTest::newRow("r(12,6),i(10,4)") + << (SignalList() << Remove(12,6) << Insert(10,14)) + << (SignalList() << Remove(12,6) << Insert(10,14)); + QTest::newRow("r(12,6),i(16,4)") + << (SignalList() << Remove(12,6) << Insert(16,4)) + << (SignalList() << Remove(12,6) << Insert(16,4)); + QTest::newRow("r(12,6),i(13,4)") + << (SignalList() << Remove(12,6) << Insert(13,4)) + << (SignalList() << Remove(12,6) << Insert(13,4)); + QTest::newRow("r(12,6),i(14,4)") + << (SignalList() << Remove(12,6) << Insert(14,4)) + << (SignalList() << Remove(12,6) << Insert(14,4)); + QTest::newRow("r(12,6),i(12,4)") + << (SignalList() << Remove(12,6) << Insert(12,4)) + << (SignalList() << Remove(12,6) << Insert(12,4)); + QTest::newRow("r(12,6),i(11,8)") + << (SignalList() << Remove(12,6) << Insert(11,8)) + << (SignalList() << Remove(12,6) << Insert(11,8)); + QTest::newRow("r(12,6),i(8,4)") + << (SignalList() << Remove(12,6) << Insert(8,4)) + << (SignalList() << Remove(12,6) << Insert(8,4)); + QTest::newRow("r(12,6),i(2,4)") + << (SignalList() << Remove(12,6) << Insert(2,4)) + << (SignalList() << Remove(12,6) << Insert(2,4)); + QTest::newRow("r(12,6),i(18,4)") + << (SignalList() << Remove(12,6) << Insert(18,4)) + << (SignalList() << Remove(12,6) << Insert(18,4)); + QTest::newRow("r(12,6),i(20,4)") + << (SignalList() << Remove(12,6) << Insert(20,4)) + << (SignalList() << Remove(12,6) << Insert(20,4)); + + // Move,then insert + QTest::newRow("m(12-5,6),i(12,6)") + << (SignalList() << Move(12,5,6) << Insert(12,6)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6)); + QTest::newRow("m(12-5,6),i(10,4)") + << (SignalList() << Move(12,5,6) << Insert(10,4)) + << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1)); + QTest::newRow("m(12-5,6),i(16,4)") + << (SignalList() << Move(12,5,6) << Insert(16,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4)); + QTest::newRow("m(12-5,6),i(13,4)") + << (SignalList() << Move(12,5,6) << Insert(13,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4)); + QTest::newRow("m(12-5,6),i(14,4)") + << (SignalList() << Move(12,5,6) << Insert(14,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4)); + QTest::newRow("m(12-5,6),i(12,4)") + << (SignalList() << Move(12,5,6) << Insert(12,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4)); + QTest::newRow("m(12-5,6),i(11,8)") + << (SignalList() << Move(12,5,6) << Insert(11,8)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8)); + QTest::newRow("m(12-5,6),i(8,4)") + << (SignalList() << Move(12,5,6) << Insert(8,4)) + << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1)); + QTest::newRow("m(12-5,6),i(2,4)") + << (SignalList() << Move(12,5,6) << Insert(2,4)) + << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0)); + QTest::newRow("m(12-5,6),i(18,4)") + << (SignalList() << Move(12,5,6) << Insert(18,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4)); + QTest::newRow("m(12-5,6),i(20,4)") + << (SignalList() << Move(12,5,6) << Insert(20,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4)); + + QTest::newRow("m(12-23,6),i(12,6)") + << (SignalList() << Move(12,23,6) << Insert(12,6)) + << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0)); + QTest::newRow("m(12-23,6),i(10,4)") + << (SignalList() << Move(12,23,6) << Insert(10,4)) + << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(16,4)") + << (SignalList() << Move(12,23,6) << Insert(16,4)) + << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(13,4)") + << (SignalList() << Move(12,23,6) << Insert(13,4)) + << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(14,4)") + << (SignalList() << Move(12,23,6) << Insert(14,4)) + << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(12,4)") + << (SignalList() << Move(12,23,6) << Insert(12,4)) + << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(11,8)") + << (SignalList() << Move(12,23,6) << Insert(11,8)) + << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0)); + QTest::newRow("m(12-23,6),i(8,4)") + << (SignalList() << Move(12,23,6) << Insert(8,4)) + << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(2,4)") + << (SignalList() << Move(12,23,6) << Insert(2,4)) + << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(18,4)") + << (SignalList() << Move(12,23,6) << Insert(18,4)) + << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(20,4)") + << (SignalList() << Move(12,23,6) << Insert(20,4)) + << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0)); + + // Move,then remove + QTest::newRow("m(12-5,6),r(12,6)") + << (SignalList() << Move(12,5,6) << Remove(12,6)) + << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(10,4)") + << (SignalList() << Move(12,5,6) << Remove(10,4)) + << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0)); + QTest::newRow("m(12-5,6),r(16,4)") + << (SignalList() << Move(12,5,6) << Remove(16,4)) + << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(13,4)") + << (SignalList() << Move(12,5,6) << Remove(13,4)) + << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(14,4)") + << (SignalList() << Move(12,5,6) << Remove(14,4)) + << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(12,4)") + << (SignalList() << Move(12,5,6) << Remove(12,4)) + << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(11,8)") + << (SignalList() << Move(12,5,6) << Remove(11,8)) + << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(8,4)") + << (SignalList() << Move(12,5,6) << Remove(8,4)) + << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0)); + QTest::newRow("m(12-5,6),r(2,4)") + << (SignalList() << Move(12,5,6) << Remove(2,4)) + << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0)); + QTest::newRow("m(12-5,6),r(6,4)") + << (SignalList() << Move(12,5,6) << Remove(6,4)) + << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1)); + QTest::newRow("m(12-5,6),r(18,4)") + << (SignalList() << Move(12,5,6) << Remove(18,4)) + << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(20,4)") + << (SignalList() << Move(12,5,6) << Remove(20,4)) + << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0)); + + QTest::newRow("m(12-23,6),r(12,6)") + << (SignalList() << Move(12,23,6) << Remove(12,6)) + << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0)); + QTest::newRow("m(12-23,6),r(10,4)") + << (SignalList() << Move(12,23,6) << Remove(10,4)) + << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(16,4)") + << (SignalList() << Move(12,23,6) << Remove(16,4)) + << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(13,4)") + << (SignalList() << Move(12,23,6) << Remove(13,4)) + << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(14,4)") + << (SignalList() << Move(12,23,6) << Remove(14,4)) + << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(12,4)") + << (SignalList() << Move(12,23,6) << Remove(12,4)) + << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(11,8)") + << (SignalList() << Move(12,23,6) << Remove(11,8)) + << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0)); + QTest::newRow("m(12-23,6),r(8,4)") + << (SignalList() << Move(12,23,6) << Remove(8,4)) + << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(2,4)") + << (SignalList() << Move(12,23,6) << Remove(2,4)) + << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(18,4)") + << (SignalList() << Move(12,23,6) << Remove(18,4)) + << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(20,4)") + << (SignalList() << Move(12,23,6) << Remove(20,4)) + << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0)); } void tst_qdeclarativemodelchange::sequence() @@ -560,24 +733,22 @@ void tst_qdeclarativemodelchange::sequence() foreach (const Signal &signal, input) { if (signal.isRemove()) - set.insertRemove(signal.start, signal.end); + set.remove(signal.index, signal.count); else if (signal.isInsert()) - set.insertInsert(signal.start, signal.end); + set.insert(signal.index, signal.count); else if (signal.isMove()) - set.insertMove(signal.start, signal.end, signal.to); + set.move(signal.index, signal.to, signal.count); else if (signal.isChange()) - set.insertChange(signal.start, signal.end); + set.change(signal.index, signal.count); } SignalList changes; foreach (const QDeclarativeChangeSet::Remove &remove, set.removes()) - changes << Remove(remove.start, remove.end); + changes << Remove(remove.index, remove.count, remove.moveId); foreach (const QDeclarativeChangeSet::Insert &insert, set.inserts()) - changes << Insert(insert.start, insert.end); - foreach (const QDeclarativeChangeSet::Move &move, set.moves()) - changes << Move(move.start, move.end, move.to); + changes << Insert(insert.index, insert.count, insert.moveId); foreach (const QDeclarativeChangeSet::Change &change, set.changes()) - changes << Change(change.start, change.end); + changes << Change(change.index, change.count); #ifdef VERIFY_EXPECTED_OUTPUT QVector list; -- cgit v1.2.3 From 955c2b0f29dc709a5cc7e563c21f0f2cf2370336 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 9 Aug 2011 11:49:57 +1000 Subject: Copy the docs for QtQuick 1 Change-Id: Iaaaaaaa13726fa471f94fc7f809911164df24544 Reviewed-on: http://codereview.qt.nokia.com/2755 Reviewed-by: Alan Alpert --- tests/auto/declarative/examples/tst_examples.cpp | 6 ++++++ tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 022b9870c5..072ab7524e 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -76,14 +76,20 @@ private: tst_examples::tst_examples() { // Add directories you want excluded here + + // These snippets are not expected to run on their own. excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; excludedDirs << "doc/src/snippets/declarative/qtbinding"; excludedDirs << "doc/src/snippets/declarative/imports"; + excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; + excludedDirs << "doc/src/snippets/qtquick1/imports"; #ifdef QT_NO_WEBKIT excludedDirs << "examples/declarative/modelviews/webview"; excludedDirs << "examples/declarative/webbrowser"; excludedDirs << "doc/src/snippets/declarative/webview"; + excludedDirs << "doc/src/snippets/qtquick1/webview"; #endif #ifdef QT_NO_XMLPATTERNS diff --git a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp index cfacae2428..0e2490a3cf 100644 --- a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp +++ b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp @@ -71,7 +71,8 @@ private: tst_moduleqt47::tst_moduleqt47() { excludedFiles << "tests/auto/qtquick1/moduleqt47/data/importqt47.qml" - << "doc/src/declarative/whatsnew.qdoc"; + << "doc/src/declarative/whatsnew.qdoc" + << "doc/src/qtquick1/whatsnew.qdoc"; } void tst_moduleqt47::create() -- cgit v1.2.3 From 2601011f1c0168f080c488be09c888042812f7cb Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 10 Aug 2011 13:51:32 +1000 Subject: Add support for individual row and column spacing to Grid object. Add rowSpacing and columnSpacing properties to QML Grid object. If these are specified, use them when laying out the grid. If they are not specified, default to using the spacing property that was previously used, so it is backwards compatible. Task-number: QTBUG-11876 Change-Id: I5c809e89fe124d8d5ea1667b273f19e2c37ff18a Reviewed-on: http://codereview.qt.nokia.com/2797 Reviewed-by: Qt Sanity Bot Reviewed-by: Bea Lam --- .../data/grid-row-column-spacing.qml | 43 ++++++++++++++++++++++ .../qsgpositioners/tst_qsgpositioners.cpp | 34 +++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml (limited to 'tests') diff --git a/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml b/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml new file mode 100644 index 0000000000..49bbd337e7 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 3 + spacing: 4 + rowSpacing: 7 + columnSpacing: 11 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp index 3b2a504ff4..497f511335 100644 --- a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp +++ b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp @@ -76,6 +76,7 @@ private slots: void test_grid_topToBottom(); void test_grid_rightToLeft(); void test_grid_spacing(); + void test_grid_row_column_spacing(); void test_grid_animated(); void test_grid_animated_rightToLeft(); void test_grid_zero_columns(); @@ -622,6 +623,39 @@ void tst_qsgpositioners::test_grid_spacing() delete canvas; } +void tst_qsgpositioners::test_grid_row_column_spacing() +{ + QSGView *canvas = createView(SRCDIR "/data/grid-row-column-spacing.qml"); + + QSGRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QSGRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QSGRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QSGRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QSGRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 61.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 92.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 57.0); + QCOMPARE(five->x(), 61.0); + QCOMPARE(five->y(), 57.0); + + QSGItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 142.0); + QCOMPARE(grid->height(), 107.0); + + delete canvas; +} + void tst_qsgpositioners::test_grid_animated() { QSGView *canvas = createView(SRCDIR "/data/grid-animated.qml"); -- cgit v1.2.3 From aac3704b08a4043318a2a6e4df4aca24c7a4f452 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Fri, 5 Aug 2011 17:21:20 +0200 Subject: Migrate part of QtScript benchmarks to QtDeclarative Benchmarks for QJSValue QJSEngine and for QJSValueIterator were added. Change-Id: Ie52a3e8f5a461add3269d41d6e9a1a9bfb0c7abd Reviewed-on: http://codereview.qt.nokia.com/2705 Reviewed-by: Qt Sanity Bot Reviewed-by: Simon Hausmann --- tests/benchmarks/declarative/declarative.pro | 3 +- tests/benchmarks/declarative/js/js.pro | 10 + .../declarative/js/qjsengine/qjsengine.pro | 12 + .../declarative/js/qjsengine/tst_qjsengine.cpp | 677 +++++++++++++ .../declarative/js/qjsvalue/qjsvalue.pro | 7 + .../declarative/js/qjsvalue/tst_qjsvalue.cpp | 1061 ++++++++++++++++++++ .../js/qjsvalueiterator/qjsvalueiterator.pro | 7 + .../js/qjsvalueiterator/tst_qjsvalueiterator.cpp | 311 ++++++ 8 files changed, 2087 insertions(+), 1 deletion(-) create mode 100644 tests/benchmarks/declarative/js/js.pro create mode 100644 tests/benchmarks/declarative/js/qjsengine/qjsengine.pro create mode 100644 tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp create mode 100644 tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro create mode 100644 tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp create mode 100644 tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro create mode 100644 tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp (limited to 'tests') diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index f2dfdf971a..820d84b0a2 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -10,7 +10,8 @@ SUBDIRS += \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ - qmltime + qmltime \ + js contains(QT_CONFIG, opengl): SUBDIRS += painting diff --git a/tests/benchmarks/declarative/js/js.pro b/tests/benchmarks/declarative/js/js.pro new file mode 100644 index 0000000000..b1448d8eb8 --- /dev/null +++ b/tests/benchmarks/declarative/js/js.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qjsengine \ + qjsvalue \ + qjsvalueiterator \ + +TRUSTED_BENCHMARKS += \ + qjsvalue \ + qjsengine \ + diff --git a/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro b/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro new file mode 100644 index 0000000000..cbd128bf97 --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qjsengine + +SOURCES += tst_qjsengine.cpp + +QT += declarative + +symbian* { + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 // Min 128kB, Max 32MB + TARGET.EPOCSTACKSIZE = 0x14000 +} diff --git a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp new file mode 100644 index 0000000000..ba486df2b1 --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp @@ -0,0 +1,677 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + + +Q_DECLARE_METATYPE(QJSValue) + +//TESTED_FILES= + +class tst_QJSEngine : public QObject +{ + Q_OBJECT + +public: + tst_QJSEngine(); + virtual ~tst_QJSEngine(); + +public slots: + void init(); + void cleanup(); + +private slots: + void constructor(); +#if 0 // No defaultPrototype for now + void defaultPrototype(); + void setDefaultPrototype(); +#endif + void evaluate_data(); + void evaluate(); +#if 0 // No program + void evaluateProgram_data(); + void evaluateProgram(); +#endif +#if 0 // no connections for now + void connectAndDisconnect(); +#endif + void globalObject(); + void hasUncaughtException(); +#if 0 // no is Evaluating for now + void isEvaluating(); +#endif + void newArray_data(); + void newArray(); + void newDate(); + void newDateFromMs(); + void newObject(); +#if 0 // No ScriptClass + void newObjectWithScriptClass(); +#endif +#if 0 // no qmetaobject + void newQMetaObject(); +#endif + void newQObject(); +#if 0 // no native functions for now + void newFunction(); +#endif + void newRegExp(); + void newRegExpFromString(); + void newVariant(); + void nullValue(); + void undefinedValue(); + void collectGarbage(); +#if 0 // No extensions + void availableExtensions(); + void importedExtensions(); +#endif +#if 0 // no context + void currentContext(); + void pushAndPopContext(); +#endif + void toObject_data(); + void toObject(); +#if 0 // no stringhandle + void toStringHandle(); +#endif + void castValueToQreal(); +#if 0 // no native functions for now + void nativeCall(); +#endif +#if 0 // no translations + void installTranslatorFunctions(); + void translation_data(); + void translation(); +#endif +#if 0 // no declarative class + void readScopeProperty_data(); + void readScopeProperty(); +#endif +#if 0 // no context + void evaluateInNewContext(); + void evaluateInNewContextWithScope(); +#endif +#if 0 // no pushScope + void evaluateBindingExpression(); +#endif + +private: + void defineStandardTestValues(); + void newEngine() + { + delete m_engine; + m_engine = new QJSEngine; + } + + QJSEngine *m_engine; +}; + +tst_QJSEngine::tst_QJSEngine() + : m_engine(0) +{ +} + +tst_QJSEngine::~tst_QJSEngine() +{ + delete m_engine; +} + +void tst_QJSEngine::init() +{ +} + +void tst_QJSEngine::cleanup() +{ +} + +void tst_QJSEngine::constructor() +{ + QBENCHMARK { + QJSEngine engine; + (void)engine.parent(); + } +} + +#if 0 // No defaultPrototype for now +void tst_QJSEngine::defaultPrototype() +{ + newEngine(); + int type = qMetaTypeId(); + m_engine->setDefaultPrototype(type, m_engine->newObject()); + QBENCHMARK { + m_engine->defaultPrototype(type); + } +} + +void tst_QJSEngine::setDefaultPrototype() +{ + newEngine(); + int type = qMetaTypeId(); + QJSValue proto = m_engine->newObject(); + QBENCHMARK { + m_engine->setDefaultPrototype(type, proto); + } +} + +#endif + +void tst_QJSEngine::evaluate_data() +{ + QTest::addColumn("code"); + QTest::newRow("empty script") << QString::fromLatin1(""); + QTest::newRow("number literal") << QString::fromLatin1("123"); + QTest::newRow("string literal") << QString::fromLatin1("'ciao'"); + QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("undefined literal") << QString::fromLatin1("undefined"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("empty object literal") << QString::fromLatin1("{}"); + QTest::newRow("this") << QString::fromLatin1("this"); + QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }"); + QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }"); + QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }"); + QTest::newRow("empty array literal") << QString::fromLatin1("[]"); + QTest::newRow("array literal with one element") << QString::fromLatin1("[1]"); + QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]"); + QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]"); + QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }"); + QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }"); + QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}"); + QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}"); + QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}"); + QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}"); + QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j"); + QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j"); + QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j"); + QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j"); + QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4"); + QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i"); + QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i"); + QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i"); + QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i"); + QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)"); +} + +void tst_QJSEngine::evaluate() +{ + QFETCH(QString, code); + newEngine(); + + QBENCHMARK { + (void)m_engine->evaluate(code); + } +} + +#if 0 +void tst_QJSEngine::connectAndDisconnect() +{ + newEngine(); + QJSValue fun = m_engine->evaluate("(function() { })"); + QBENCHMARK { + qScriptConnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); + qScriptDisconnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); + } +} + +void tst_QJSEngine::evaluateProgram_data() +{ + evaluate_data(); +} + +void tst_QJSEngine::evaluateProgram() +{ + QFETCH(QString, code); + QScriptProgram program(code); + newEngine(); + + QBENCHMARK { + (void)m_engine->evaluate(program); + } +} +#endif + +void tst_QJSEngine::globalObject() +{ + newEngine(); + QBENCHMARK { + m_engine->globalObject(); + } +} + +void tst_QJSEngine::hasUncaughtException() +{ + newEngine(); + QBENCHMARK { + m_engine->hasUncaughtException(); + } +} + +#if 0 +void tst_QJSEngine::isEvaluating() +{ + newEngine(); + QBENCHMARK { + m_engine->isEvaluating(); + } +} +#endif + +void tst_QJSEngine::newArray_data() +{ + QTest::addColumn("size"); + QTest::newRow("size=0") << 0; + QTest::newRow("size=10") << 10; + QTest::newRow("size=100") << 0; + QTest::newRow("size=1000") << 0; + QTest::newRow("size=10000") << 0; + QTest::newRow("size=50000") << 0; +} + +void tst_QJSEngine::newArray() +{ + QFETCH(int, size); + newEngine(); + QBENCHMARK { + m_engine->newArray(size); + } +} + +void tst_QJSEngine::newDate() +{ + newEngine(); + QDateTime dt = QDateTime::currentDateTime(); + QBENCHMARK { + m_engine->newDate(dt); + } +} + +void tst_QJSEngine::newDateFromMs() +{ + newEngine(); + QBENCHMARK { + m_engine->newDate(0); + } +} + +void tst_QJSEngine::newObject() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newObject(); + } +} + +#if 0 +void tst_QJSEngine::newObjectWithScriptClass() +{ + newEngine(); + QScriptClass cls(m_engine); + QBENCHMARK { + m_engine->newObject(&cls); + } +} + +void tst_QJSEngine::newQMetaObject() +{ + newEngine(); + QBENCHMARK { + m_engine->newQMetaObject(&QJSEngine::staticMetaObject); + } +} +#endif + +void tst_QJSEngine::newQObject() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newQObject(QCoreApplication::instance()); + } +} + +#if 0 +static QJSValue testFunction(QScriptContext *, QJSEngine *) +{ + return 0; +} + +void tst_QJSEngine::newFunction() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newFunction(testFunction); + } +} +#endif + +void tst_QJSEngine::newRegExp() +{ + newEngine(); + QRegExp re = QRegExp("foo"); + QBENCHMARK { + m_engine->newRegExp(re); + } +} + +void tst_QJSEngine::newRegExpFromString() +{ + newEngine(); + QString pattern("foo"); + QString flags("gim"); + QBENCHMARK { + m_engine->newRegExp(pattern, flags); + } +} + +void tst_QJSEngine::newVariant() +{ + newEngine(); + QVariant var(123); + QBENCHMARK { + (void)m_engine->newVariant(var); + } +} + +void tst_QJSEngine::nullValue() +{ + newEngine(); + QBENCHMARK { + m_engine->nullValue(); + } +} + +void tst_QJSEngine::undefinedValue() +{ + newEngine(); + QBENCHMARK { + m_engine->undefinedValue(); + } +} + +void tst_QJSEngine::collectGarbage() +{ + newEngine(); + QBENCHMARK { + m_engine->collectGarbage(); + } +} + +#if 0 +void tst_QJSEngine::availableExtensions() +{ + newEngine(); + QBENCHMARK { + m_engine->availableExtensions(); + } +} + +void tst_QJSEngine::importedExtensions() +{ + newEngine(); + QBENCHMARK { + m_engine->importedExtensions(); + } +} + +void tst_QJSEngine::currentContext() +{ + newEngine(); + QBENCHMARK { + m_engine->currentContext(); + } +} + +void tst_QJSEngine::pushAndPopContext() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->pushContext(); + m_engine->popContext(); + } +} +#endif + +void tst_QJSEngine::toObject_data() +{ + newEngine(); + QTest::addColumn("val"); + QTest::newRow("bool") << m_engine->evaluate("true"); + QTest::newRow("number") << m_engine->evaluate("123"); + QTest::newRow("string") << m_engine->evaluate("'ciao'"); + QTest::newRow("null") << m_engine->evaluate("null"); + QTest::newRow("undefined") << m_engine->evaluate("undefined"); + QTest::newRow("object") << m_engine->evaluate("({foo:123})"); + QTest::newRow("array") << m_engine->evaluate("[10,20,30]"); + QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })"); + QTest::newRow("date") << m_engine->evaluate("new Date"); + QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')"); + QTest::newRow("error") << m_engine->evaluate("new Error"); + + QTest::newRow("qobject") << m_engine->newQObject(this); +#if 0 // no QMetaObject + QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject); +#endif + QTest::newRow("variant") << m_engine->newVariant(123); +#if 0 //no classes + QTest::newRow("qscriptclassobject") << m_engine->newObject(new QScriptClass(m_engine)); +#endif + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool-no-engine") << QJSValue(true); + QTest::newRow("number-no-engine") << QJSValue(123.0); + QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello")); + QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue); + QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue); +} + +void tst_QJSEngine::toObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + m_engine->toObject(val); + } +} + +#if 0 +void tst_QJSEngine::toStringHandle() +{ + newEngine(); + QString str = QString::fromLatin1("foobarbaz"); + QBENCHMARK { + (void)m_engine->toStringHandle(str); + } +} +#endif + +void tst_QJSEngine::castValueToQreal() +{ + QJSValue val(123); + QBENCHMARK { + (void)qjsvalue_cast(val); + } +} + +#if 0 +static QJSValue native_function(QScriptContext *, QJSEngine *) +{ + return 42; +} + +void tst_QJSEngine::nativeCall() +{ + newEngine(); + m_engine->globalObject().setProperty("fun", m_engine->newFunction(native_function)); + QBENCHMARK{ +#if !defined(Q_OS_SYMBIAN) + m_engine->evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n" + " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }"); +#else + m_engine->evaluate("var w = 0; for (i = 0; i < 25000; ++i) {\n" + " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }"); +#endif + } +} + +void tst_QJSEngine::installTranslatorFunctions() +{ + newEngine(); + QBENCHMARK { + m_engine->installTranslatorFunctions(); + } +} + +void tst_QJSEngine::translation_data() +{ + QTest::addColumn("text"); + QTest::addColumn("fileName"); + QTest::newRow("no translation") << "\"hello world\"" << ""; + QTest::newRow("qsTr") << "qsTr(\"hello world\")" << ""; + QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")" << ""; + QTest::newRow("qsTr:script.js") << "qsTr(\"hello world\")" << "script.js"; +} + +void tst_QJSEngine::translation() +{ + QFETCH(QString, text); + QFETCH(QString, fileName); + newEngine(); + m_engine->installTranslatorFunctions(); + + QBENCHMARK { + (void)m_engine->evaluate(text, fileName); + } +} +#endif + +#if 0 +void tst_QJSEngine::readScopeProperty_data() +{ + QTest::addColumn("staticScope"); + QTest::addColumn("nestedScope"); + QTest::newRow("single dynamic scope") << false << false; + QTest::newRow("single static scope") << true << false; + QTest::newRow("double dynamic scope") << false << true; + QTest::newRow("double static scope") << true << true; +} + +void tst_QJSEngine::readScopeProperty() +{ + QFETCH(bool, staticScope); + QFETCH(bool, nestedScope); + + newEngine(); + QScriptContext *ctx = m_engine->pushContext(); + + QJSValue scope; + if (staticScope) + scope = QScriptDeclarativeClass::newStaticScopeObject(m_engine); + else + scope = m_engine->newObject(); + scope.setProperty("foo", 123); + ctx->pushScope(scope); + + if (nestedScope) { + QJSValue scope2; + if (staticScope) + scope2 = QScriptDeclarativeClass::newStaticScopeObject(m_engine); + else + scope2 = m_engine->newObject(); + scope2.setProperty("bar", 456); // ensure a miss in inner scope + ctx->pushScope(scope2); + } + + QJSValue fun = m_engine->evaluate("(function() {\n" + " for (var i = 0; i < 10000; ++i) {\n" + " foo; foo; foo; foo; foo; foo; foo; foo;\n" + " }\n" + "})"); + m_engine->popContext(); + QVERIFY(fun.isFunction()); + QBENCHMARK { + fun.call(); + } +} + +void tst_QJSEngine::evaluateInNewContext() +{ + QJSEngine engine; + QBENCHMARK { + engine.pushContext(); + engine.evaluate("var a = 10"); + engine.popContext(); + } +} + +void tst_QJSEngine::evaluateInNewContextWithScope() +{ + QJSEngine engine; + QJSValue scope = engine.newObject(); + scope.setProperty("foo", 123); + QBENCHMARK { + QScriptContext *ctx = engine.pushContext(); + ctx->pushScope(scope); + engine.evaluate("foo"); + engine.popContext(); + } +} + +// Binding expressions in QML are implemented as anonymous functions +// with custom scopes. +void tst_QJSEngine::evaluateBindingExpression() +{ + QJSEngine engine; + QScriptContext *ctx = engine.pushContext(); + QJSValue scope = engine.newObject(); + scope.setProperty("foo", 123); + ctx->pushScope(scope); + QJSValue fun = engine.evaluate("(function() { return foo; })"); + QVERIFY(fun.isFunction()); + engine.popContext(); + QVERIFY(fun.call().equals(scope.property("foo"))); + QJSValue receiver = engine.globalObject(); + QBENCHMARK { + fun.call(receiver); + } +} +#endif + +QTEST_MAIN(tst_QJSEngine) +#include "tst_qjsengine.moc" diff --git a/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro b/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro new file mode 100644 index 0000000000..48c40a2a52 --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qjsvalue + +SOURCES += tst_qjsvalue.cpp + +QT += declarative diff --git a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp new file mode 100644 index 0000000000..afe6d1c4db --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp @@ -0,0 +1,1061 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +Q_DECLARE_METATYPE(QJSValue) + +//TESTED_FILES= + +class tst_QJSValue : public QObject +{ + Q_OBJECT + +public: + tst_QJSValue(); + virtual ~tst_QJSValue(); + +public slots: + void init(); + void cleanup(); + +private slots: + void boolConstructor(); + void floatConstructor(); + void numberConstructor(); + void stringConstructor(); + void nullConstructor(); + void undefinedConstructor(); + void boolConstructorWithEngine(); + void floatConstructorWithEngine(); + void intConstructorWithEngine(); + void stringConstructorWithEngine(); + void nullConstructorWithEngine(); + void undefinedConstructorWithEngine(); + void copyConstructor_data(); + void copyConstructor(); + void call_data(); + void call(); + void construct_data(); + void construct(); +#if 0 // no data + void data(); + void setData(); + void data_noData_data(); + void data_noData(); +#endif + void engine_data(); + void engine(); + void equalsSelf_data(); + void equalsSelf(); +#if 0 // no less then + void lessThanSelf_data(); + void lessThanSelf(); +#endif + void strictlyEqualsSelf_data(); + void strictlyEqualsSelf(); + void instanceOf(); + void isArray_data(); + void isArray(); + void isBool_data(); + void isBool(); + void isDate_data(); + void isDate(); + void isError_data(); + void isError(); + void isFunction_data(); + void isFunction(); + void isNull_data(); + void isNull(); + void isNumber_data(); + void isNumber(); + void isObject_data(); + void isObject(); +#if 0 // no qmetaobject + void isQMetaObject_data(); + void isQMetaObject(); +#endif + void isQObject_data(); + void isQObject(); + void isRegExp_data(); + void isRegExp(); + void isString_data(); + void isString(); + void isUndefined_data(); + void isUndefined(); + void isValid_data(); + void isValid(); + void isVariant_data(); + void isVariant(); + void toBool_data(); + void toBool(); + void toDateTime_data(); + void toDateTime(); + void toInt32_data(); + void toInt32(); + void toInteger_data(); + void toInteger(); + void toNumber_data(); + void toNumber(); + void toRegExp_data(); + void toRegExp(); + void toString_data(); + void toString(); + void toUInt16_data(); + void toUInt16(); + void toUInt32_data(); + void toUInt32(); +#if 0 // no qmetaobject + void toQMetaObject_data(); + void toQMetaObject(); +#endif + void toQObject_data(); + void toQObject(); + void toVariant_data(); + void toVariant(); + void property_data(); + void property(); +#if 0 // no string handle + void propertyById_data(); + void propertyById(); +#endif + void propertyByIndex(); + void setProperty_data(); + void setProperty(); +#if 0 // no string handle + void setPropertyById_data(); + void setPropertyById(); +#endif + void setPropertyByIndex(); +#if 0 // no propertyFlags for now + void propertyFlags_data(); + void propertyFlags(); + void propertyFlagsById_data(); + void propertyFlagsById(); +#endif + void prototype_data(); + void prototype(); + void setPrototype(); +#if 0 // no script class + void scriptClass_data(); + void scriptClass(); + void setScriptClass(); +#endif +#if 0 // no string handle + void readMetaProperty(); + void writeMetaProperty(); +#endif + +private: + void defineStandardTestValues(); + void newEngine() + { + delete m_engine; + m_engine = new QJSEngine; + } + + QJSEngine *m_engine; +}; + +tst_QJSValue::tst_QJSValue() + : m_engine(0) +{ +} + +tst_QJSValue::~tst_QJSValue() +{ + delete m_engine; +} + +void tst_QJSValue::init() +{ +} + +void tst_QJSValue::cleanup() +{ +} + +void tst_QJSValue::boolConstructor() +{ + QBENCHMARK { + QJSValue val(true); + } +} + +void tst_QJSValue::floatConstructor() +{ + QBENCHMARK { + QJSValue val(123.0); + } +} + +void tst_QJSValue::numberConstructor() +{ + QBENCHMARK { + (void)QJSValue(123); + } +} + +void tst_QJSValue::stringConstructor() +{ + QString str = QString::fromLatin1("ciao"); + QBENCHMARK { + (void)QJSValue(str); + } +} + +void tst_QJSValue::nullConstructor() +{ + QBENCHMARK { + QJSValue val(QJSValue::NullValue); + } +} + +void tst_QJSValue::undefinedConstructor() +{ + QBENCHMARK { + QJSValue val(QJSValue::UndefinedValue); + } +} + +void tst_QJSValue::boolConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + QJSValue val(m_engine, true); + } +} + +void tst_QJSValue::floatConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + QJSValue val(m_engine, 123.0); + } +} + +void tst_QJSValue::intConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + (void)QJSValue(m_engine, 123); + } +} + +void tst_QJSValue::stringConstructorWithEngine() +{ + newEngine(); + QString str = QString::fromLatin1("ciao"); + QBENCHMARK { + (void)QJSValue(m_engine, str); + } +} + +void tst_QJSValue::nullConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + QJSValue val(m_engine, QJSValue::NullValue); + } +} + +void tst_QJSValue::undefinedConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + QJSValue val(m_engine, QJSValue::UndefinedValue); + } +} + +void tst_QJSValue::copyConstructor_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::copyConstructor() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + QJSValue copy(val); + } +} + +void tst_QJSValue::call_data() +{ + newEngine(); + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })"); + QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)"); +} + +void tst_QJSValue::call() +{ + QFETCH(QString, code); + QJSValue fun = m_engine->evaluate(code); + QVERIFY(fun.isFunction()); + QBENCHMARK { + (void)fun.call(); + } +} + +void tst_QJSValue::construct_data() +{ + newEngine(); + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })"); +} + +void tst_QJSValue::construct() +{ + QFETCH(QString, code); + QJSValue fun = m_engine->evaluate(code); + QVERIFY(fun.isFunction()); + QBENCHMARK { + (void)fun.construct(); + } +} + +#if 0 +void tst_QJSValue::data() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + obj.setData(QJSValue(m_engine, 123)); + QBENCHMARK { + obj.data(); + } +} + +void tst_QJSValue::setData() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue val(m_engine, 123); + QBENCHMARK { + obj.setData(val); + } +} + +void tst_QJSValue::data_noData_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::data_noData() +{ + QFETCH(QJSValue, val); + QVERIFY(!val.data().isValid()); + QBENCHMARK { + val.data(); + } +} +#endif + +void tst_QJSValue::engine_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::engine() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.engine(); + } +} + +void tst_QJSValue::equalsSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::equalsSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.equals(val); + } +} + +#if 0 +void tst_QJSValue::lessThanSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::lessThanSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.lessThan(val); + } +} +#endif + +void tst_QJSValue::strictlyEqualsSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::strictlyEqualsSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.strictlyEquals(val); + } +} + +void tst_QJSValue::instanceOf() +{ + newEngine(); + QJSValue arrayCtor = m_engine->globalObject().property("Array"); + QJSValue array = arrayCtor.construct(); + QVERIFY(array.instanceOf(arrayCtor)); + QBENCHMARK { + array.instanceOf(arrayCtor); + } +} + +void tst_QJSValue::isArray_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isArray() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isArray(); + } +} + +void tst_QJSValue::isBool_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isBool() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isBool(); + } +} + +void tst_QJSValue::isDate_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isDate() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isDate(); + } +} + +void tst_QJSValue::isError_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isError() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isError(); + } +} + +void tst_QJSValue::isFunction_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isFunction() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isFunction(); + } +} + +void tst_QJSValue::isNull_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isNull() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isNull(); + } +} + +void tst_QJSValue::isNumber_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isNumber() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isNumber(); + } +} + +void tst_QJSValue::isObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isObject(); + } +} + +#if 0 +void tst_QJSValue::isQMetaObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isQMetaObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isQMetaObject(); + } +} +#endif + +void tst_QJSValue::isQObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isQObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isQObject(); + } +} + +void tst_QJSValue::isRegExp_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isRegExp() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isRegExp(); + } +} + +void tst_QJSValue::isString_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isString() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isString(); + } +} + +void tst_QJSValue::isUndefined_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isUndefined() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isUndefined(); + } +} + +void tst_QJSValue::isValid_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isValid() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isValid(); + } +} + +void tst_QJSValue::isVariant_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isVariant() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isVariant(); + } +} + +void tst_QJSValue::toBool_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toBool() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toBool(); + } +} + +void tst_QJSValue::toDateTime_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toDateTime() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toDateTime(); + } +} + +void tst_QJSValue::toInt32_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toInt32() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toInt32(); + } +} + +void tst_QJSValue::toInteger_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toInteger() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toInteger(); + } +} + +void tst_QJSValue::toNumber_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toNumber() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toNumber(); + } +} + +void tst_QJSValue::toRegExp_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toRegExp() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toRegExp(); + } +} + +void tst_QJSValue::toString_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toString() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + (void)val.toString(); + } +} + +#if 0 +void tst_QJSValue::toQMetaObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toQMetaObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toQMetaObject(); + } +} +#endif + +void tst_QJSValue::toQObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toQObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + (void)val.toQObject(); + } +} + +void tst_QJSValue::toUInt16_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toUInt16() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toUInt16(); + } +} + +void tst_QJSValue::toUInt32_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toUInt32() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toUInt32(); + } +} + +void tst_QJSValue::toVariant_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toVariant() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toVariant(); + } +} +void tst_QJSValue::property_data() +{ + QTest::addColumn("propertyName"); + QTest::addColumn("create"); + QTest::newRow("foo") << QString::fromLatin1("foo") << true; + QTest::newRow("hasOwnProperty") << QString::fromLatin1("hasOwnProperty") << false; // From Object.prototype. + QTest::newRow("noSuchProperty") << QString::fromLatin1("noSuchProperty") << false; +} + +void tst_QJSValue::property() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + if (create) + obj.setProperty(propertyName, 123); + QBENCHMARK { + (void)obj.property(propertyName); + } +} + +#if 0 +void tst_QJSValue::propertyById_data() +{ + property_data(); +} + +void tst_QJSValue::propertyById() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + if (create) + obj.setProperty(id, 123); + QBENCHMARK { + obj.property(id); + } +} +#endif + +void tst_QJSValue::propertyByIndex() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + obj.setProperty(123, 456); + QBENCHMARK { + obj.property(123); + } +} + +void tst_QJSValue::setProperty_data() +{ + newEngine(); + QTest::addColumn("propertyName"); + QTest::addColumn("val"); + QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123); + QTest::newRow("bar") << QString::fromLatin1("bar") << QJSValue(m_engine, 123); + QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue(); + QTest::newRow("toString") << QString::fromLatin1("toString") << QJSValue(m_engine, true); +} + +void tst_QJSValue::setProperty() +{ + QFETCH(QString, propertyName); + QFETCH(QJSValue, val); + QJSValue obj = m_engine->newObject(); + QBENCHMARK { + obj.setProperty(propertyName, val); + } +} + +#if 0 +void tst_QJSValue::setPropertyById_data() +{ + setProperty_data(); +} + +void tst_QJSValue::setPropertyById() +{ + QFETCH(QString, propertyName); + QFETCH(QJSValue, val); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + QBENCHMARK { + obj.setProperty(id, val); + } +} +#endif + +void tst_QJSValue::setPropertyByIndex() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue val(456); + QBENCHMARK { + obj.setProperty(123, 456); + } +} + +#if 0 +void tst_QJSValue::propertyFlags_data() +{ + property_data(); +} + +void tst_QJSValue::propertyFlags() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + if (create) + obj.setProperty(propertyName, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); + QBENCHMARK { + (void)obj.propertyFlags(propertyName); + } +} + +void tst_QJSValue::propertyFlagsById_data() +{ + propertyFlags_data(); +} + +void tst_QJSValue::propertyFlagsById() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + if (create) + obj.setProperty(id, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); + QBENCHMARK { + obj.propertyFlags(id); + } +} +#endif + +void tst_QJSValue::prototype_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::prototype() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.prototype(); + } +} + +void tst_QJSValue::setPrototype() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue proto = m_engine->newObject(); + QBENCHMARK { + obj.setPrototype(proto); + } +} + +#if 0 +void tst_QJSValue::scriptClass_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::scriptClass() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.scriptClass(); + } +} + +void tst_QJSValue::setScriptClass() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSClass cls(m_engine); + QBENCHMARK { + obj.setScriptClass(&cls); + } +} + +void tst_QJSValue::readMetaProperty() +{ + newEngine(); + QJSValue object = m_engine->newQObject(QCoreApplication::instance()); + QJSString propertyName = m_engine->toStringHandle("objectName"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + object.property(propertyName); + } +} + +void tst_QJSValue::writeMetaProperty() +{ + newEngine(); + QJSValue object = m_engine->newQObject(QCoreApplication::instance()); + QJSString propertyName = m_engine->toStringHandle("objectName"); + QJSValue value(m_engine, "foo"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + object.setProperty(propertyName, value); + } +} +#endif + +void tst_QJSValue::defineStandardTestValues() +{ + newEngine(); + QTest::addColumn("val"); + QTest::newRow("bool") << m_engine->evaluate("true"); + QTest::newRow("number") << m_engine->evaluate("123"); + QTest::newRow("string") << m_engine->evaluate("'ciao'"); + QTest::newRow("null") << m_engine->evaluate("null"); + QTest::newRow("undefined") << m_engine->evaluate("undefined"); + QTest::newRow("object") << m_engine->evaluate("({foo:123})"); + QTest::newRow("array") << m_engine->evaluate("[10,20,30]"); + QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })"); + QTest::newRow("date") << m_engine->evaluate("new Date"); + QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')"); + QTest::newRow("error") << m_engine->evaluate("new Error"); + + QTest::newRow("qobject") << m_engine->newQObject(this); +#if 0 // no qmetaobject + QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject); +#endif + QTest::newRow("variant") << m_engine->newVariant(123); +#if 0 // no classess + QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine)); +#endif + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool-no-engine") << QJSValue(true); + QTest::newRow("number-no-engine") << QJSValue(123.0); + QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello")); + QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue); + QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue); +} + +QTEST_MAIN(tst_QJSValue) +#include "tst_qjsvalue.moc" diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro b/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro new file mode 100644 index 0000000000..a114b863f6 --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qjsvalueiterator + +SOURCES += tst_qjsvalueiterator.cpp + +QT = core declarative diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp new file mode 100644 index 0000000000..8b4921cf8e --- /dev/null +++ b/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +//TESTED_FILES= + +class tst_QJSValueIterator : public QObject +{ + Q_OBJECT + +public: + tst_QJSValueIterator(); + virtual ~tst_QJSValueIterator(); + + void dataHelper(); + +private slots: + void init(); + void cleanup(); + + void hasNextAndNext(); + + void constructAndNext_data(); + void constructAndNext(); + + void name_data(); + void name(); +#if 0 // No string handle + void scriptName_data(); + void scriptName(); +#endif + + void value_data(); + void value(); +#if 0 // no setValue + void setValue_data(); + void setValue(); +#endif +#if 0 // no flags + void flags(); +#endif + +#if 0 // no array index + void iterateArrayAndConvertNameToIndex(); +#endif +#if 0 // no setValue + void iterateArrayAndDoubleElements(); +#endif +#if 0 // no remove + void iterateArrayAndRemoveAllElements(); +#endif +}; + +tst_QJSValueIterator::tst_QJSValueIterator() +{ +} + +tst_QJSValueIterator::~tst_QJSValueIterator() +{ +} + +void tst_QJSValueIterator::init() +{ +} + +void tst_QJSValueIterator::cleanup() +{ +} + +void tst_QJSValueIterator::dataHelper() +{ + QTest::addColumn("code"); + QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })"); + QTest::newRow("Math") << QString::fromLatin1("Math"); + QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype"); + QTest::newRow("Global Object") << QString::fromLatin1("this"); + QTest::newRow("['foo']") << QString::fromLatin1("['foo']"); + QTest::newRow("array with 1000 elements") + << QString::fromLatin1("(function() {" + " var a = new Array;" + " for (i = 0; i < 1000; ++i)" + " a[i] = i;" + " return a;" + "})()"); +} + +void tst_QJSValueIterator::hasNextAndNext() +{ + QJSEngine engine; + QJSValue object = engine.newObject(); + for (int i = 0; i < 2000; ++i) + object.setProperty(i, i); + QBENCHMARK { + for (int i = 0; i < 1000; ++i) { + QJSValueIterator it(object); + while (it.hasNext()) + it.next(); + } + } +} + +void tst_QJSValueIterator::constructAndNext_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::constructAndNext() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QBENCHMARK { + for (int i = 0; i < 100; ++i) { + QJSValueIterator it(object); + it.next(); + } + } +} + +void tst_QJSValueIterator::name_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::name() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 200000; ++i) + it.name(); + } +} + +#if 0 +void tst_QJSValueIterator::scriptName_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::scriptName() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.scriptName(); + } +} +#endif + +void tst_QJSValueIterator::value_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::value() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.value(); + } +} + +#if 0 +void tst_QJSValueIterator::setValue_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::setValue() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QJSValue newValue(&engine, 456); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.setValue(newValue); + } +} + +void tst_QJSValueIterator::flags() +{ + QJSEngine engine; + QJSValue object = engine.newObject(); + QJSValue::PropertyFlags flags = flags; + object.setProperty("foo", 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly | QJSValue::Undeletable); + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.flags(); + } +} +#endif + +#if 0 +void tst_QJSValueIterator::iterateArrayAndConvertNameToIndex() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.scriptName().toArrayIndex(); + } + } +} + +void tst_QJSValueIterator::iterateArrayAndDoubleElements() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.setValue(QJSValue(&engine, it.value().toNumber() * 2)); + } + } +} + +void tst_QJSValueIterator::iterateArrayAndRemoveAllElements() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.remove(); + } + } +} +#endif + +QTEST_MAIN(tst_QJSValueIterator) +#include "tst_qjsvalueiterator.moc" -- cgit v1.2.3 From cc01e0b1e112aac3a0e515f7accbd05ca5a55ecd Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 8 Aug 2011 15:00:29 +1000 Subject: Allow borderimage .sci source to be a quoted filename Previously, attempting to set the source property of a border image via a .sci file to a quoted filename would fail. This commit adds support for quoted source filenames. Task-number: QTBUG-20709 Change-Id: Ida54ef42bc07081457fd945bb279f3cc82c26e10 Reviewed-on: http://codereview.qt.nokia.com/2724 Reviewed-by: Qt Sanity Bot Reviewed-by: Damian Jansen Reviewed-by: Michael Brasser --- tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci | 7 +++++++ tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp | 2 ++ .../qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci | 7 +++++++ .../qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp | 2 ++ 4 files changed, 18 insertions(+) create mode 100644 tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci create mode 100644 tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci (limited to 'tests') diff --git a/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci b/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci new file mode 100644 index 0000000000..294f3cfe48 --- /dev/null +++ b/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:"colors.png" diff --git a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp index 75cc6a0b4a..d1fe084df2 100644 --- a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp +++ b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp @@ -324,8 +324,10 @@ void tst_qsgborderimage::sciSource_data() QTest::addColumn("valid"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; } diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci new file mode 100644 index 0000000000..294f3cfe48 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:"colors.png" diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index d5631469a5..9ef2aaeb56 100644 --- a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -333,8 +333,10 @@ void tst_qdeclarativeborderimage::sciSource_data() QTest::addColumn("valid"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; } -- cgit v1.2.3 From 74f3a67fe80fecf7ba2fd76e1758b6c0f68ce918 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 16 Aug 2011 11:48:14 +1000 Subject: Add attached properties to the positioners. Added an attached property type to the base positioner class. This allows items within a positioner (Row, Column, Grid, Flow) to determine their index inside the positioner, as well as whether they are the first or last items. Non-visible items are ignored, as in the positioner layout objects themselves. It may be useful to expand this in the future to contain more information specific to the positioner, for example row/column for Grid. Task-number: QTBUG-19211 Change-Id: I10a8c9ca5528dd12811125cae8a9b4d2e3747972 Reviewed-on: http://codereview.qt.nokia.com/2983 Reviewed-by: Qt Sanity Bot Reviewed-by: Alan Alpert --- .../data/attachedproperties-column.qml | 50 +++++++++ .../data/attachedproperties-dynamic.qml | 44 ++++++++ .../data/attachedproperties-flow.qml | 50 +++++++++ .../data/attachedproperties-grid.qml | 50 +++++++++ .../qsgpositioners/data/attachedproperties-row.qml | 50 +++++++++ .../qsgpositioners/data/rectangleComponent.qml | 11 ++ .../qsgpositioners/tst_qsgpositioners.cpp | 114 +++++++++++++++++++++ 7 files changed, 369 insertions(+) create mode 100644 tests/auto/declarative/qsgpositioners/data/attachedproperties-column.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/attachedproperties-dynamic.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/attachedproperties-flow.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/attachedproperties-grid.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/attachedproperties-row.qml create mode 100644 tests/auto/declarative/qsgpositioners/data/rectangleComponent.qml (limited to 'tests') diff --git a/tests/auto/declarative/qsgpositioners/data/attachedproperties-column.qml b/tests/auto/declarative/qsgpositioners/data/attachedproperties-column.qml new file mode 100644 index 0000000000..4c667aa205 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/attachedproperties-column.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 200 + + Column { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/attachedproperties-dynamic.qml b/tests/auto/declarative/qsgpositioners/data/attachedproperties-dynamic.qml new file mode 100644 index 0000000000..894749dc16 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/attachedproperties-dynamic.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Rectangle +{ + width: 300 + height: 100 + + Row { + id: pos + objectName: "pos" + anchors.fill: parent + + Rectangle { + objectName: "rect0" + width: 100 + height: 100 + color: 'red' + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem + } + + Rectangle { + objectName: "rect1" + width: 100 + height: 100 + color: 'green' + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem + } + + property QtObject subRect; + + function createSubRect() { + var component = Qt.createComponent("rectangleComponent.qml"); + subRect = component.createObject(pos, {}); + } + + function destroySubRect() { + subRect.destroy(); + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/attachedproperties-flow.qml b/tests/auto/declarative/qsgpositioners/data/attachedproperties-flow.qml new file mode 100644 index 0000000000..e7f9a63e2a --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/attachedproperties-flow.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Flow { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/attachedproperties-grid.qml b/tests/auto/declarative/qsgpositioners/data/attachedproperties-grid.qml new file mode 100644 index 0000000000..2094309b9f --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/attachedproperties-grid.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Grid { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/attachedproperties-row.qml b/tests/auto/declarative/qsgpositioners/data/attachedproperties-row.qml new file mode 100644 index 0000000000..212a26b431 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/attachedproperties-row.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Row { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/declarative/qsgpositioners/data/rectangleComponent.qml b/tests/auto/declarative/qsgpositioners/data/rectangleComponent.qml new file mode 100644 index 0000000000..de1bb99593 --- /dev/null +++ b/tests/auto/declarative/qsgpositioners/data/rectangleComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0; + +Rectangle { + objectName: "rect2" + color: "blue" + width: 100 + height: 100 + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem +} diff --git a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp index 497f511335..137e6acd77 100644 --- a/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp +++ b/tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp @@ -91,6 +91,10 @@ private slots: void test_conflictinganchors(); void test_mirroring(); void test_allInvisible(); + void test_attachedproperties(); + void test_attachedproperties_data(); + void test_attachedproperties_dynamic(); + private: QSGView *createView(const QString &filename); }; @@ -1345,6 +1349,116 @@ void tst_qsgpositioners::test_allInvisible() QVERIFY(column->height() == 0); } +void tst_qsgpositioners::test_attachedproperties() +{ + QFETCH(QString, filename); + + QSGView *canvas = createView(filename); + QVERIFY(canvas->rootObject() != 0); + + QSGRectangle *greenRect = canvas->rootObject()->findChild("greenRect"); + QVERIFY(greenRect != 0); + + int posIndex = greenRect->property("posIndex").toInt(); + QVERIFY(posIndex == 0); + bool isFirst = greenRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == true); + bool isLast = greenRect->property("isLastItem").toBool(); + QVERIFY(isLast == false); + + QSGRectangle *yellowRect = canvas->rootObject()->findChild("yellowRect"); + QVERIFY(yellowRect != 0); + + posIndex = yellowRect->property("posIndex").toInt(); + QVERIFY(posIndex == -1); + isFirst = yellowRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == false); + isLast = yellowRect->property("isLastItem").toBool(); + QVERIFY(isLast == false); + + yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner"); + + posIndex = yellowRect->property("posIndex").toInt(); + QVERIFY(posIndex == 1); + isFirst = yellowRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == false); + isLast = yellowRect->property("isLastItem").toBool(); + QVERIFY(isLast == true); + + delete canvas; +} + +void tst_qsgpositioners::test_attachedproperties_data() +{ + QTest::addColumn("filename"); + + QTest::newRow("column") << SRCDIR "/data/attachedproperties-column.qml"; + QTest::newRow("row") << SRCDIR "/data/attachedproperties-row.qml"; + QTest::newRow("grid") << SRCDIR "/data/attachedproperties-grid.qml"; + QTest::newRow("flow") << SRCDIR "/data/attachedproperties-flow.qml"; +} + +void tst_qsgpositioners::test_attachedproperties_dynamic() +{ + QSGView *canvas = createView(SRCDIR "/data/attachedproperties-dynamic.qml"); + QVERIFY(canvas->rootObject() != 0); + + QSGRow *row = canvas->rootObject()->findChild("pos"); + QVERIFY(row != 0); + + QSGRectangle *rect0 = canvas->rootObject()->findChild("rect0"); + QVERIFY(rect0 != 0); + + int posIndex = rect0->property("index").toInt(); + QVERIFY(posIndex == 0); + bool isFirst = rect0->property("firstItem").toBool(); + QVERIFY(isFirst == true); + bool isLast = rect0->property("lastItem").toBool(); + QVERIFY(isLast == false); + + QSGRectangle *rect1 = canvas->rootObject()->findChild("rect1"); + QVERIFY(rect1 != 0); + + posIndex = rect1->property("index").toInt(); + QVERIFY(posIndex == 1); + isFirst = rect1->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect1->property("lastItem").toBool(); + QVERIFY(isLast == true); + + row->metaObject()->invokeMethod(row, "createSubRect"); + + posIndex = rect1->property("index").toInt(); + QVERIFY(posIndex == 1); + isFirst = rect1->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect1->property("lastItem").toBool(); + QVERIFY(isLast == false); + + QSGRectangle *rect2 = canvas->rootObject()->findChild("rect2"); + QVERIFY(rect2 != 0); + + posIndex = rect2->property("index").toInt(); + QVERIFY(posIndex == 2); + isFirst = rect2->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect2->property("lastItem").toBool(); + QVERIFY(isLast == true); + + row->metaObject()->invokeMethod(row, "destroySubRect"); + + qApp->processEvents(QEventLoop::DeferredDeletion); + + posIndex = rect1->property("index").toInt(); + QVERIFY(posIndex == 1); + isFirst = rect1->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect1->property("lastItem").toBool(); + QVERIFY(isLast == true); + + delete canvas; +} + QSGView *tst_qsgpositioners::createView(const QString &filename) { QSGView *canvas = new QSGView(0); -- cgit v1.2.3 From 36767e3fe1f0038441ae06ef5b5e1cb19a3738fa Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 3 Aug 2011 09:20:18 +1000 Subject: Make QColor a value type This commit allows direct access to the r, g, b and a components of a color (in floating point format: 0 <= v <= 1). Since conversion from color to string is a common operation, this commit also adds unit tests to ensure that the previous behaviour is maintained in other cases (comparison with toString value, etc). Task-number: QTBUG-14731 Change-Id: I87b521dd4f9c1e96dfe5b20cf8053293cb14cfe4 Reviewed-on: http://codereview.qt.nokia.com/2527 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- .../qdeclarativevaluetypes/data/color_compare.qml | 37 ++++++++++++ .../qdeclarativevaluetypes/data/color_read.qml | 9 +++ .../qdeclarativevaluetypes/data/color_write.qml | 8 +++ .../declarative/qdeclarativevaluetypes/testtypes.h | 10 ++++ .../tst_qdeclarativevaluetypes.cpp | 68 ++++++++++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml new file mode 100644 index 0000000000..8701dae612 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml @@ -0,0 +1,37 @@ +import Test 1.0 + +MyTypeObject { + property real v_r: color.r + property real v_g: color.g + property real v_b: color.b + property real v_a: color.a + property variant copy: color + property string colorToString: color.toString() + + // compare different colors + property bool colorEqualsIdenticalRgba: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true + property bool colorEqualsDifferentAlpha: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44)) // false + property bool colorEqualsDifferentRgba: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44)) // false + + // compare different color.toString()s + property bool colorToStringEqualsColorString: (color.toString() == colorToString) // true + property bool colorToStringEqualsDifferentAlphaString: (color.toString() == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // true + property bool colorToStringEqualsDifferentRgbaString: (color.toString() == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false + + // compare colors to strings + property bool colorEqualsColorString: (color == colorToString) // false + property bool colorEqualsDifferentAlphaString: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // false + property bool colorEqualsDifferentRgbaString: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false + + // compare colors to various value types + property bool equalsColor: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true + property bool equalsVector3d: (color == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (color == Qt.size(1912, 1913)) // false + property bool equalsPoint: (color == Qt.point(10, 4)) // false + property bool equalsRect: (color == Qt.rect(2, 3, 109, 102)) // false + + // ensure comparison directionality doesn't matter + property bool equalsColorRHS: (Qt.rgba(0.2, 0.88, 0.6, 0.34) == color) // true + property bool colorEqualsCopy: (color == copy) // true + property bool copyEqualsColor: (copy == color) // true +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml new file mode 100644 index 0000000000..bc92b1e5f9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property real v_r: color.r + property real v_g: color.g + property real v_b: color.b + property real v_a: color.a + property variant copy: color +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml new file mode 100644 index 0000000000..3f1bad4aa6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + color.r: if (true) 0.5 + color.g: if (true) 0.38 + color.b: if (true) 0.3 + color.a: if (true) 0.7 +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 1efab0c423..5eb6bf6b6d 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ class MyTypeObject : public QObject Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed) Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed) Q_PROPERTY(QVariant variant READ variant NOTIFY changed) public: @@ -109,6 +111,10 @@ public: m_font.setCapitalization(QFont::AllLowercase); m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2); m_font.setWordSpacing(19.7); + m_color.setRedF(0.2); + m_color.setGreenF(0.88); + m_color.setBlueF(0.6); + m_color.setAlphaF(0.34); } QPoint m_point; @@ -171,6 +177,10 @@ public: QFont font() const { return m_font; } void setFont(const QFont &v) { m_font = v; emit changed(); } + QColor m_color; + QColor color() const { return m_color; } + void setColor(const QColor &v) { m_color = v; emit changed(); } + QVariant variant() const { return sizef(); } void emitRunScript() { emit runScript(); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 5869310ef6..89d0e7e357 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -77,6 +77,7 @@ private slots: void quaternion(); void matrix4x4(); void font(); + void color(); void variant(); void bindingAssignment(); @@ -807,6 +808,73 @@ void tst_qdeclarativevaluetypes::font() } } +void tst_qdeclarativevaluetypes::color() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("color_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2); + QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88); + QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6); + QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34); + QColor comparison; + comparison.setRedF(0.2); + comparison.setGreenF(0.88); + comparison.setBlueF(0.6); + comparison.setAlphaF(0.34); + QCOMPARE(object->property("copy"), QVariant(comparison)); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("color_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QColor newColor; + newColor.setRedF(0.5); + newColor.setGreenF(0.38); + newColor.setBlueF(0.3); + newColor.setAlphaF(0.7); + QCOMPARE(object->color(), newColor); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("color_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QString colorString("#33e199"); + QCOMPARE(object->property("colorToString").toString(), colorString); + QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true); + QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false); + QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false); + QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true); + QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true); + QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false); + QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0 + QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0 + QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false); + + QCOMPARE(object->property("equalsColor").toBool(), true); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + + // Color == Property and Property == Color should return the same result. + QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool()); + QCOMPARE(object->property("colorEqualsCopy").toBool(), true); + QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool()); + + delete object; + } +} + // Test bindings can write to value types void tst_qdeclarativevaluetypes::bindingAssignment() { -- cgit v1.2.3 From eaf52673ef38b4d7a14f9fb9f258d8f1c6097401 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 14 Jul 2011 15:40:30 +1000 Subject: Add support for a vector4d type in QML QVector4D is a value-type which is supported but was not able to be constructed using a Qt object function. This commit allows properties of vector4d type to be constructed, and adds a function to the global Qt object and adds unit tests to ensure that it behaves correctly. Task-number: QTBUG-18559 Change-Id: I96509a4f496b644d20fdb1d977d0afe430d89e13 Reviewed-on: http://codereview.qt.nokia.com/1626 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- .../tst_qdeclarativeinstruction.cpp | 19 +++++++++++++++++++ .../qdeclarativelanguage/data/assignBasicTypes.qml | 1 + .../data/assignLiteralToVariant.qml | 1 + .../declarative/qdeclarativelanguage/testtypes.h | 10 ++++++++++ .../tst_qdeclarativelanguage.cpp | 3 +++ .../declarative/qdeclarativeqt/data/vector4.qml | 8 ++++++++ .../qdeclarativeqt/tst_qdeclarativeqt.cpp | 21 +++++++++++++++++++++ 7 files changed, 63 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeqt/data/vector4.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index e6e87d1bbd..f432cbff49 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -63,6 +63,7 @@ private slots: void rect(); void rectf(); void vector3d(); + void vector4d(); void time(); }; @@ -682,6 +683,24 @@ void tst_qdeclarativeinstruction::vector3d() QCOMPARE(vector.z(), (qreal)(float)12.0); } +void tst_qdeclarativeinstruction::vector4d() +{ + QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D)); + QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D)); + + QDeclarativeInstruction i; + i.storeVector4D.vector.xp = 8.2; + i.storeVector4D.vector.yp = 99.3; + i.storeVector4D.vector.zp = 12.0; + i.storeVector4D.vector.wp = 121.1; + + const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector); + QCOMPARE(vector.x(), (qreal)(float)8.2); + QCOMPARE(vector.y(), (qreal)(float)99.3); + QCOMPARE(vector.z(), (qreal)(float)12.0); + QCOMPARE(vector.w(), (qreal)(float)121.1); +} + void tst_qdeclarativeinstruction::time() { QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeTime::QTime), sizeof(QTime)); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml index 9fe0ded459..2313499d19 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml @@ -21,6 +21,7 @@ MyTypeObject { boolProperty: true variantProperty: "Hello World!" vectorProperty: "10,1,2.2" + vector4Property: "10,1,2.2,2.3" urlProperty: "main.qml" objectProperty: MyTypeObject { intProperty: 8 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml index de476ae47f..f6f9a139dc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -12,5 +12,6 @@ QtObject { property variant test9: String("#FF008800") property variant test10: true property variant test11: false + property variant test12: "100,100,100,100" } diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index c11bc33eab..dad0e23ae3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -224,6 +225,7 @@ class MyTypeObject : public QObject Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property) Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) @@ -442,6 +444,14 @@ public: vectorPropertyValue = v; } + QVector4D vector4PropertyValue; + QVector4D vector4Property() const { + return vector4PropertyValue; + } + void setVector4Property(const QVector4D &v) { + vector4PropertyValue = v; + } + QUrl urlPropertyValue; QUrl urlProperty() const { return urlPropertyValue; diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index dfaf3d1618..5e9bc418cc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -564,6 +564,7 @@ void tst_qdeclarativelanguage::assignBasicTypes() QCOMPARE(object->boolProperty(), true); QCOMPARE(object->variantProperty(), QVariant("Hello World!")); QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3)); QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); QVERIFY(object->objectProperty() != 0); MyTypeObject *child = qobject_cast(object->objectProperty()); @@ -610,6 +611,7 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QCOMPARE(object->property("test9").userType(), (int)QVariant::String); QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); QVERIFY(object->property("test1") == QVariant(1)); QVERIFY(object->property("test2") == QVariant((double)1.7)); @@ -622,6 +624,7 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); QVERIFY(object->property("test10") == QVariant(bool(true))); QVERIFY(object->property("test11") == QVariant(bool(false))); + QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); delete object; } diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector4.qml b/tests/auto/declarative/qdeclarativeqt/data/vector4.qml new file mode 100644 index 0000000000..554dd1e9d4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/vector4.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.vector4d(1, 0, 0.9, 0.6); + property variant test2: Qt.vector4d(102, -10, -982.1, 10); + property variant test3: Qt.vector4d(102, -10, -982.1); + property variant test4: Qt.vector4d(102, -10, -982.1, 10, 15); +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 4a9bb4513c..d9cd2b8fdf 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -72,6 +72,7 @@ private slots: void point(); void size(); void vector(); + void vector4d(); void lighter(); void darker(); void tint(); @@ -243,6 +244,26 @@ void tst_qdeclarativeqt::vector() delete object; } +void tst_qdeclarativeqt::vector4d() +{ + QDeclarativeComponent component(&engine, TEST_FILE("vector4.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QVector4D(1, 0, 0.9, 0.6)); + QCOMPARE(qvariant_cast(object->property("test2")), QVector4D(102, -10, -982.1, 10)); + QCOMPARE(qvariant_cast(object->property("test3")), QVector4D()); + QCOMPARE(qvariant_cast(object->property("test4")), QVector4D()); + + delete object; +} + void tst_qdeclarativeqt::lighter() { QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); -- cgit v1.2.3 From 08e37a16c202364b0b919653f3a17979388cac27 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 18 Aug 2011 10:25:38 +0200 Subject: Don't skip autotest and export needed symbol Change-Id: Ib5090348cefa955caa54c5e4fff8cb961ddb8e52 Reviewed-on: http://codereview.qt.nokia.com/3147 Reviewed-by: Kim M. Kalland Reviewed-by: Qt Sanity Bot --- tests/auto/declarative/nodes/tst_nodestest.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/nodes/tst_nodestest.cpp b/tests/auto/declarative/nodes/tst_nodestest.cpp index 1d825fbd34..6b1fa85a4a 100644 --- a/tests/auto/declarative/nodes/tst_nodestest.cpp +++ b/tests/auto/declarative/nodes/tst_nodestest.cpp @@ -220,8 +220,6 @@ void NodesTest::simulatedEffect_data() void NodesTest::simulatedEffect() { - QSKIP("QTBUG-20029", SkipAll); - QFETCH(bool, connected); QSGRootNode root; -- cgit v1.2.3 From e636770970e979d4111ca90eca926c5eea2e7ce0 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Aug 2011 12:28:35 +1000 Subject: Fix tst_qdeclarativestates autotest. Update test after changes to Column. Task-number: QTBUG-21002 Change-Id: I12671207cd07ba375f9c90cc02fdc9f81f189678 Reviewed-on: http://codereview.qt.nokia.com/3236 Reviewed-by: Qt Sanity Bot Reviewed-by: Alan Alpert --- .../qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 1 - .../qdeclarativestates/data/anchorRewindBug.qml | 2 +- .../qdeclarativestates/tst_qdeclarativestates.cpp | 15 +++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 191a96f81d..c39766e22d 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -404,7 +404,6 @@ void tst_qdeclarativebehaviors::sameValue() QCOMPARE(target->x(), qreal(100)); target->setProperty("x", 0); - qDebug() << "x" << target->x(); QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml index 6512533b37..60c537b1ed 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml @@ -31,7 +31,7 @@ Rectangle { } PropertyChanges { target: rectangle - opacity: 0 + visible: false } } } diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index a59ca2607f..e13a6c4305 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ #include #include #include +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -953,10 +955,11 @@ void tst_qdeclarativestates::anchorChangesCrash() // QTBUG-12273 void tst_qdeclarativestates::anchorRewindBug() { - QDeclarativeEngine engine; + QSGView *view = new QSGView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchorRewindBug.qml")); + qApp->processEvents(); - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); - QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(view->rootObject()); QVERIFY(rect != 0); QSGItem * column = rect->findChild("column"); @@ -971,7 +974,7 @@ void tst_qdeclarativestates::anchorRewindBug() // and column's implicit resizing should still work QVERIFY(!QSGItemPrivate::get(column)->heightValid); QVERIFY(!QSGItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 100.0); + QTRY_COMPARE(column->height(), 100.0); QSGItemPrivate::get(rect)->setState(""); @@ -979,9 +982,9 @@ void tst_qdeclarativestates::anchorRewindBug() // and column's implicit resizing should still work QVERIFY(!QSGItemPrivate::get(column)->heightValid); QVERIFY(!QSGItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 200.0); + QTRY_COMPARE(column->height(), 200.0); - delete rect; + delete view; } // QTBUG-11834 -- cgit v1.2.3 From 9506823a68cda1214ecf305e78f4f27cc764afa6 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 19 Aug 2011 13:13:26 +1000 Subject: Fix unit test failure Previously had hardcoded tostring comparison value for QFont, but on some platforms the default styleHint may be different. This commit ensures that the comparison value is generated properly rather than hardcoded. Task-number: QTBUG-21003 Change-Id: I49229863b10bf5fb96248b9334b66d7b1ef46676 Reviewed-on: http://codereview.qt.nokia.com/3237 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- .../declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 89d0e7e357..3ccd5cb341 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -794,7 +794,7 @@ void tst_qdeclarativevaluetypes::font() MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); - QString tostring = QLatin1String("QFont(Arial,29,-1,0,63,1,1,1,0,0)"); + QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')'); QCOMPARE(object->property("tostring").toString(), tostring); QCOMPARE(object->property("equalsString").toBool(), true); QCOMPARE(object->property("equalsColor").toBool(), false); -- cgit v1.2.3 From 1cc58fdf174656a52603af00cb40478066c5abd4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 1 Jun 2011 09:45:55 +0200 Subject: Make QSGTextNode back-end for QML's TextInput and TextEdit Use the general QSGTextNode class as back-end for all text elements in QML to make all text elements look the same and use the same text rasterization back-end. This requires a few rewrites in the text node to support e.g. selections. Crashes seen with threaded renderer in TextEdit and TextInput on Mac are also fixed by this. Reviewed-by: Jiang Jiang Task-number: QTBUG-18019, QTBUG-20017 Change-Id: I4207faf180c83422e5f8b726741321af395bd724 Reviewed-on: http://codereview.qt.nokia.com/2865 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/declarative/qsgtext/tst_qsgtext.cpp | 37 +++++++- .../declarative/qsgtextedit/tst_qsgtextedit.cpp | 62 ++++++++++++-- .../declarative/qsgtextinput/data/positionAt.qml | 2 +- .../declarative/qsgtextinput/tst_qsgtextinput.cpp | 99 ++++++++++++++++++++-- 4 files changed, 185 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp index 48d679bfa7..747ea51f41 100644 --- a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp +++ b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,8 @@ #define SRCDIR "." #endif +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) + class tst_qsgtext : public QObject { @@ -261,14 +264,42 @@ void tst_qsgtext::width() delete textObject; } + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + for (int i = 0; i < standard.size(); i++) { QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = qCeil(metricWidth); + qreal metricWidth = 0.0; + + if (requiresUnhintedMetrics) { + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + metricWidth = qCeil(layout.boundingRect().width()); + } else { + QFontMetricsF fm(f); + qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); + metricWidth = qCeil(metricWidth); + } QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); diff --git a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp index 3492ac2138..2a94e20d3f 100644 --- a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp +++ b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ #endif Q_DECLARE_METATYPE(QSGTextEdit::SelectionMode) +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { @@ -280,12 +282,40 @@ void tst_qsgtextedit::width() QCOMPARE(textEditObject->width(), 0.0); } + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + for (int i = 0; i < standard.size(); i++) { QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = ceil(metricWidth); + qreal metricWidth = 0.0; + + if (requiresUnhintedMetrics) { + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + metricWidth = ceil(layout.boundingRect().width()); + } else { + QFontMetricsF fm(f); + metricWidth = fm.size(Qt::TextExpandTabs | Qt::TextShowMnemonic, standard.at(i)).width(); + metricWidth = ceil(metricWidth); + } QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); @@ -301,6 +331,8 @@ void tst_qsgtextedit::width() QTextDocument document; document.setHtml(richText.at(i)); document.setDocumentMargin(0); + if (requiresUnhintedMetrics) + document.setUseDesignMetrics(true); int documentWidth = ceil(document.idealWidth()); @@ -455,7 +487,6 @@ void tst_qsgtextedit::hAlign() void tst_qsgtextedit::hAlign_RightToLeft() { - QSKIP("QTBUG-20017", SkipAll); QSGView canvas(QUrl::fromLocalFile(SRCDIR "/data/horizontalAlignment_RightToLeft.qml")); QSGTextEdit *textEdit = canvas.rootObject()->findChild("text"); QVERIFY(textEdit != 0); @@ -1471,7 +1502,28 @@ void tst_qsgtextedit::positionAt() const int y1 = fm.height() * 3 / 2; int pos = texteditObject->positionAt(texteditObject->width()/2, y0); - int diff = abs(int(fm.width(texteditObject->text().left(pos))-texteditObject->width()/2)); + int width = 0; + if (!qmlDisableDistanceField()) { + QTextLayout layout(texteditObject->text().left(pos)); + + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + width = ceil(line.horizontalAdvance()); + + } else { + width = fm.width(texteditObject->text().left(pos)); + } + + + int diff = abs(int(width-texteditObject->width()/2)); // some tollerance for different fonts. #ifdef Q_OS_LINUX diff --git a/tests/auto/declarative/qsgtextinput/data/positionAt.qml b/tests/auto/declarative/qsgtextinput/data/positionAt.qml index 7611376e13..1840462c87 100644 --- a/tests/auto/declarative/qsgtextinput/data/positionAt.qml +++ b/tests/auto/declarative/qsgtextinput/data/positionAt.qml @@ -4,5 +4,5 @@ TextInput{ focus: true objectName: "myInput" width: 50 - text: "This is a long piece of text" + text: "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" } diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp index 93e8ad21fd..744717cd80 100644 --- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp +++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp @@ -51,7 +51,9 @@ #include #include #include +#include #include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -59,6 +61,7 @@ #endif Q_DECLARE_METATYPE(QSGTextInput::SelectionMode) +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { @@ -221,11 +224,38 @@ void tst_qsgtextinput::width() delete textinputObject; } + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + for (int i = 0; i < standard.size(); i++) { QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.width(standard.at(i)); + qreal metricWidth = 0.0; + if (requiresUnhintedMetrics) { + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + metricWidth = ceil(layout.boundingRect().width()); + } else { + QFontMetricsF fm(f); + metricWidth = fm.width(standard.at(i)); + } QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textinputComponent(&engine); @@ -1048,7 +1078,6 @@ void tst_qsgtextinput::horizontalAlignment() void tst_qsgtextinput::horizontalAlignment_RightToLeft() { - QSKIP("QTBUG-20017", SkipAll); QSGView canvas(QUrl::fromLocalFile(SRCDIR "/data/horizontalAlignment_RightToLeft.qml")); QSGTextInput *textInput = canvas.rootObject()->findChild("text"); QVERIFY(textInput != 0); @@ -1161,7 +1190,45 @@ void tst_qsgtextinput::positionAt() QFontMetrics fm(textinputObject->font()); int pos = textinputObject->positionAt(textinputObject->width()/2); - int diff = abs(int(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2))); + int textWidth = 0; + int textLeftWidth = 0; + if (!qmlDisableDistanceField()) { + { + QTextLayout layout(textinputObject->text().left(pos)); + + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + textLeftWidth = ceil(line.horizontalAdvance()); + } + { + QTextLayout layout(textinputObject->text()); + + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + textWidth = ceil(line.horizontalAdvance()); + } + } else { + textWidth = fm.width(textinputObject->text()); + textLeftWidth = fm.width(textinputObject->text().left(pos)); + } + + int diff = abs(textWidth - (textLeftWidth+textinputObject->width()/2)); // some tollerance for different fonts. #ifdef Q_OS_LINUX @@ -1177,7 +1244,28 @@ void tst_qsgtextinput::positionAt() // Check without autoscroll... textinputObject->setAutoScroll(false); pos = textinputObject->positionAt(textinputObject->width()/2); - diff = abs(int(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2)); + + if (!qmlDisableDistanceField()) { + { + QTextLayout layout(textinputObject->text().left(pos)); + + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + textLeftWidth = ceil(line.horizontalAdvance()); + } + } else { + textLeftWidth = fm.width(textinputObject->text().left(pos)); + } + + diff = abs(int(textLeftWidth-textinputObject->width()/2)); // some tollerance for different fonts. #ifdef Q_OS_LINUX @@ -1442,7 +1530,6 @@ void tst_qsgtextinput::navigation() void tst_qsgtextinput::navigation_RTL() { - QSKIP("QTBUG-20017", SkipAll); QSGView canvas(QUrl::fromLocalFile(SRCDIR "/data/navigation.qml")); canvas.show(); canvas.setFocus(); -- cgit v1.2.3 From e5166af2e4856668ea45d31e0d6fb044dc9ab1af Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 22 Aug 2011 09:25:30 +1000 Subject: tests: acknowledge all known failures in declarative autotests This change XFAILs or CONFIG+=insignificant_tests all known failures in declarative autotests, and links them to bug reports. Note that the changes were only applied to qpa builds, although it is possible some of these failures affect other platforms too. Task-number: QTBUG-20990 Task-number: QTBUG-21000 Task-number: QTBUG-21001 Task-number: QTBUG-21004 Task-number: QTBUG-21005 Task-number: QTBUG-21007 Task-number: QTBUG-21008 Task-number: QTBUG-21009 Task-number: QTBUG-21010 Task-number: QTBUG-21011 Task-number: QTBUG-21012 Task-number: QTBUG-21013 Task-number: QTBUG-21015 Task-number: QTBUG-21016 Task-number: QTBUG-21017 Change-Id: Ieb89aa38e48e9e5162d87483d6441749865f234d Reviewed-on: http://codereview.qt.nokia.com/3239 Reviewed-by: Qt Sanity Bot Reviewed-by: Keith Isdale --- tests/auto/declarative/examples/examples.pro | 2 ++ tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp | 3 +++ tests/auto/declarative/qsgborderimage/qsgborderimage.pro | 2 ++ tests/auto/declarative/qsgimage/tst_qsgimage.cpp | 6 ++++++ tests/auto/declarative/qsglistview/tst_qsglistview.cpp | 3 +++ tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp | 6 ++++++ tests/auto/declarative/qsgtext/tst_qsgtext.cpp | 3 +++ tests/auto/declarative/qsgtextedit/qsgtextedit.pro | 2 ++ tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp | 7 +++++++ .../qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 3 +++ .../auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro | 1 + .../qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro | 1 + tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro | 1 + tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp | 3 +++ .../qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 3 +++ .../qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 9 +++++++++ 16 files changed, 55 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 8c3c030692..d1593960de 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -19,3 +19,5 @@ symbian: { CONFIG += parallel_test QT += core-private gui-private declarative-private qtquick1-private + +qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp index 9f9e066003..4eef465ddd 100644 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp @@ -3705,6 +3705,9 @@ void tst_QJSValue::castToPointer() QJSValue v = eng.newVariant(int(123)); int *ip = qjsvalue_cast(v); QVERIFY(ip != 0); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21000 fails", Abort); +#endif QCOMPARE(*ip, 123); QEXPECT_FAIL("", "Pointer magic for variants is currently not supported by QJSEngine", Abort); *ip = 456; diff --git a/tests/auto/declarative/qsgborderimage/qsgborderimage.pro b/tests/auto/declarative/qsgborderimage/qsgborderimage.pro index db7fe77e1d..7b0c1d5560 100644 --- a/tests/auto/declarative/qsgborderimage/qsgborderimage.pro +++ b/tests/auto/declarative/qsgborderimage/qsgborderimage.pro @@ -16,3 +16,5 @@ symbian: { CONFIG += parallel_test QT += core-private gui-private declarative-private + +qpa:CONFIG+=insignificant_test # QTBUG-21004 fails, unstably diff --git a/tests/auto/declarative/qsgimage/tst_qsgimage.cpp b/tests/auto/declarative/qsgimage/tst_qsgimage.cpp index 5ac8c217ed..948f36cdb2 100644 --- a/tests/auto/declarative/qsgimage/tst_qsgimage.cpp +++ b/tests/auto/declarative/qsgimage/tst_qsgimage.cpp @@ -343,6 +343,9 @@ void tst_qsgimage::mirror() } QImage img = expected.toImage(); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21005 fails", Continue); +#endif QCOMPARE(screenshots[fillMode], img); } } @@ -469,6 +472,9 @@ void tst_qsgimage::tiling_QTBUG_6716() QImage img = canvas->grabFrameBuffer(); for (int x = 0; x < tiling->width(); ++x) { for (int y = 0; y < tiling->height(); ++y) { +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21005 fails", Abort); +#endif QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); } } diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index e1e6edd53d..0cd10f6046 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -1147,6 +1147,9 @@ void tst_QSGListView::enforceRange_withoutHighlight() expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section QTest::keyClick(canvas, Qt::Key_Down); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21007 fails", Abort); +#endif QTRY_COMPARE(listview->contentY(), expectedPos); expectedPos += 20; // scroll past 1st item of 2nd section diff --git a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp index 6e731d1682..420eda9aca 100644 --- a/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp +++ b/tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp @@ -781,6 +781,9 @@ void tst_QSGMouseArea::hoverPosition() QMouseEvent moveEvent(QEvent::MouseMove, QPoint(10, 32), Qt::NoButton, Qt::NoButton, 0); QApplication::sendEvent(canvas, &moveEvent); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21008 fails", Abort); +#endif QCOMPARE(root->property("mouseX").toReal(), qreal(10)); QCOMPARE(root->property("mouseY").toReal(), qreal(32)); @@ -801,6 +804,9 @@ void tst_QSGMouseArea::hoverPropagation() QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0); QApplication::sendEvent(canvas, &moveEvent); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21008 fails", Abort); +#endif QCOMPARE(root->property("point1").toBool(), true); QCOMPARE(root->property("point2").toBool(), false); diff --git a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp index 747ea51f41..d972378a65 100644 --- a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp +++ b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp @@ -1355,6 +1355,9 @@ void tst_qsgtext::lineHeight() qreal h = myText->height(); myText->setLineHeight(1.5); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21009 fails", Continue); +#endif QVERIFY(myText->height() == h * 1.5); myText->setLineHeightMode(QSGText::FixedHeight); diff --git a/tests/auto/declarative/qsgtextedit/qsgtextedit.pro b/tests/auto/declarative/qsgtextedit/qsgtextedit.pro index fea4b71369..491bb2d3f3 100644 --- a/tests/auto/declarative/qsgtextedit/qsgtextedit.pro +++ b/tests/auto/declarative/qsgtextedit/qsgtextedit.pro @@ -14,3 +14,5 @@ symbian: { } QT += core-private gui-private declarative-private QT += opengl-private + +qpa:CONFIG+=insignificant_test # QTBUG-21010, fails unstably diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp index 744717cd80..9761180fec 100644 --- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp +++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp @@ -1267,6 +1267,10 @@ void tst_qsgtextinput::positionAt() diff = abs(int(textLeftWidth-textinputObject->width()/2)); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21011 fails", Continue); +#endif + // some tollerance for different fonts. #ifdef Q_OS_LINUX QVERIFY(diff < 2); @@ -2309,6 +2313,9 @@ void tst_qsgtextinput::preeditAutoScroll() // test the text is scrolled so the preedit is visible. ic.sendPreeditText(preeditText.mid(0, 3), 1); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21011 fails", Abort); +#endif QVERIFY(input->positionAt(0) != 0); QVERIFY(input->cursorRectangle().left() < input->boundingRect().width()); QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 773fc24148..68efbe1b3f 100644 --- a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -401,6 +401,9 @@ void tst_qdeclarativebehaviors::sameValue() QCOMPARE(target->x(), qreal(100)); target->setProperty("x", 0); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21001 fails", Abort); +#endif QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. diff --git a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro index 64d5d0a518..22d015c798 100644 --- a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro @@ -15,3 +15,4 @@ symbian: { CONFIG += parallel_test QT += core-private gui-private declarative-private qtquick1-private +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific) diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro index f532585b89..5e943d73fe 100644 --- a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -12,3 +12,4 @@ symbian: { } QT += core-private gui-private declarative-private qtquick1-private +qpa:CONFIG+=insignificant_test # QTBUG-21013 unstable diff --git a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro index 0b87e3c9e7..459f80bec2 100644 --- a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro @@ -15,3 +15,4 @@ symbian: { CONFIG += parallel_test QT += core-private gui-private declarative-private qtquick1-private +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific) diff --git a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp index d6984cb98a..8398ec6061 100644 --- a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp @@ -1329,6 +1329,9 @@ void tst_qdeclarativetext::lineHeight() qreal h = myText->height(); myText->setLineHeight(1.5); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21015 fails", Continue); +#endif QVERIFY(myText->height() == h * 1.5); myText->setLineHeightMode(QDeclarative1Text::FixedHeight); diff --git a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 94378e96c3..76f4687e2e 100644 --- a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1617,6 +1617,9 @@ void tst_qdeclarativetextedit::positionAt() int pos = texteditObject->positionAt(texteditObject->width()/2, y0); int diff = abs(int(fm.width(texteditObject->text().left(pos))-texteditObject->width()/2)); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21016 fails", Continue); +#endif // some tollerance for different fonts. #ifdef Q_OS_LINUX QVERIFY(diff < 2); diff --git a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 7cc79c7878..2d86a4b038 100644 --- a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -1324,6 +1324,9 @@ void tst_qdeclarativetextinput::positionAt() pos = textinputObject->positionAt(textinputObject->width()/2); diff = abs(int(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2)); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21017 fails", Continue); +#endif // some tollerance for different fonts. #ifdef Q_OS_LINUX QVERIFY(diff < 2); @@ -2336,6 +2339,9 @@ void tst_qdeclarativetextinput::setHAlignClearCache() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21017 fails", Abort); +#endif QTRY_COMPARE(input.nbPaint, 1); input.setHAlign(QDeclarative1TextInput::AlignRight); QApplication::processEvents(); @@ -2444,6 +2450,9 @@ void tst_qdeclarativetextinput::preeditAutoScroll() // test the text is scrolled so the preedit is visible. ic.sendPreeditText(preeditText.mid(0, 3), 1); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21017 fails", Abort); +#endif QVERIFY(input.positionAt(0) != 0); QVERIFY(input.cursorRectangle().left() < input.boundingRect().width()); QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); -- cgit v1.2.3 From c0184fcbbd85787734cde6d481001b0cbfd4fc82 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 22 Aug 2011 16:11:31 +1000 Subject: test: marked tst_qdeclarativebehaviors as expected failure This was supposed to be marked in e5166af2e4856668ea45d31e0d6fb044dc9ab1af, but was accidentally omitted (note that there are two autotests named tst_qdeclarativebehaviors). Task-number: QTBUG-21001 Change-Id: I0afeccff776a448e24d76f51cd9b761774067311 Reviewed-on: http://codereview.qt.nokia.com/3288 Reviewed-by: Qt Sanity Bot Reviewed-by: Damian Jansen --- .../declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index c39766e22d..15248e301d 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -404,6 +404,9 @@ void tst_qdeclarativebehaviors::sameValue() QCOMPARE(target->x(), qreal(100)); target->setProperty("x", 0); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21001 fails", Abort); +#endif QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. -- cgit v1.2.3 From 419aa6ec6d066f99830f1066edc08985748fbf2b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 23 Aug 2011 09:57:58 +1000 Subject: test: marked tst_qsgfocusscope as insignificant This autotest is unstable. Task-number: QTBUG-21054 Change-Id: Ifeea19a842ccca9b086117345c889b8d6d0cc295 Reviewed-on: http://codereview.qt.nokia.com/3342 Reviewed-by: Qt Sanity Bot Reviewed-by: Damian Jansen --- tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro b/tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro index b5d1815e11..375b497e3f 100644 --- a/tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro +++ b/tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro @@ -12,3 +12,5 @@ symbian: { } QT += core-private gui-private declarative-private + +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21054, unstable -- cgit v1.2.3 From 6a35e8a13900665ab77a0caed59de1df3e89aa6c Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 23 Aug 2011 10:33:58 +1000 Subject: test: marked expected failure in tst_qsgtextinput Part of this test was already marked as an expected failure. Now it fails in a different place. Task-number: QTBUG-21011 Change-Id: I15ce8be882b361fda8351900eb768acec01a7bac Reviewed-on: http://codereview.qt.nokia.com/3343 Reviewed-by: Qt Sanity Bot Reviewed-by: Damian Jansen --- tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp index 9761180fec..3cc0dc196b 100644 --- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp +++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp @@ -1230,6 +1230,10 @@ void tst_qsgtextinput::positionAt() int diff = abs(textWidth - (textLeftWidth+textinputObject->width()/2)); +#ifdef Q_WS_QPA + QEXPECT_FAIL("", "QTBUG-21011 fails", Continue); +#endif + // some tollerance for different fonts. #ifdef Q_OS_LINUX QVERIFY(diff < 2); -- cgit v1.2.3 From b18974cb3d448696c985c7d3a965dcf9523a4e9e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 24 Aug 2011 10:41:06 +1000 Subject: test: marked tst_examples as insignificant_test on x11 This test sometimes segfaults. Task-number: QTBUG-21078 Change-Id: I3636063457fd78099fd471a1175bc2151ae178cc Reviewed-on: http://codereview.qt.nokia.com/3426 Reviewed-by: Qt Sanity Bot Reviewed-by: Toby Tomkins --- tests/auto/declarative/examples/examples.pro | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index d1593960de..f41e9e7fa0 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -21,3 +21,4 @@ CONFIG += parallel_test QT += core-private gui-private declarative-private qtquick1-private qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts +x11:CONFIG+=insignificant_test # QTBUG-21078, unstably crashes -- cgit v1.2.3 From 0d572fc7d251691a34fe5b99c60868835409047e Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Tue, 23 Aug 2011 19:04:16 -0300 Subject: Do not deliver mouse wheel events when item is not visible This patch change the code to also skip invisible items (it was done for disabled already) when deciding whether or not deliver the wheel event to an item. The rationale here is to follow the same rule as the other mouse events. An autotest was added to verify and maintain this behavior. Change-Id: If0fe6d64d1f7cfb8679ce11edda7c02dc3783f94 Reviewed-on: http://codereview.qt.nokia.com/3429 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- tests/auto/declarative/qsgitem/tst_qsgitem.cpp | 49 +++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp index e591ab8c86..7799fef9de 100644 --- a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp +++ b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp @@ -52,16 +52,18 @@ class TestItem : public QSGItem { Q_OBJECT public: - TestItem(QSGItem *parent = 0) : QSGItem(parent), focused(false), pressCount(0), releaseCount(0) {} + TestItem(QSGItem *parent = 0) : QSGItem(parent), focused(false), pressCount(0), releaseCount(0), wheelCount(0) {} bool focused; int pressCount; int releaseCount; + int wheelCount; protected: virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) { event->accept(); ++pressCount; } virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { event->accept(); ++releaseCount; } + virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; } }; class TestPolishItem : public QSGItem @@ -123,6 +125,9 @@ private slots: void mouseGrab(); void polishOutsideAnimation(); + void wheelEvent_data(); + void wheelEvent(); + private: void ensureFocus(QWidget *w) { w->show(); @@ -845,6 +850,48 @@ void tst_qsgitem::polishOutsideAnimation() delete canvas; } +void tst_qsgitem::wheelEvent_data() +{ + QTest::addColumn("visible"); + QTest::addColumn("enabled"); + + QTest::newRow("visible and enabled") << true << true; + QTest::newRow("visible and disabled") << true << false; + QTest::newRow("invisible and enabled") << false << true; + QTest::newRow("invisible and disabled") << false << false; +} + +void tst_qsgitem::wheelEvent() +{ + QFETCH(bool, visible); + QFETCH(bool, enabled); + + const bool shouldReceiveWheelEvents = visible && enabled; + + QSGCanvas *canvas = new QSGCanvas; + canvas->resize(200, 200); + canvas->show(); + + TestItem *item = new TestItem; + item->setSize(QSizeF(200, 100)); + item->setParentItem(canvas->rootItem()); + + item->setEnabled(enabled); + item->setVisible(visible); + + QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); + event.setAccepted(false); + QApplication::sendEvent(canvas, &event); + + if (shouldReceiveWheelEvents) { + QVERIFY(event.isAccepted()); + QCOMPARE(item->wheelCount, 1); + } else { + QVERIFY(!event.isAccepted()); + QCOMPARE(item->wheelCount, 0); + } +} + QTEST_MAIN(tst_qsgitem) #include "tst_qsgitem.moc" -- cgit v1.2.3 From 537c30a772afa0715d912011192dafec9f7e5a14 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 24 Aug 2011 14:55:59 +1000 Subject: reenable tst_examples A potential culprit has been disabled pending investigation, testing may proceed as normal. Change-Id: I471d768e033b1e3fea1714983056ca4631baabd8 Reviewed-on: http://codereview.qt.nokia.com/3444 Reviewed-by: Qt Sanity Bot Reviewed-by: Charles Yin --- tests/auto/declarative/examples/examples.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index f41e9e7fa0..d1593960de 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -21,4 +21,3 @@ CONFIG += parallel_test QT += core-private gui-private declarative-private qtquick1-private qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts -x11:CONFIG+=insignificant_test # QTBUG-21078, unstably crashes -- cgit v1.2.3 From e6c0633a9c386817017a97dac9e541a45f42fd7f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 22 Aug 2011 13:15:52 +0200 Subject: Fix tst_qjsvalue::castToPointer test failure In order for casting the variant's data() to work, we need to get at the actual QVariant wrapped in the JS object; copying the variant caused a stale pointer to be returned. Task-number: QTBUG-21000 Change-Id: I1a32a70d5a043c94dbbd07ef2c8048e7df7fc7bf Reviewed-on: http://codereview.qt.nokia.com/3309 Reviewed-by: Qt Sanity Bot Reviewed-by: Simon Hausmann --- tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp index 4eef465ddd..24330c9f2e 100644 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp @@ -3705,11 +3705,7 @@ void tst_QJSValue::castToPointer() QJSValue v = eng.newVariant(int(123)); int *ip = qjsvalue_cast(v); QVERIFY(ip != 0); -#ifdef Q_WS_QPA - QEXPECT_FAIL("", "QTBUG-21000 fails", Abort); -#endif QCOMPARE(*ip, 123); - QEXPECT_FAIL("", "Pointer magic for variants is currently not supported by QJSEngine", Abort); *ip = 456; QCOMPARE(qjsvalue_cast(v), 456); -- cgit v1.2.3 From 71f6f5625d3675fa166c81799bc6872d6cb95700 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 24 Aug 2011 20:45:41 -0300 Subject: Fix leak in tst_qsgitem::wheelEvent() autotest Change-Id: If0fe6d64d1f7cfb8679ce11edda7c02dc3783f95 Reviewed-on: http://codereview.qt.nokia.com/3539 Reviewed-by: Qt Sanity Bot Reviewed-by: Alan Alpert --- tests/auto/declarative/qsgitem/tst_qsgitem.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp index 7799fef9de..7a612c433b 100644 --- a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp +++ b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp @@ -890,6 +890,8 @@ void tst_qsgitem::wheelEvent() QVERIFY(!event.isAccepted()); QCOMPARE(item->wheelCount, 0); } + + delete canvas; } QTEST_MAIN(tst_qsgitem) -- cgit v1.2.3 From 0d84e957297b4ffa6ab5b0b5bcf8b169d567d298 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 25 Aug 2011 14:14:25 +1000 Subject: qsgflickable test is unstable Ensure that the flickable animation finishes before flicking in the other axis is initiated. Task-number: QTBUG-21096 Change-Id: I97bdbc539d9b5af999c0c3d186c35a75a029194d Reviewed-on: http://codereview.qt.nokia.com/3553 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp index fe96453140..4dbff74c56 100644 --- a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp +++ b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp @@ -460,7 +460,8 @@ void tst_qsgflickable::movingAndDragging() QCOMPARE(dragStartSpy.count(), 1); QCOMPARE(dragEndSpy.count(), 1); - // Don't test moving because a flick could occur + // wait for any motion to end + QTRY_VERIFY(flickable->isMoving() == false); //Horizontal vDragSpy.clear(); -- cgit v1.2.3