aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-08-25 11:47:24 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-08-25 12:52:15 +0200
commit8e6ecb56e5d61ce661422779c9d9cbf22f081a34 (patch)
tree227aeb360800a49de58472bd39bc5f4c596c1b15 /tests
parentc9224b6cf5cceb7d5314f7504d44bfe72bc66950 (diff)
parent0d84e957297b4ffa6ab5b0b5bcf8b169d567d298 (diff)
Merge branch 'master' into refactor
Conflicts: src/declarative/items/qsgcanvas.cpp src/declarative/items/qsgitem.cpp src/declarative/items/qsgtextnode.cpp tests/auto/declarative/examples/examples.pro tools/qmlviewer/qmlviewer.pro Change-Id: Icbb0ef5dc79b658c62fd2b2c25a66c9bb3cbeb10
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/examples/examples.pro2
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp6
-rw-r--r--tests/auto/declarative/nodes/tst_nodestest.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp27
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml24
-rw-r--r--tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp17
-rw-r--r--tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp1007
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml17
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml31
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml26
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml18
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml72
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp132
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp19
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h10
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml8
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/vector4.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp21
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml2
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml37
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml9
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml8
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml31
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml35
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml22
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml22
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml25
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml25
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml24
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml21
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h28
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp297
-rw-r--r--tests/auto/declarative/qjsengine/tst_qjsengine.cpp57
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp1
-rw-r--r--tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci7
-rw-r--r--tests/auto/declarative/qsgborderimage/qsgborderimage.pro2
-rw-r--r--tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp2
-rw-r--r--tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp3
-rw-r--r--tests/auto/declarative/qsgfocusscope/qsgfocusscope.pro2
-rw-r--r--tests/auto/declarative/qsggridview/data/gridview-initCurrent.qml13
-rw-r--r--tests/auto/declarative/qsggridview/data/gridview1.qml1
-rw-r--r--tests/auto/declarative/qsggridview/tst_qsggridview.cpp36
-rw-r--r--tests/auto/declarative/qsgimage/tst_qsgimage.cpp6
-rw-r--r--tests/auto/declarative/qsgitem/tst_qsgitem.cpp51
-rw-r--r--tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml61
-rw-r--r--tests/auto/declarative/qsglistview/data/listview-initCurrent.qml13
-rw-r--r--tests/auto/declarative/qsglistview/tst_qsglistview.cpp128
-rw-r--r--tests/auto/declarative/qsgmousearea/data/hoverPropagation.qml54
-rw-r--r--tests/auto/declarative/qsgmousearea/data/pressedCanceled.qml18
-rw-r--r--tests/auto/declarative/qsgmousearea/tst_qsgmousearea.cpp77
-rw-r--r--tests/auto/declarative/qsgpathview/data/pathview0.qml1
-rw-r--r--tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp60
-rw-r--r--tests/auto/declarative/qsgpositioners/data/attachedproperties-column.qml50
-rw-r--r--tests/auto/declarative/qsgpositioners/data/attachedproperties-dynamic.qml44
-rw-r--r--tests/auto/declarative/qsgpositioners/data/attachedproperties-flow.qml50
-rw-r--r--tests/auto/declarative/qsgpositioners/data/attachedproperties-grid.qml50
-rw-r--r--tests/auto/declarative/qsgpositioners/data/attachedproperties-row.qml50
-rw-r--r--tests/auto/declarative/qsgpositioners/data/grid-row-column-spacing.qml43
-rw-r--r--tests/auto/declarative/qsgpositioners/data/horizontal-animated-disabled.qml40
-rw-r--r--tests/auto/declarative/qsgpositioners/data/horizontal-animated.qml3
-rw-r--r--tests/auto/declarative/qsgpositioners/data/rectangleComponent.qml11
-rw-r--r--tests/auto/declarative/qsgpositioners/tst_qsgpositioners.cpp189
-rw-r--r--tests/auto/declarative/qsgtext/tst_qsgtext.cpp40
-rw-r--r--tests/auto/declarative/qsgtextedit/qsgtextedit.pro2
-rw-r--r--tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp62
-rw-r--r--tests/auto/declarative/qsgtextinput/data/positionAt.qml2
-rw-r--r--tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp110
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml2
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml2
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml2
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml2
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml2
-rw-r--r--tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp1
-rw-r--r--tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp3
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp3
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp17
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci7
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp2
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro1
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro1
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro1
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp3
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp3
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp9
-rw-r--r--tests/benchmarks/declarative/declarative.pro3
-rw-r--r--tests/benchmarks/declarative/js/js.pro10
-rw-r--r--tests/benchmarks/declarative/js/qjsengine/qjsengine.pro12
-rw-r--r--tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp677
-rw-r--r--tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro7
-rw-r--r--tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp1061
-rw-r--r--tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp311
-rw-r--r--tests/systemtests/declarative/qsgimage/ImageNG.qml41
-rw-r--r--tests/systemtests/declarative/qsgimage/img-align.qml41
115 files changed, 5367 insertions, 497 deletions
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index 6748d7518b..297559ef97 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 widgets-private
+
+qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 5368a0eda4..e2edc3e93c 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/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;
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<QSGRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QSGRectangle *myRect = rect->findChild<QSGRectangle*>("TheRect");
+ QVERIFY(myRect);
+
+ QDeclarativeTransition *trans = rect->findChild<QDeclarativeTransition*>();
+ 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/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 191a96f81d..15248e301d 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -404,7 +404,9 @@ void tst_qdeclarativebehaviors::sameValue()
QCOMPARE(target->x(), qreal(100));
target->setProperty("x", 0);
- qDebug() << "x" << target->x();
+#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/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<QSGRectangle*>(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/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<Signal> SignalList;
@@ -100,16 +99,24 @@ public:
QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
{
+ QHash<int, QVector<int> > removedValues;
QVector<int> alteredList = list;
foreach (const Signal &signal, changes) {
if (signal.isInsert()) {
- alteredList.insert(signal.start, signal.end - signal.start, 100);
+ if (signal.moveId != -1) {
+ QVector<int> 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<SignalList>("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<int> list;
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/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<Rectangle> listProperty: [ Rectangle { width: 10; height: 10 } ]
+ property list<Rectangle> 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..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();
@@ -113,6 +114,7 @@ private slots:
void dynamicCreation();
void dynamicDestruction();
void objectToString();
+ void objectHasOwnProperty();
void selfDeletingBinding();
void extendedObjectPropertyLookup();
void scriptErrors();
@@ -1037,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<QDeclarativeComponent*>() != 0);
+ QCOMPARE(object->property("aliasIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAliased");
+ QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 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<QDeclarativeComponent*>() != 0);
+ QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 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<QDeclarativeComponent*>() != 0);
+ QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false));
+ QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 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<QDeclarativeComponent*>() != 0);
+ QObject *loader = object->findChild<QObject*>("loader");
+ QVERIFY(loader != 0);
+ delete loader;
+ QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // deletion should have caused value unset.
+ QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash.
+ QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 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<QDeclarativeComponent*>() == 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<QDeclarativeComponent*>() == 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<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QCOMPARE(object->property("intAlias").value<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ delete object;
+}
+
void tst_qdeclarativeecmascript::dynamicCreation_data()
{
QTest::addColumn<QString>("method");
@@ -1141,6 +1224,55 @@ void tst_qdeclarativeecmascript::objectToString()
}
/*
+ 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<bool>() == true);
+ QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
+ QVERIFY(object->property("result").value<bool>() == false);
+
+ // now test other types in QML
+ QObject *child = object->findChild<QObject*>("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.
This test is best run under valgrind to ensure no invalid memory access occur.
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/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
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 <QtGui/qmatrix.h>
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeparserstatus.h>
@@ -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<MyTypeObject *>(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/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"
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
+}
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<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
+
+ delete object;
+}
+
void tst_qdeclarativeqt::lighter()
{
QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
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 <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qsgview.h>
#include <private/qsgstateoperations_p.h>
#include <private/qsganchors_p_p.h>
#include <private/qsgrectangle_p.h>
@@ -49,6 +50,7 @@
#include <private/qdeclarativestategroup_p.h>
#include <private/qsgitem_p.h>
#include <private/qdeclarativeproperty_p.h>
+#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<QSGRectangle*>(rectComponent.create());
+ QSGRectangle *rect = qobject_cast<QSGRectangle*>(view->rootObject());
QVERIFY(rect != 0);
QSGItem * column = rect->findChild<QSGItem*>("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
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/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..5eb6bf6b6d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
@@ -54,6 +54,7 @@
#include <QQuaternion>
#include <QMatrix4x4>
#include <QFont>
+#include <QColor>
#include <qdeclarative.h>
#include <QDeclarativePropertyValueSource>
#include <QDeclarativeProperty>
@@ -65,27 +66,34 @@ 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)
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:
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),
@@ -103,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;
@@ -113,6 +125,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 +137,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 +149,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(); }
@@ -153,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 aa4c014d99..3ccd5cb341 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();
@@ -134,6 +135,26 @@ void tst_qdeclarativevaluetypes::point()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("point_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +180,26 @@ void tst_qdeclarativevaluetypes::pointf()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("pointf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +225,26 @@ void tst_qdeclarativevaluetypes::size()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("size_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +270,26 @@ void tst_qdeclarativevaluetypes::sizef()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizef_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +374,26 @@ void tst_qdeclarativevaluetypes::rect()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rect_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +421,26 @@ void tst_qdeclarativevaluetypes::rectf()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rectf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +466,24 @@ void tst_qdeclarativevaluetypes::vector2d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector2d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +510,25 @@ void tst_qdeclarativevaluetypes::vector3d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector3d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +556,24 @@ void tst_qdeclarativevaluetypes::vector4d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector4d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +601,24 @@ void tst_qdeclarativevaluetypes::quaternion()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("quaternion_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +665,24 @@ void tst_qdeclarativevaluetypes::matrix4x4()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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 +788,91 @@ void tst_qdeclarativevaluetypes::font()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 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);
+ 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::color()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("color_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(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<MyTypeObject *>(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<MyTypeObject *>(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
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
index 49febdbf5e..d2f4b3b6ac 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <qjsengine.h>
+#include <qjsvalueiterator.h>
#include <qgraphicsitem.h>
#include <qstandarditemmodel.h>
#include <QtCore/qnumeric.h>
@@ -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
@@ -203,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();
@@ -1560,11 +1557,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<QString> expectedNames;
expectedNames
@@ -1598,10 +1594,6 @@ void tst_QJSEngine::globalObjectProperties_enumerate()
<< "unescape"
<< "SyntaxError"
<< "undefined"
- // non-standard
- << "gc"
- << "version"
- << "print"
// JavaScriptCore
<< "JSON"
// V8
@@ -1609,7 +1601,7 @@ void tst_QJSEngine::globalObjectProperties_enumerate()
;
QSet<QString> actualNames;
{
- QScriptValueIterator it(global);
+ QJSValueIterator it(global);
while (it.hasNext()) {
it.next();
actualNames.insert(it.name());
@@ -1627,7 +1619,6 @@ void tst_QJSEngine::globalObjectProperties_enumerate()
}
QVERIFY(remainingNames.isEmpty());
}
-#endif
void tst_QJSEngine::createGlobalObjectProperty()
{
@@ -3330,7 +3321,7 @@ void tst_QJSEngine::disableProcessEventsInterval()
}
#endif
-#if 0 // ###FIXME: No QScriptValueIterator API
+
void tst_QJSEngine::stacktrace()
{
QString script = QString::fromLatin1(
@@ -3358,34 +3349,36 @@ void tst_QJSEngine::stacktrace()
<< "foo(0)@testfile:3"
<< "<global>()@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();
@@ -3401,10 +3394,11 @@ void tst_QJSEngine::stacktrace()
--counter;
}
- {
- QScriptValue bt = result.property("backtrace").call(result);
- QCOMPARE(qscriptvalue_cast<QStringList>(bt), backtrace);
- }
+// FIXME? it is not standard.
+// {
+// QJSValue bt = result.property("backtrace").call(result);
+// QCOMPARE(qjsvalue_cast<QStringList>(bt), backtrace);
+// }
// throw something that isn't an Error object
eng.clearExceptions();
@@ -3423,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());
@@ -3435,7 +3429,6 @@ void tst_QJSEngine::stacktrace()
QVERIFY(!eng.hasUncaughtException());
// ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty());
}
-#endif
void tst_QJSEngine::numberParsing_data()
{
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
index 4a785a92b0..91485e48d8 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
@@ -3706,7 +3706,6 @@ void tst_QJSValue::castToPointer()
int *ip = qjsvalue_cast<int*>(v);
QVERIFY(ip != 0);
QCOMPARE(*ip, 123);
- QEXPECT_FAIL("", "Pointer magic for variants is currently not supported by QJSEngine", Abort);
*ip = 456;
QCOMPARE(qjsvalue_cast<int>(v), 456);
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/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/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<bool>("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/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();
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
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/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 e7dce4c86d..49c3080a1c 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<QSGItem>(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<QSGText>(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")
@@ -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);
@@ -1344,7 +1366,7 @@ void tst_QSGGridView::modelChanges()
QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
gridView->setModel(modelVariant);
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/qsgitem/tst_qsgitem.cpp b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp
index e591ab8c86..7a612c433b 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,50 @@ void tst_qsgitem::polishOutsideAnimation()
delete canvas;
}
+void tst_qsgitem::wheelEvent_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("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);
+ }
+
+ delete canvas;
+}
+
QTEST_MAIN(tst_qsgitem)
#include "tst_qsgitem.moc"
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..1db1096499
--- /dev/null
+++ b/tests/auto/declarative/qsglistview/data/listview-enforcerange-nohighlight.qml
@@ -0,0 +1,61 @@
+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
+ focus: true
+
+ 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/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 48a10ca669..94d6cf3d45 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();
@@ -120,6 +121,7 @@ private slots:
void sizeLessThan1();
void QTBUG_14821();
void resizeDelegate();
+ void resizeFirstDelegate();
void QTBUG_16037();
void indexAt();
void incrementalModel();
@@ -1113,6 +1115,54 @@ 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<QSGListView>(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);
+#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
+ 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();
@@ -1431,6 +1481,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);
@@ -1441,6 +1511,8 @@ void tst_QSGListView::currentIndex()
QTRY_VERIFY(canvas->hasFocus());
qApp->processEvents();
+ listview->setCurrentIndex(0);
+
QTest::keyClick(canvas, Qt::Key_Down);
QCOMPARE(listview->currentIndex(), 1);
@@ -1961,7 +2033,7 @@ void tst_QSGListView::modelChanges()
QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
listView->setModel(modelVariant);
@@ -2671,6 +2743,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<QSGListView>(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<QSGItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ item = findItem<QSGItem>(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<QSGItem>(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();
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/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 8e711e6ceb..420eda9aca 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();
@@ -75,6 +76,7 @@ private slots:
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
void hoverPosition();
+ void hoverPropagation();
private:
QSGView *createView();
@@ -417,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();
@@ -735,12 +781,43 @@ 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));
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);
+#ifdef Q_WS_QPA
+ QEXPECT_FAIL("", "QTBUG-21008 fails", Abort);
+#endif
+ 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"
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..96a591f511 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<QSGItem>(pathview, "wrapper").count(), 14);
QVERIFY(pathview->currentIndex() == 0);
+ QCOMPARE(pathview->currentItem(), findItem<QSGItem>(pathview, "wrapper", 0));
QSGText *text = findItem<QSGText>(pathview, "myText", 4);
QVERIFY(text);
@@ -433,6 +434,7 @@ void tst_QSGPathView::dataModel()
text = findItem<QSGText>(pathview, "myText", 2);
QVERIFY(text);
QCOMPARE(text->text(), model.name(2));
+ QCOMPARE(pathview->currentItem(), findItem<QSGItem>(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<QSGItem>(pathview, "wrapper", 1));
+ QTest::qWait(100);
model.insertItem(2, "pink", "2");
QTest::qWait(100);
QTRY_COMPARE(findItems<QSGItem>(pathview, "wrapper").count(), 5);
QVERIFY(pathview->currentIndex() == 1);
+ QCOMPARE(pathview->currentItem(), findItem<QSGItem>(pathview, "wrapper", 1));
text = findItem<QSGText>(pathview, "myText", 2);
QVERIFY(text);
@@ -462,6 +467,7 @@ void tst_QSGPathView::dataModel()
text = findItem<QSGText>(pathview, "myText", 3);
QVERIFY(text);
QCOMPARE(text->text(), model.name(3));
+ QCOMPARE(pathview->currentItem(), findItem<QSGItem>(pathview, "wrapper", 1));
model.moveItem(3, 5);
QTRY_COMPARE(findItems<QSGItem>(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<QSGItem>(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<QSGRectangle>(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<QSGRectangle>(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<QSGRectangle>(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<QSGRectangle>(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<QSGRectangle>(pathview, "wrapper", 0));
+ QVERIFY(findItem<QSGRectangle>(pathview, "wrapper", 1));
+ QVERIFY(!findItem<QSGRectangle>(pathview, "wrapper", 2));
+ QVERIFY(!findItem<QSGRectangle>(pathview, "wrapper", 3));
+
+ pathview->setCurrentIndex(2);
+ firstItem = findItem<QSGRectangle>(pathview, "wrapper", 2);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 1);
+ firstItem = findItem<QSGRectangle>(pathview, "wrapper", 1);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QSGRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QSGRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->incrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QSGRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
delete canvas;
}
@@ -777,7 +835,7 @@ void tst_QSGPathView::modelChanges()
QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
QVERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
pathView->setModel(modelVariant);
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/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/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/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 a9bdf4249b..137e6acd77 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();
@@ -75,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();
@@ -89,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);
};
@@ -328,6 +334,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<QSGRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QSGRectangle *two = canvas->rootObject()->findChild<QSGRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QSGRectangle *three = canvas->rootObject()->findChild<QSGRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QSGItem *row = canvas->rootObject()->findChild<QSGItem*>("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");
@@ -581,6 +627,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<QSGRectangle*>("one");
+ QVERIFY(one != 0);
+ QSGRectangle *two = canvas->rootObject()->findChild<QSGRectangle*>("two");
+ QVERIFY(two != 0);
+ QSGRectangle *three = canvas->rootObject()->findChild<QSGRectangle*>("three");
+ QVERIFY(three != 0);
+ QSGRectangle *four = canvas->rootObject()->findChild<QSGRectangle*>("four");
+ QVERIFY(four != 0);
+ QSGRectangle *five = canvas->rootObject()->findChild<QSGRectangle*>("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<QSGItem*>("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");
@@ -1270,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<QSGRectangle *>("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<QSGRectangle *>("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<QString>("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<QSGRow *>("pos");
+ QVERIFY(row != 0);
+
+ QSGRectangle *rect0 = canvas->rootObject()->findChild<QSGRectangle *>("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<QSGRectangle *>("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<QSGRectangle *>("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);
diff --git a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp
index 48d679bfa7..d972378a65 100644
--- a/tests/auto/declarative/qsgtext/tst_qsgtext.cpp
+++ b/tests/auto/declarative/qsgtext/tst_qsgtext.cpp
@@ -45,6 +45,7 @@
#include <private/qsgtext_p.h>
#include <private/qsgtext_p_p.h>
#include <private/qdeclarativevaluetype_p.h>
+#include <private/qsgdistancefieldglyphcache_p.h>
#include <QFontMetrics>
#include <QGraphicsSceneMouseEvent>
#include <qmath.h>
@@ -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);
@@ -1324,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/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 <QtDeclarative/qdeclarativecomponent.h>
#include <private/qsgtextedit_p.h>
#include <private/qsgtextedit_p_p.h>
+#include <private/qsgdistancefieldglyphcache_p.h>
#include <QFontMetrics>
#include <QSGView>
#include <QDir>
@@ -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<QSGTextEdit*>("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..3cc0dc196b 100644
--- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
+++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
@@ -51,7 +51,9 @@
#include <QStyle>
#include <QInputContext>
#include <private/qapplication_p.h>
+#include <private/qsgdistancefieldglyphcache_p.h>
#include <QtOpenGL/QGLShaderProgram>
+#include <math.h>
#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<QSGTextInput*>("text");
QVERIFY(textInput != 0);
@@ -1161,7 +1190,49 @@ 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));
+
+#ifdef Q_WS_QPA
+ QEXPECT_FAIL("", "QTBUG-21011 fails", Continue);
+#endif
// some tollerance for different fonts.
#ifdef Q_OS_LINUX
@@ -1177,7 +1248,32 @@ 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));
+
+#ifdef Q_WS_QPA
+ QEXPECT_FAIL("", "QTBUG-21011 fails", Continue);
+#endif
// some tollerance for different fonts.
#ifdef Q_OS_LINUX
@@ -1442,7 +1538,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();
@@ -2222,6 +2317,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/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<QSGItem>(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<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
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()
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/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<QDeclarative1Rectangle*>(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/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<bool>("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/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);
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 <qtest.h>
+#include <QtDeclarative/qjsvalue.h>
+#include <QtDeclarative/qjsengine.h>
+
+
+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<int>();
+ m_engine->setDefaultPrototype(type, m_engine->newObject());
+ QBENCHMARK {
+ m_engine->defaultPrototype(type);
+ }
+}
+
+void tst_QJSEngine::setDefaultPrototype()
+{
+ newEngine();
+ int type = qMetaTypeId<int>();
+ QJSValue proto = m_engine->newObject();
+ QBENCHMARK {
+ m_engine->setDefaultPrototype(type, proto);
+ }
+}
+
+#endif
+
+void tst_QJSEngine::evaluate_data()
+{
+ QTest::addColumn<QString>("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<int>("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<QJSValue>("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<qreal>(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<QString>("text");
+ QTest::addColumn<QString>("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<bool>("staticScope");
+ QTest::addColumn<bool>("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 <qtest.h>
+#include <QtDeclarative/qjsvalue.h>
+#include <QtDeclarative/qjsengine.h>
+
+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<QString>("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<QString>("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<QString>("propertyName");
+ QTest::addColumn<bool>("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<QString>("propertyName");
+ QTest::addColumn<QJSValue>("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<QJSValue>("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 <qtest.h>
+#include <QtDeclarative/qjsengine.h>
+#include <QtDeclarative/qjsvalue.h>
+#include <QtDeclarative/qjsvalueiterator.h>
+
+//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<QString>("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"
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 {