summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro10
-rw-r--r--tests/auto/declarative/.gitignore3
-rw-r--r--tests/auto/declarative/datetimeformatter/datetimeformatter.pro3
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp83
-rw-r--r--tests/auto/declarative/declarative.pro22
-rw-r--r--tests/auto/declarative/layouts/data/grid-margin.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing-margin.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid.xml9
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical.xml7
-rw-r--r--tests/auto/declarative/layouts/layouts.pro6
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp392
-rw-r--r--tests/auto/declarative/listview/data/listview.xml14
-rw-r--r--tests/auto/declarative/listview/listview.pro6
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp484
-rw-r--r--tests/auto/declarative/namespaces/data/Red/Rect.qml2
-rw-r--r--tests/auto/declarative/namespaces/namespaces.pro6
-rw-r--r--tests/auto/declarative/namespaces/tst_namespaces.cpp94
-rw-r--r--tests/auto/declarative/numberformatter/numberformatter.pro3
-rw-r--r--tests/auto/declarative/numberformatter/tst_numberformatter.cpp216
-rw-r--r--tests/auto/declarative/pathview/data/pathview.xml20
-rw-r--r--tests/auto/declarative/pathview/pathview.pro6
-rw-r--r--tests/auto/declarative/pathview/tst_pathview.cpp259
-rw-r--r--tests/auto/declarative/qbindablemap/qbindablemap.pro3
-rw-r--r--tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp72
-rw-r--r--tests/auto/declarative/qfxtext/qfxtext.pro3
-rw-r--r--tests/auto/declarative/qfxtext/tst_qfxtext.cpp412
-rw-r--r--tests/auto/declarative/qfxtextedit/qfxtextedit.pro3
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp326
-rw-r--r--tests/auto/declarative/qmlbindengine/qmlbindengine.pro3
-rw-r--r--tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp123
-rw-r--r--tests/auto/declarative/qmllist/qmllist.pro3
-rw-r--r--tests/auto/declarative/qmllist/tst_qmllist.cpp38
-rw-r--r--tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro3
-rw-r--r--tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp61
-rw-r--r--tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro3
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp104
-rw-r--r--tests/auto/declarative/qmlparser/qmlparser.pro3
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp444
-rw-r--r--tests/auto/declarative/repeater/data/repeater.xml7
-rw-r--r--tests/auto/declarative/repeater/repeater.pro6
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp91
-rw-r--r--tests/auto/declarative/simplecanvasitem/data/test.xml12
-rw-r--r--tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro6
-rw-r--r--tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp79
-rw-r--r--tests/auto/declarative/visual/ListView/basic1/basic1.xml19
-rw-r--r--tests/auto/declarative/visual/ListView/basic1/data/opengl/image0.pngbin0 -> 3759 bytes
-rw-r--r--tests/auto/declarative/visual/ListView/basic1/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/ListView/basic1/test1
-rw-r--r--tests/auto/declarative/visual/ListView/basic2/basic2.xml20
-rw-r--r--tests/auto/declarative/visual/ListView/basic2/data/opengl/image0.pngbin0 -> 3759 bytes
-rw-r--r--tests/auto/declarative/visual/ListView/basic2/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/ListView/basic2/test1
-rw-r--r--tests/auto/declarative/visual/ListView/basic3/basic3.xml18
-rw-r--r--tests/auto/declarative/visual/ListView/basic3/data/opengl/image0.pngbin0 -> 3759 bytes
-rw-r--r--tests/auto/declarative/visual/ListView/basic3/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/ListView/basic3/test1
-rw-r--r--tests/auto/declarative/visual/ListView/basic4/basic4.xml19
-rw-r--r--tests/auto/declarative/visual/ListView/basic4/data/opengl/image0.pngbin0 -> 3759 bytes
-rw-r--r--tests/auto/declarative/visual/ListView/basic4/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/ListView/basic4/test1
-rw-r--r--tests/auto/declarative/visual/bindinganimation/bindinganimation.xml19
-rw-r--r--tests/auto/declarative/visual/bindinganimation/data/opengl/image0.pngbin0 -> 817 bytes
-rw-r--r--tests/auto/declarative/visual/bindinganimation/data/opengl/manifest-play.xml104
-rw-r--r--tests/auto/declarative/visual/bindinganimation/data/opengl/manifest.xml104
-rw-r--r--tests/auto/declarative/visual/bindinganimation/test1
-rw-r--r--tests/auto/declarative/visual/colorAnimation/colorAnimation.xml18
-rw-r--r--tests/auto/declarative/visual/colorAnimation/image0.pngbin0 -> 947 bytes
-rw-r--r--tests/auto/declarative/visual/colorAnimation/manifest-play.xml73
-rw-r--r--tests/auto/declarative/visual/colorAnimation/manifest.xml73
-rw-r--r--tests/auto/declarative/visual/easing/easing.xml70
-rw-r--r--tests/auto/declarative/visual/easing/image0.pngbin0 -> 17530 bytes
-rw-r--r--tests/auto/declarative/visual/easing/manifest-play.xml23
-rw-r--r--tests/auto/declarative/visual/easing/manifest.xml23
-rw-r--r--tests/auto/declarative/visual/easing/pics/qtlogo.pngbin0 -> 2738 bytes
-rw-r--r--tests/auto/declarative/visual/flickable/Day.qml8
-rw-r--r--tests/auto/declarative/visual/flickable/cork.jpgbin0 -> 88766 bytes
-rw-r--r--tests/auto/declarative/visual/flickable/flickable.xml43
-rw-r--r--tests/auto/declarative/visual/flickable/image0.pngbin0 -> 360547 bytes
-rw-r--r--tests/auto/declarative/visual/flickable/manifest-fail.xml30
-rw-r--r--tests/auto/declarative/visual/flickable/manifest.xml190
-rw-r--r--tests/auto/declarative/visual/flipable/flipable.xml138
-rw-r--r--tests/auto/declarative/visual/flipable/image0.pngbin0 -> 6184 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/manifest-play.xml24
-rw-r--r--tests/auto/declarative/visual/flipable/manifest.xml24
-rw-r--r--tests/auto/declarative/visual/flipable/pics/arrow.pngbin0 -> 546 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/face.pngbin0 -> 10112 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo0.pngbin0 -> 10412 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo1.pngbin0 -> 11068 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo10.pngbin0 -> 12539 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo2.pngbin0 -> 11490 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo3.pngbin0 -> 11308 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo4.pngbin0 -> 11322 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo5.pngbin0 -> 11497 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo6.pngbin0 -> 11707 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo7.pngbin0 -> 11101 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo8.pngbin0 -> 11558 bytes
-rw-r--r--tests/auto/declarative/visual/flipable/pics/photo9.pngbin0 -> 10943 bytes
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/image0.pngbin0 -> 3209 bytes
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/manifest-play.xml138
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/manifest.xml138
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/pauseAnimation.xml13
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/pics/qtlogo.pngbin0 -> 2738 bytes
-rw-r--r--tests/auto/declarative/visual/qfxtext/elide/data/opengl/image0.pngbin0 -> 980 bytes
-rw-r--r--tests/auto/declarative/visual/qfxtext/elide/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/qfxtext/elide/elide.xml6
-rw-r--r--tests/auto/declarative/visual/qfxtext/elide/test1
-rw-r--r--tests/auto/declarative/visual/repeater/basic1/basic1.xml21
-rw-r--r--tests/auto/declarative/visual/repeater/basic1/data/opengl/image0.pngbin0 -> 3493 bytes
-rw-r--r--tests/auto/declarative/visual/repeater/basic1/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/repeater/basic1/test1
-rw-r--r--tests/auto/declarative/visual/repeater/basic2/basic2.xml22
-rw-r--r--tests/auto/declarative/visual/repeater/basic2/data/opengl/image0.pngbin0 -> 3493 bytes
-rw-r--r--tests/auto/declarative/visual/repeater/basic2/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/repeater/basic2/test1
-rw-r--r--tests/auto/declarative/visual/repeater/basic3/basic3.xml19
-rw-r--r--tests/auto/declarative/visual/repeater/basic3/data/opengl/image0.pngbin0 -> 3493 bytes
-rw-r--r--tests/auto/declarative/visual/repeater/basic3/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/repeater/basic3/test1
-rw-r--r--tests/auto/declarative/visual/repeater/basic4/basic4.xml18
-rw-r--r--tests/auto/declarative/visual/repeater/basic4/data/opengl/image0.pngbin0 -> 3493 bytes
-rw-r--r--tests/auto/declarative/visual/repeater/basic4/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/repeater/basic4/test1
-rwxr-xr-xtests/auto/declarative/visual/runtests.sh2
-rw-r--r--tests/auto/declarative/visual/tests11
-rw-r--r--tests/auto/declarative/visual/tst_visual.cpp72
-rw-r--r--tests/auto/declarative/visual/visual.pro5
-rw-r--r--tests/auto/declarative/visual/webview/autosize/data/opengl/image0.pngbin0 -> 5396 bytes
-rw-r--r--tests/auto/declarative/visual/webview/autosize/data/opengl/manifest.xml4
-rw-r--r--tests/auto/declarative/visual/webview/autosize/test1
-rw-r--r--tests/auto/dynamicobject/dynamicobject.pro6
-rw-r--r--tests/auto/dynamicobject/qdynamicmetaobject.cpp254
-rw-r--r--tests/auto/dynamicobject/qdynamicmetaobject.h47
-rw-r--r--tests/auto/dynamicobject/qmetaobjectbuilder.cpp2347
-rw-r--r--tests/auto/dynamicobject/qmetaobjectbuilder.h258
-rw-r--r--tests/auto/dynamicobject/tst_qobject.cpp325
-rw-r--r--tests/auto/qanimationgroup/qanimationgroup.pro5
-rw-r--r--tests/auto/qanimationgroup/tst_qanimationgroup.cpp347
-rw-r--r--tests/auto/qanimationstate/qanimationstate.pro5
-rw-r--r--tests/auto/qanimationstate/tst_qanimationstate.cpp625
-rw-r--r--tests/auto/qeasingcurve/qeasingcurve.pro3
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp488
-rw-r--r--tests/auto/qparallelanimationgroup/qparallelanimationgroup.pro5
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp834
-rw-r--r--tests/auto/qpropertyanimation/qpropertyanimation.pro5
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp831
-rw-r--r--tests/auto/qscriptqobject/tst_qscriptqobject.cpp66
-rw-r--r--tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro5
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp1649
-rw-r--r--tests/auto/qstate/qstate.pro5
-rw-r--r--tests/auto/qstate/tst_qstate.cpp372
-rw-r--r--tests/auto/qstatemachine/qstatemachine.pro4
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp2177
160 files changed, 15743 insertions, 2 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 443ee7e..869f1c4 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -5,9 +5,11 @@ TEMPLATE = subdirs
headers
SUBDIRS += bic \
+ dynamicobject \
collections \
compile \
compilerwarnings \
+ dynamicobject \
exceptionsafety \
macgui \
macplist \
@@ -75,6 +77,7 @@ SUBDIRS += bic \
qaction \
qactiongroup \
qalgorithms \
+ qanimationgroup \
qapplication \
qatomicint \
qatomicpointer \
@@ -213,6 +216,7 @@ SUBDIRS += bic \
qpainter \
qpainterpath \
qpalette \
+ qparallelanimationgroup \
qpathclipper \
qpen \
qpicture \
@@ -228,6 +232,7 @@ SUBDIRS += bic \
qprocess \
qprogressbar \
qprogressdialog \
+ qpropertyanimation \
qpushbutton \
qqueue \
qradiobutton \
@@ -254,6 +259,7 @@ SUBDIRS += bic \
qscrollarea \
qsemaphore \
qsharedpointer \
+ qsequentialanimationgroup \
qset \
qsettings \
qshortcut \
@@ -287,6 +293,7 @@ SUBDIRS += bic \
qstackedwidget \
qstandarditem \
qstandarditemmodel \
+ qstate \
qstatusbar \
qstl \
qstring \
@@ -340,6 +347,7 @@ SUBDIRS += bic \
qtranslator \
qtransform \
qtransformedscreen \
+ qtransition \
qtreeview \
qtreewidget \
qtreewidgetitemiterator \
@@ -432,3 +440,5 @@ contains(QT_CONFIG, webkit): SUBDIRS += \
qwebpage
SUBDIRS += math3d
+
+contains(QT_CONFIG, declarative): SUBDIRS += declarative
diff --git a/tests/auto/declarative/.gitignore b/tests/auto/declarative/.gitignore
new file mode 100644
index 0000000..c8bbd2f
--- /dev/null
+++ b/tests/auto/declarative/.gitignore
@@ -0,0 +1,3 @@
+tst_*
+!tst_*.*
+tst_*~
diff --git a/tests/auto/declarative/datetimeformatter/datetimeformatter.pro b/tests/auto/declarative/datetimeformatter/datetimeformatter.pro
new file mode 100644
index 0000000..e3d6cd0
--- /dev/null
+++ b/tests/auto/declarative/datetimeformatter/datetimeformatter.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_datetimeformatter.cpp
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
new file mode 100644
index 0000000..4593033
--- /dev/null
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -0,0 +1,83 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmldatetimeformatter.h>
+
+class tst_datetimeformatter : public QObject
+{
+ Q_OBJECT
+public:
+ tst_datetimeformatter() {}
+
+private slots:
+ void date();
+ void time();
+ void dateTime();
+};
+
+void tst_datetimeformatter::date()
+{
+ QmlEngine engine;
+ QmlComponent formatterComponent(&engine, "<DateTimeFormatter date=\"2008-12-24\"/>");
+ QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QDate date(2008,12,24);
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateFormat("ddd MMMM d yy");
+ QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
+
+ QVERIFY(formatter->timeText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+}
+
+void tst_datetimeformatter::time()
+{
+ QmlEngine engine;
+ QmlComponent formatterComponent(&engine, "<DateTimeFormatter time=\"14:15:38.200\"/>");
+ QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QTime time(14,15,38,200);
+
+ QCOMPARE(formatter->time(),time);
+
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setTimeFormat("H:m:s a");
+ QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
+
+ formatter->setTimeFormat("hh:mm:ss.zzz");
+ QCOMPARE(formatter->timeText(),time.toString("hh:mm:ss.zzz"));
+
+ QVERIFY(formatter->dateText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+}
+
+void tst_datetimeformatter::dateTime()
+{
+ QmlEngine engine;
+ QmlComponent formatterComponent(&engine, "<DateTimeFormatter dateTime=\"1978-03-04T09:13:54\"/>");
+ QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateTimeFormat("M/d/yy H:m:s a");
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
+}
+
+QTEST_MAIN(tst_datetimeformatter)
+
+#include "tst_datetimeformatter.moc"
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
new file mode 100644
index 0000000..b6e3584
--- /dev/null
+++ b/tests/auto/declarative/declarative.pro
@@ -0,0 +1,22 @@
+TEMPLATE = subdirs
+SUBDIRS += datetimeformatter \
+ numberformatter \
+ qbindablemap \
+ layouts \
+ listview \
+ pathview \
+ qfxtext \
+ qfxtextedit \
+ simplecanvasitem \
+ repeater \
+ qmlparser \
+ qmlbindengine \
+ qmlmetaproperty \
+ qmllist \
+ qmllistaccessor \
+ visual
+
+# Tests which should run in Pulse
+PULSE_TESTS = $$SUBDIRS
+PULSE_TESTS -= visual # All except 'visual' tests, allegedly too flaky
+
diff --git a/tests/auto/declarative/layouts/data/grid-margin.xml b/tests/auto/declarative/layouts/data/grid-margin.xml
new file mode 100644
index 0000000..fe58eef
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-margin.xml
@@ -0,0 +1,9 @@
+<Item width="640" height="480">
+ <GridLayout columns="3" margin="8">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="green" width="20" height="50"/>
+ <Rect id="three" color="blue" width="50" height="20"/>
+ <Rect id="four" color="cyan" width="50" height="50"/>
+ <Rect id="five" color="magenta" width="10" height="10"/>
+ </GridLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/grid-spacing-margin.xml b/tests/auto/declarative/layouts/data/grid-spacing-margin.xml
new file mode 100644
index 0000000..807b653
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-spacing-margin.xml
@@ -0,0 +1,9 @@
+<Item width="640" height="480">
+ <GridLayout columns="3" spacing="4" margin="8">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="green" width="20" height="50"/>
+ <Rect id="three" color="blue" width="50" height="20"/>
+ <Rect id="four" color="cyan" width="50" height="50"/>
+ <Rect id="five" color="magenta" width="10" height="10"/>
+ </GridLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/grid-spacing.xml b/tests/auto/declarative/layouts/data/grid-spacing.xml
new file mode 100644
index 0000000..55ef5a5
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-spacing.xml
@@ -0,0 +1,9 @@
+<Item width="640" height="480">
+ <GridLayout columns="3" spacing="4">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="green" width="20" height="50"/>
+ <Rect id="three" color="blue" width="50" height="20"/>
+ <Rect id="four" color="cyan" width="50" height="50"/>
+ <Rect id="five" color="magenta" width="10" height="10"/>
+ </GridLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/grid.xml b/tests/auto/declarative/layouts/data/grid.xml
new file mode 100644
index 0000000..abef813
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid.xml
@@ -0,0 +1,9 @@
+<Item width="640" height="480">
+ <GridLayout columns="3">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="green" width="20" height="50"/>
+ <Rect id="three" color="blue" width="50" height="20"/>
+ <Rect id="four" color="cyan" width="50" height="50"/>
+ <Rect id="five" color="magenta" width="10" height="10"/>
+ </GridLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/horizontal-margin.xml b/tests/auto/declarative/layouts/data/horizontal-margin.xml
new file mode 100644
index 0000000..7ee9706
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-margin.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <HorizontalLayout margin="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </HorizontalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml
new file mode 100644
index 0000000..8767818
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <HorizontalLayout spacing="5" margin="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </HorizontalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.xml b/tests/auto/declarative/layouts/data/horizontal-spacing.xml
new file mode 100644
index 0000000..cb58711
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <HorizontalLayout spacing="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </HorizontalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/horizontal.xml b/tests/auto/declarative/layouts/data/horizontal.xml
new file mode 100644
index 0000000..f9deaf1
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <HorizontalLayout>
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </HorizontalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/vertical-margin.xml b/tests/auto/declarative/layouts/data/vertical-margin.xml
new file mode 100644
index 0000000..abd7635
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-margin.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <VerticalLayout margin="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </VerticalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml b/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml
new file mode 100644
index 0000000..3d41ca0
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <VerticalLayout spacing="5" margin="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </VerticalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.xml b/tests/auto/declarative/layouts/data/vertical-spacing.xml
new file mode 100644
index 0000000..e25f981
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-spacing.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <VerticalLayout spacing="10">
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </VerticalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/data/vertical.xml b/tests/auto/declarative/layouts/data/vertical.xml
new file mode 100644
index 0000000..198d99f
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical.xml
@@ -0,0 +1,7 @@
+<Item width="640" height="480">
+ <VerticalLayout>
+ <Rect id="one" color="red" width="50" height="50"/>
+ <Rect id="two" color="red" width="20" height="10"/>
+ <Rect id="three" color="red" width="40" height="20"/>
+ </VerticalLayout>
+</Item>
diff --git a/tests/auto/declarative/layouts/layouts.pro b/tests/auto/declarative/layouts/layouts.pro
new file mode 100644
index 0000000..f7e7622
--- /dev/null
+++ b/tests/auto/declarative/layouts/layouts.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_layouts.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
new file mode 100644
index 0000000..ad6a0b2
--- /dev/null
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -0,0 +1,392 @@
+#include <QtTest/QtTest>
+#include <qlistmodelinterface.h>
+#include <qfxview.h>
+#include <qfxrect.h>
+#include <qmlexpression.h>
+
+class tst_QFxLayouts : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QFxLayouts();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_spacing();
+ void test_horizontal_margin();
+ void test_horizontal_spacing_margin();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_margin();
+ void test_vertical_spacing_margin();
+ void test_grid();
+ void test_grid_spacing();
+ void test_grid_margin();
+ void test_grid_spacing_margin();
+
+private:
+ QFxView *createView(const QString &filename);
+ template<typename T>
+ T *findItem(QFxItem *parent, const QString &id, int index=0);
+};
+
+tst_QFxLayouts::tst_QFxLayouts()
+{
+}
+
+void tst_QFxLayouts::test_horizontal()
+{
+ QFxView *canvas = createView(SRCDIR "/data/horizontal.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+}
+
+void tst_QFxLayouts::test_horizontal_spacing()
+{
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 60.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+}
+
+void tst_QFxLayouts::test_horizontal_margin()
+{
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 10.0);
+ QCOMPARE(one->y(), 10.0);
+ QCOMPARE(two->x(), 60.0);
+ QCOMPARE(two->y(), 10.0);
+ QCOMPARE(three->x(), 80.0);
+ QCOMPARE(three->y(), 10.0);
+}
+
+void tst_QFxLayouts::test_horizontal_spacing_margin()
+{
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 10.0);
+ QCOMPARE(one->y(), 10.0);
+ QCOMPARE(two->x(), 65.0);
+ QCOMPARE(two->y(), 10.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 10.0);
+}
+
+void tst_QFxLayouts::test_vertical()
+{
+ QFxView *canvas = createView(SRCDIR "/data/vertical.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+}
+
+void tst_QFxLayouts::test_vertical_spacing()
+{
+ QFxView *canvas = createView(SRCDIR "/data/vertical-spacing.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 60.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 80.0);
+}
+
+void tst_QFxLayouts::test_vertical_margin()
+{
+ QFxView *canvas = createView(SRCDIR "/data/vertical-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 10.0);
+ QCOMPARE(one->y(), 10.0);
+ QCOMPARE(two->x(), 10.0);
+ QCOMPARE(two->y(), 60.0);
+ QCOMPARE(three->x(), 10.0);
+ QCOMPARE(three->y(), 70.0);
+}
+
+void tst_QFxLayouts::test_vertical_spacing_margin()
+{
+ QFxView *canvas = createView(SRCDIR "/data/vertical-spacing-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 10.0);
+ QCOMPARE(one->y(), 10.0);
+ QCOMPARE(two->x(), 10.0);
+ QCOMPARE(two->y(), 65.0);
+ QCOMPARE(three->x(), 10.0);
+ QCOMPARE(three->y(), 80.0);
+}
+
+void tst_QFxLayouts::test_grid()
+{
+ QFxView *canvas = createView("data/grid.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+ QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QVERIFY(four != 0);
+ QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+}
+
+void tst_QFxLayouts::test_grid_spacing()
+{
+ QFxView *canvas = createView("data/grid-spacing.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+ QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QVERIFY(four != 0);
+ QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 54.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 78.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 54.0);
+ QCOMPARE(five->x(), 54.0);
+ QCOMPARE(five->y(), 54.0);
+}
+
+void tst_QFxLayouts::test_grid_margin()
+{
+ QFxView *canvas = createView("data/grid-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+ QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QVERIFY(four != 0);
+ QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 8.0);
+ QCOMPARE(one->y(), 8.0);
+ QCOMPARE(two->x(), 58.0);
+ QCOMPARE(two->y(), 8.0);
+ QCOMPARE(three->x(), 78.0);
+ QCOMPARE(three->y(), 8.0);
+ QCOMPARE(four->x(), 8.0);
+ QCOMPARE(four->y(), 58.0);
+ QCOMPARE(five->x(), 58.0);
+ QCOMPARE(five->y(), 58.0);
+}
+
+
+void tst_QFxLayouts::test_grid_spacing_margin()
+{
+ QFxView *canvas = createView("data/grid-spacing-margin.xml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QVERIFY(one != 0);
+ QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QVERIFY(two != 0);
+ QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QVERIFY(three != 0);
+ QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QVERIFY(four != 0);
+ QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 8.0);
+ QCOMPARE(one->y(), 8.0);
+ QCOMPARE(two->x(), 62.0);
+ QCOMPARE(two->y(), 8.0);
+ QCOMPARE(three->x(), 86.0);
+ QCOMPARE(three->y(), 8.0);
+ QCOMPARE(four->x(), 8.0);
+ QCOMPARE(four->y(), 62.0);
+ QCOMPARE(five->x(), 62.0);
+ QCOMPARE(five->y(), 62.0);
+}
+
+QFxView *tst_QFxLayouts::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setXml(xml, filename);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified id. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+*/
+template<typename T>
+T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &id, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->children()->count(); ++i) {
+ QFxItem *item = parent->children()->at(i);
+ if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (index != -1) {
+ QmlExpression e(item->itemContext(), "index", item);
+ e.setTrackChange(false);
+ if (e.value().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, id, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QFxLayouts)
+
+#include "tst_layouts.moc"
diff --git a/tests/auto/declarative/listview/data/listview.xml b/tests/auto/declarative/listview/data/listview.xml
new file mode 100644
index 0000000..7fda2b5
--- /dev/null
+++ b/tests/auto/declarative/listview/data/listview.xml
@@ -0,0 +1,14 @@
+<Rect width="240" height="320" color="#ffffff">
+ <resources>
+ <Component id="Delegate">
+ <Item id="wrapper" height="20" width="240">
+ <Text text="{index}"/>
+ <Text x="30" id="textName" text="{name}"/>
+ <Text x="120" id="textNumber" text="{number}"/>
+ <Text x="200" text="{wrapper.y}"/>
+ </Item>
+ </Component>
+ </resources>
+ <ListView id="list" width="240" height="320" model="{testModel}" delegate="{Delegate}">
+ </ListView>
+</Rect>
diff --git a/tests/auto/declarative/listview/listview.pro b/tests/auto/declarative/listview/listview.pro
new file mode 100644
index 0000000..bf68268
--- /dev/null
+++ b/tests/auto/declarative/listview/listview.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_listview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
new file mode 100644
index 0000000..5dd94a2
--- /dev/null
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -0,0 +1,484 @@
+#include <QtTest/QtTest>
+#include <qlistmodelinterface.h>
+#include <qfxview.h>
+#include <qfxlistview.h>
+#include <qfxtext.h>
+#include <qmlcontext.h>
+#include <qmlexpression.h>
+
+class tst_QFxListView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QFxListView();
+
+private slots:
+ // Test both QListModelInterface and QAbstractItemModel model types
+ void qListModelInterface_items();
+ void qAbstractItemModel_items();
+
+ void qListModelInterface_changed();
+ void qAbstractItemModel_changed();
+
+ void qListModelInterface_inserted();
+ void qAbstractItemModel_inserted();
+
+ void qListModelInterface_removed();
+ void qAbstractItemModel_removed();
+
+private:
+ template <class T> void items();
+ template <class T> void changed();
+ template <class T> void inserted();
+ template <class T> void removed();
+ QFxView *createView(const QString &filename);
+ template<typename T>
+ T *findItem(QFxItem *parent, const QString &id, int index=0);
+};
+
+class TestModel : public QListModelInterface
+{
+ Q_OBJECT
+public:
+ TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
+ ~TestModel() {}
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ int count() const { return list.count(); }
+
+ QList<int> roles() const { return QList<int>() << Name << Number; }
+ QString toString(int role) const {
+ switch(role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+ }
+
+ QHash<int, QVariant> data(int index, const QList<int> &roles) const {
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch(role) {
+ case Name:
+ info = list.at(index).first;
+ break;
+ case Number:
+ info = list.at(index).second;
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+ return returnHash;
+ }
+
+ void addItem(const QString &name, const QString &number) {
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+ }
+
+ void removeItem(int index) {
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+ }
+
+ void modifyItem(int index, const QString &name, const QString &number) {
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+class TestModel2 : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+ }
+
+ int count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QFxListView::tst_QFxListView()
+{
+}
+
+template <class T>
+void tst_QFxListView::items()
+{
+ QFxView *canvas = createView(SRCDIR "/data/listview.xml");
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxFlickable *listview = findItem<QFxFlickable>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QFxItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+
+ for (int i = 0; i < model.count(); ++i) {
+ QFxText *name = findItem<QFxText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QFxText *number = findItem<QFxText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QFxListView::changed()
+{
+ QFxView *canvas = createView(SRCDIR "/data/listview.xml");
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxFlickable *listview = findItem<QFxFlickable>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QFxItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QFxText *name = findItem<QFxText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QFxText *number = findItem<QFxText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QFxListView::inserted()
+{
+ QFxView *canvas = createView(SRCDIR "/data/listview.xml");
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxListView *listview = findItem<QFxListView>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QFxItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+
+ QFxText *name = findItem<QFxText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QFxText *number = findItem<QFxText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QVERIFY(item->y() == i*20);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+
+ name = findItem<QFxText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QFxText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ QCOMPARE(listview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QVERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QFxListView::removed()
+{
+ QFxView *canvas = createView(SRCDIR "/data/listview.xml");
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxListView *listview = findItem<QFxListView>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QFxItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ QFxText *name = findItem<QFxText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QFxText *number = findItem<QFxText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QVERIFY(item->y() == i*20);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0); // post: top item starts at 20
+
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ name = findItem<QFxText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QFxText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(),i*20.0 + 20.0);
+ }
+
+ // Remove items not visible
+ model.removeItem(18);
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(),i*20.0+20.0);
+ }
+
+ // Remove items before visible
+ listview->setYPosition(80);
+ listview->setCurrentIndex(10);
+
+ model.removeItem(1); // post: top item will be at 40
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ // Confirm items positioned correctly
+ for (int i = 2; i < 18; ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ listview->setYPosition(40); // That's the top now
+ // let transitions settle.
+ QTest::qWait(1000);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QFxListView::qListModelInterface_items()
+{
+ items<TestModel>();
+}
+
+void tst_QFxListView::qAbstractItemModel_items()
+{
+ items<TestModel2>();
+}
+
+void tst_QFxListView::qListModelInterface_changed()
+{
+ changed<TestModel>();
+}
+
+void tst_QFxListView::qAbstractItemModel_changed()
+{
+ changed<TestModel2>();
+}
+
+void tst_QFxListView::qListModelInterface_inserted()
+{
+ inserted<TestModel>();
+}
+
+void tst_QFxListView::qAbstractItemModel_inserted()
+{
+ inserted<TestModel2>();
+}
+
+void tst_QFxListView::qListModelInterface_removed()
+{
+ removed<TestModel>();
+}
+
+void tst_QFxListView::qAbstractItemModel_removed()
+{
+ removed<TestModel2>();
+}
+
+QFxView *tst_QFxListView::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+ canvas->setFixedSize(240,320);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setXml(xml, filename);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified id. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+*/
+template<typename T>
+T *tst_QFxListView::findItem(QFxItem *parent, const QString &id, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->children()->count(); ++i) {
+ QFxItem *item = parent->children()->at(i);
+ if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (index != -1) {
+ QmlExpression e(item->itemContext(), "index", item);
+ e.setTrackChange(false);
+ if (e.value().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, id, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QFxListView)
+
+#include "tst_listview.moc"
diff --git a/tests/auto/declarative/namespaces/data/Red/Rect.qml b/tests/auto/declarative/namespaces/data/Red/Rect.qml
new file mode 100644
index 0000000..c7b3d8c
--- /dev/null
+++ b/tests/auto/declarative/namespaces/data/Red/Rect.qml
@@ -0,0 +1,2 @@
+<Text objectName="x" text="Pretending to be a Rect" color="red">
+</Text>
diff --git a/tests/auto/declarative/namespaces/namespaces.pro b/tests/auto/declarative/namespaces/namespaces.pro
new file mode 100644
index 0000000..f232770
--- /dev/null
+++ b/tests/auto/declarative/namespaces/namespaces.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_namespaces.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/namespaces/tst_namespaces.cpp b/tests/auto/declarative/namespaces/tst_namespaces.cpp
new file mode 100644
index 0000000..665651d
--- /dev/null
+++ b/tests/auto/declarative/namespaces/tst_namespaces.cpp
@@ -0,0 +1,94 @@
+#include <qtest.h>
+#include <QtDeclarative/qfxview.h>
+#include <QtDeclarative/qmlcontext.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qfxrect.h>
+#include <QtDeclarative/qfxtext.h>
+#include <QDir>
+
+class tst_namespaces : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_namespaces();
+
+private slots:
+ void simple();
+ void simple_data();
+};
+
+tst_namespaces::tst_namespaces()
+{
+}
+
+void tst_namespaces::simple_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QString>("texts");
+ QTest::addColumn<QString>("rects");
+
+ QTest::newRow("Control") <<
+ "<Rect objectName=\"a\">"
+ "<Rect objectName=\"b\"/>"
+ "</Rect>"
+ << true << "" << "ab";
+
+ QTest::newRow("Control2") <<
+ "<Rect objectName=\"a\">"
+ "<Text objectName=\"b\"/>"
+ "</Rect>"
+ << true << "b" << "a";
+
+ QTest::newRow("Replace builtin") <<
+ "<Rect objectName=\"a\" xmlns:rs=\"http://nokia.com/qml/Red\">"
+ "<rs:Rect objectName=\"b\"/>"
+ "</Rect>"
+ << true << "b" << "a";
+}
+
+void tst_namespaces::simple()
+{
+ QFETCH(QString, qml);
+ QFETCH(bool, valid);
+ QFETCH(QString, texts);
+ QFETCH(QString, rects);
+
+ QFxView canvas(0);
+ canvas.rootContext()->engine()->addNameSpacePath("http://nokia.com/qml", SRCDIR "/data");
+ canvas.setXml(qml);
+ canvas.execute();
+ qApp->processEvents();
+
+ QFxItem *testObject = qobject_cast<QFxItem*>(canvas.root());
+
+ QCOMPARE((testObject != 0),valid);
+
+ if (valid && testObject != 0) {
+ QString textids;
+ QList<QFxText*> textobjects = testObject->findChildren<QFxText*>();
+ if (qobject_cast<QFxText*>(testObject))
+ textids += testObject->objectName();
+ foreach (QFxText *obj, textobjects) {
+ textids += obj->objectName();
+ }
+ if (textids != texts)
+ testObject->dump();
+ QCOMPARE(textids,texts);
+
+ QString rectids;
+ QList<QFxRect*> rectobjects = testObject->findChildren<QFxRect*>();
+ if (qobject_cast<QFxRect*>(testObject))
+ rectids += testObject->objectName();
+ foreach (QFxRect *obj, rectobjects)
+ rectids += obj->objectName();
+ if (rectids != rects)
+ testObject->dump();
+ QCOMPARE(rectids,rects);
+ }
+}
+
+QTEST_MAIN(tst_namespaces)
+
+#include "tst_namespaces.moc"
diff --git a/tests/auto/declarative/numberformatter/numberformatter.pro b/tests/auto/declarative/numberformatter/numberformatter.pro
new file mode 100644
index 0000000..ba391ed
--- /dev/null
+++ b/tests/auto/declarative/numberformatter/numberformatter.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_numberformatter.cpp
diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
new file mode 100644
index 0000000..eaeab51
--- /dev/null
+++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
@@ -0,0 +1,216 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qnumberformat.h>
+#include <QtDeclarative/qmlnumberformatter.h>
+
+class tst_numberformat : public QObject
+{
+ Q_OBJECT
+public:
+ tst_numberformat();
+
+ void init() {}
+ void initTestCase() {}
+
+ void cleanup() {}
+ void cleanupTestCase() {}
+
+private slots:
+ void number_data();
+ void number();
+
+ void text_data();
+ void text();
+
+private:
+ QStringList strings;
+ QList<float> numbers;
+ QStringList formats;
+ QStringList texts;
+};
+
+tst_numberformat::tst_numberformat()
+{
+ strings << "100.0"
+ << "12345"
+ << "1234567"
+ << "0.123"
+ << "0.9999"
+ << "0.989"
+ << "1"
+ << "1.0"
+ << "1.01";
+
+ numbers << 100
+ << 12345
+ << 1234567
+ << 0.123
+ << 0.9999
+ << 0.989
+ << 1
+ << 1.0
+ << 1.01;
+
+ formats << ""
+ << "0000"
+ << "0000.00"
+ << "##"
+ << "##.##"
+ << "#0.00#"
+ << "##,##0.##"
+ << "(000) 000 - 000"
+ << "00000,000.0000";
+
+ //US locale only.
+ texts << "100.000000"
+ << "12345.000000"
+ << "1234567.000000"
+ << "0.123000"
+ << "0.999900"
+ << "0.989000"
+ << "1.000000"
+ << "1.000000"
+ << "1.010000" //end ""
+ << "0100"
+ << "12345"
+ << "1234567"
+ << "0000"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001" // end "0000"
+ << "0100.00"
+ << "12345.00"
+ << "1234567.00"
+ << "0000.12"
+ << "0001.00"
+ << "0000.99"
+ << "0001.00"
+ << "0001.00"
+ << "0001.01" // end "0000.00"
+ << "100"
+ << "12345"
+ << "1234567"
+ << "0"
+ << "1"
+ << "1"
+ << "1"
+ << "1"
+ << "1" // end "##"
+ << "100"//start "##.##"
+ << "12345"
+ << "1234567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" // end "##.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "100.00" //start "#0.00#"
+ << "12345.00"
+ << "1234567.00"
+ << "0.123"
+ << "1.00"
+ << "0.989"
+ << "1.00"
+ << "1.00"
+ << "1.01" //end "#0.00#"
+ << "100" //start "##,##0.##"
+ << "12,345"
+ << "1,234,567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" //end "##,##0.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "(000) 000 - 100" //start "(000) 000 - 000"
+ << "(000) 012 - 345"
+ << "(001) 234 - 567"
+ << "(000) 000 - 000"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001" // end "(000) 000 - 000"
+ << "00,000,100.0000" // start "00000,000.0000"
+ << "00,012,345.0000"
+ << "01,234,567.0000"
+ << "00,000,000.1230"
+ << "00,000,000.9999"
+ << "00,000,000.9890"
+ << "00,000,001.0000"
+ << "00,000,001.0000"
+ << "00,000,001.0100"; // end
+
+ qDebug() << "strings.size()" << strings.size()
+ << "\nformats.size()" << formats.size()
+ << "texts.size()" << texts.size();
+}
+
+void tst_numberformat::number_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<float>("number");
+
+ for (int i = 0; i < strings.size(); i++)
+ QTest::newRow(QString::number(i).toAscii()) << strings.at(i) << numbers.at(i);
+}
+
+void tst_numberformat::number()
+{
+ // ### tests the conversion from string to float
+ QFETCH(QString, string);
+ QFETCH(float, number);
+
+ QString componentStr = QString("<NumberFormatter number=\"") + string + QString("\"/>");
+
+ QmlEngine engine;
+ QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+ QCOMPARE((float)formatter->number(), number);
+ //qDebug() << formatter->format() << formatter->text();
+ QVERIFY(formatter->format().isEmpty());
+ QVERIFY(formatter->text() == QString("%1").arg(number, -1, 'f', -1));
+}
+
+void tst_numberformat::text_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QString>("text");
+
+ for (int j=0; j < formats.size(); j++)
+ {
+ for (int i=0; i < strings.size(); i++)
+ {
+ QTest::newRow(QString("%1, %2").arg(strings.at(i)).arg(formats.at(j)).toAscii())
+ << strings.at(i) << formats.at(j) << texts.at(j*formats.size()+i);
+ }
+ }
+
+}
+
+void tst_numberformat::text()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, format);
+ QFETCH(QString, text);
+
+ QString componentStr = QString("<NumberFormatter number=\"") + string + QString("\" format=\"") + format + QString("\" />");
+
+ QmlEngine engine;
+ QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QCOMPARE(formatter->format(), format);
+ QCOMPARE(formatter->text(), text);
+}
+
+QTEST_MAIN(tst_numberformat)
+
+#include "tst_numberformatter.moc"
diff --git a/tests/auto/declarative/pathview/data/pathview.xml b/tests/auto/declarative/pathview/data/pathview.xml
new file mode 100644
index 0000000..26b426c
--- /dev/null
+++ b/tests/auto/declarative/pathview/data/pathview.xml
@@ -0,0 +1,20 @@
+<Rect width="240" height="320" color="#ffffff">
+ <resources>
+ <Component id="Delegate">
+ <Rect id="wrapper" height="20" width="60" color="white" pen.color="black">
+ <Text text="{index}"/>
+ <Text x="20" id="textName" text="{name}"/>
+ <Text x="40" id="textNumber" text="{number}"/>
+ </Rect>
+ </Component>
+ </resources>
+ <PathView id="view" width="240" height="320" model="{testModel}" delegate="{Delegate}" snapPos="0.01">
+ <path>
+ <Path startY="120" startX="160">
+ <PathQuad y="120" x="80" controlY="330" controlX="100"/>
+ <PathLine y="160" x="20"/>
+ <PathCubic y="120" x="160" control1Y="0" control1X="100" control2Y="000" control2X="200"/>
+ </Path>
+ </path>
+ </PathView>
+</Rect>
diff --git a/tests/auto/declarative/pathview/pathview.pro b/tests/auto/declarative/pathview/pathview.pro
new file mode 100644
index 0000000..28bbe49
--- /dev/null
+++ b/tests/auto/declarative/pathview/pathview.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_pathview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp
new file mode 100644
index 0000000..4d58e57
--- /dev/null
+++ b/tests/auto/declarative/pathview/tst_pathview.cpp
@@ -0,0 +1,259 @@
+#include <QtTest/QtTest>
+#include <qlistmodelinterface.h>
+#include <qfxview.h>
+#include <qfxpathview.h>
+#include <qfxtext.h>
+#include <qfxrect.h>
+#include <qmlcontext.h>
+#include <qmlexpression.h>
+
+class tst_QFxPathView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QFxPathView();
+
+private slots:
+ void items();
+ void pathMoved();
+ void limitedItems();
+
+private:
+ QFxView *createView(const QString &filename);
+ template<typename T>
+ T *findItem(QFxItem *parent, const QString &id, int index=0);
+};
+
+class TestModel : public QListModelInterface
+{
+ Q_OBJECT
+public:
+ TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
+ ~TestModel() {}
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ int count() const { return list.count(); }
+
+ QList<int> roles() const { return QList<int>() << Name << Number; }
+ QString toString(int role) const {
+ switch(role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+ }
+
+ QHash<int, QVariant> data(int index, const QList<int> &roles) const {
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch(role) {
+ case Name:
+ info = list.at(index).first;
+ break;
+ case Number:
+ info = list.at(index).second;
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+ return returnHash;
+ }
+
+ void addItem(const QString &name, const QString &number) {
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+ }
+
+ void removeItem(int index) {
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+ }
+
+ void modifyItem(int index, const QString &name, const QString &number) {
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QFxPathView::tst_QFxPathView()
+{
+}
+
+void tst_QFxPathView::items()
+{
+ QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxPathView *pathview = findItem<QFxPathView>(canvas->root(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->children()->count(), model.count()); // assumes all are visible
+
+ for (int i = 0; i < model.count(); ++i) {
+ QFxText *name = findItem<QFxText>(pathview, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QFxText *number = findItem<QFxText>(pathview, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QFxPathView::pathMoved()
+{
+ QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+
+ TestModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxPathView *pathview = findItem<QFxPathView>(canvas->root(), "view");
+ QVERIFY(pathview != 0);
+
+ QFxRect *firstItem = findItem<QFxRect>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QFxPath *path = qobject_cast<QFxPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(10);
+ QTest::qWait(1000);//Moving is animated?
+
+ for(int i=0; i<model.count(); i++){
+ QFxRect *curItem = findItem<QFxRect>(pathview, "wrapper", i);
+ QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
+ }
+
+ pathview->setOffset(100);
+ QTest::qWait(1000);//Moving is animated?
+ QCOMPARE(firstItem->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QFxPathView::limitedItems()
+{
+ QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+
+ TestModel model;
+ for(int i=0; i<100; i++)
+ model.addItem("Bob", QString::number(i));
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxPathView *pathview = findItem<QFxPathView>(canvas->root(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setPathItemCount(10);
+ QCOMPARE(pathview->pathItemCount(), 10);
+
+ QFxRect *testItem = findItem<QFxRect>(pathview, "wrapper", 0);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QFxRect>(pathview, "wrapper", 9);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QFxRect>(pathview, "wrapper", 10);
+ QVERIFY(testItem == 0);
+
+ pathview->setCurrentIndex(50);
+ QTest::qWait(5100);//Moving is animated and it's travelling far - should be reconsidered.
+ testItem = findItem<QFxRect>(pathview, "wrapper", 0);
+ QVERIFY(testItem == 0);
+ testItem = findItem<QFxRect>(pathview, "wrapper", 1);
+ QVERIFY(testItem == 0);
+ testItem = findItem<QFxRect>(pathview, "wrapper", 9);
+ QVERIFY(testItem == 0);
+ testItem = findItem<QFxRect>(pathview, "wrapper", 50);
+ QVERIFY(testItem != 0);
+}
+
+QFxView *tst_QFxPathView::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+ canvas->setFixedSize(240,320);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setXml(xml, filename);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified id. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+*/
+template<typename T>
+T *tst_QFxPathView::findItem(QFxItem *parent, const QString &id, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->children()->count(); ++i) {
+ QFxItem *item = parent->children()->at(i);
+ if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (index != -1) {
+ QmlExpression e(item->itemContext(), "index", item);
+ e.setTrackChange(false);
+ if (e.value().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, id, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QFxPathView)
+
+#include "tst_pathview.moc"
diff --git a/tests/auto/declarative/qbindablemap/qbindablemap.pro b/tests/auto/declarative/qbindablemap/qbindablemap.pro
new file mode 100644
index 0000000..b042405
--- /dev/null
+++ b/tests/auto/declarative/qbindablemap/qbindablemap.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qbindablemap.cpp
diff --git a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
new file mode 100644
index 0000000..9519382
--- /dev/null
+++ b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
@@ -0,0 +1,72 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcontext.h>
+#include <QtDeclarative/qbindablemap.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QSignalSpy>
+
+class tst_QBindableMap : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QBindableMap() {}
+
+private slots:
+ void insert();
+ void clear();
+ void changed();
+};
+
+void tst_QBindableMap::insert()
+{
+ QBindableMap map;
+ map.setValue(QLatin1String("key1"),100);
+ map.setValue(QLatin1String("key2"),200);
+ QVERIFY(map.keys().count() == 2);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map.setValue(QLatin1String("key1"),"Hello World");
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QBindableMap::clear()
+{
+ QBindableMap map;
+ map.setValue(QLatin1String("key1"),100);
+ QVERIFY(map.keys().count() == 1);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+
+ map.clearValue(QLatin1String("key1"));
+ QVERIFY(map.keys().count() == 1);
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant());
+}
+
+void tst_QBindableMap::changed()
+{
+ QBindableMap map;
+ QSignalSpy spy(&map, SIGNAL(changed(const QString&)));
+ map.setValue(QLatin1String("key1"),100);
+ map.setValue(QLatin1String("key2"),200);
+ QCOMPARE(spy.count(), 0);
+
+ map.clearValue(QLatin1String("key1"));
+ QCOMPARE(spy.count(), 0);
+
+ //make changes in QML
+ QmlEngine engine;
+ QmlContext *ctxt = engine.rootContext();
+ ctxt->setProperty("data", &map);
+ QmlComponent component(&engine, "<Script script=\"data.key1 = 'Hello World';\"/>");
+ component.create();
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+QTEST_MAIN(tst_QBindableMap)
+
+#include "tst_qbindablemap.moc"
diff --git a/tests/auto/declarative/qfxtext/qfxtext.pro b/tests/auto/declarative/qfxtext/qfxtext.pro
new file mode 100644
index 0000000..f705334
--- /dev/null
+++ b/tests/auto/declarative/qfxtext/qfxtext.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+SOURCES += tst_qfxtext.cpp
diff --git a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
new file mode 100644
index 0000000..2448898
--- /dev/null
+++ b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
@@ -0,0 +1,412 @@
+#include <qtest.h>
+#include <QTextDocument>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxtext.h>
+#include <QFontMetrics>
+
+class tst_qfxtext : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qfxtext();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void elide();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void vAlign();
+ void font();
+ void style();
+ void color();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList styleStrings;
+ QList<QFxText::TextStyle> styles;
+
+ QStringList colorStrings;
+
+ QmlEngine engine;
+};
+
+tst_qfxtext::tst_qfxtext()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\"http://www.google.com\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\"http://www.google.com\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ hAlignmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ vAlignmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ hAlignments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ vAlignments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ styleStrings << "Normal"
+ << "Outline"
+ << "Raised"
+ << "Sunken";
+
+ styles << QFxText::Normal
+ << QFxText::Outline
+ << QFxText::Raised
+ << QFxText::Sunken;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qfxtext::text()
+{
+ {
+ QmlComponent textComponent(&engine, "<Text text=\"\" />");
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "<Text>" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), standard.at(i));
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "<Text><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), richText.at(i));
+ }
+}
+
+void tst_qfxtext::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QmlComponent textComponent(&engine, "<Text text=\"\"/>");
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 0);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetrics fm(f);
+ int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+
+ QString componentStr = "<Text>" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), metricWidth);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "<Text><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), documentWidth);
+ }
+}
+
+void tst_qfxtext::wrap()
+{
+ // XXX Poor coverage - should at least be testing an expected height.
+
+ // for specified width and wrap set true
+ {
+ QmlComponent textComponent(&engine, "<Text text=\"\" wrap=\"true\" width=\"300\"/>");
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "<Text wrap=\"true\" width=\"300\">" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "<Text wrap=\"true\" width=\"300\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+
+}
+
+void tst_qfxtext::elide()
+{
+ for (Qt::TextElideMode m = Qt::ElideLeft; m<=Qt::ElideNone; m=Qt::TextElideMode(int(m)+1)) {
+ const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
+ QString elide = "elide=\""+QString(elidename[int(m)])+"\"";
+
+ // XXX Poor coverage.
+
+ {
+ QmlComponent textComponent(&engine, ("<Text text=\"\" "+elide+" width=\"300\"/>").toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "<Text "+elide+" width=\"300\">" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+
+ // richtext - does nothing
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "<Text "+elide+" width=\"300\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->width(), 300);
+ }
+ }
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qfxtext::hAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<Text hAlign=\"" + hAlignmentStrings.at(j) + "\">" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<Text hAlign=\"" + hAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qfxtext::vAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<Text vAlign=\"" + vAlignmentStrings.at(j) + "\">" + standard.at(i) + "</Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<Text vAlign=\"" + vAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qfxtext::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "<Text font.size=\"40\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->font()->size(), qreal(40));
+ QCOMPARE(textObject->font()->bold(), false);
+ QCOMPARE(textObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<Text font.bold=\"true\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->font()->bold(), true);
+ QCOMPARE(textObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<Text font.italic=\"true\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->font()->italic(), true);
+ QCOMPARE(textObject->font()->bold(), false);
+ }
+
+ {
+ QString componentStr = "<Text font.family=\"Helvetica\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->font()->family(), QString("Helvetica"));
+ QCOMPARE(textObject->font()->bold(), false);
+ QCOMPARE(textObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<Text font.family=\"\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->font()->family(), QString(""));
+ }
+}
+
+void tst_qfxtext::style()
+{
+ //test style
+ for (int i = 0; i < styles.size(); i++)
+ {
+ QString componentStr = "<Text style=\"" + styleStrings.at(i) + "\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->style(), (int)styles.at(i));
+ QCOMPARE(textObject->styleColor(), QColor());
+ }
+}
+
+void tst_qfxtext::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "<Text color=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor());
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "<Text styleColor=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
+ // default color to black?
+ QCOMPARE(textObject->color(), QColor("black"));
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ for (int j = 0; j < colorStrings.size(); j++)
+ {
+ QString componentStr = "<Text color=\"" + colorStrings.at(i) + "\" styleColor=\"" + colorStrings.at(j) + "\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
+ }
+ }
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "<Text color=\"" + colorStr + "\" text=\"Hello World\"/>";
+ QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), testColor);
+ }
+}
+QTEST_MAIN(tst_qfxtext)
+
+#include "tst_qfxtext.moc"
diff --git a/tests/auto/declarative/qfxtextedit/qfxtextedit.pro b/tests/auto/declarative/qfxtextedit/qfxtextedit.pro
new file mode 100644
index 0000000..59ab6e5
--- /dev/null
+++ b/tests/auto/declarative/qfxtextedit/qfxtextedit.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+SOURCES += tst_qfxtextedit.cpp
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
new file mode 100644
index 0000000..e988918
--- /dev/null
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -0,0 +1,326 @@
+#include <qtest.h>
+#include <QTextDocument>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxtextedit.h>
+#include <QFontMetrics>
+
+class tst_qfxtextedit : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qfxtextedit();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void vAlign();
+ void font();
+ void color();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList colorStrings;
+
+ QmlEngine engine;
+};
+
+tst_qfxtextedit::tst_qfxtextedit()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\"http://www.google.com\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\"http://www.google.com\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ hAlignmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ vAlignmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ hAlignments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ vAlignments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qfxtextedit::text()
+{
+ {
+ QmlComponent texteditComponent(&engine, "<TextEdit text=\"\" />");
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "<TextEdit>" + standard.at(i) + "</TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "<TextEdit><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+ }
+}
+
+void tst_qfxtextedit::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QmlComponent texteditComponent(&engine, "<TextEdit text=\"\"/>");
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), 0);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetrics fm(f);
+ int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+
+ QString componentStr = "<TextEdit>" + standard.at(i) + "</TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), metricWidth);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "<TextEdit><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), documentWidth);
+ }
+}
+
+void tst_qfxtextedit::wrap()
+{
+ // for specified width and wrap set true
+ {
+ QmlComponent texteditComponent(&engine, "<TextEdit text=\"\" wrap=\"true\" width=\"300\"/>");
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), 300);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "<TextEdit wrap=\"true\" width=\"300\">" + standard.at(i) + "</TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), 300);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "<TextEdit wrap=\"true\" width=\"300\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->width(), 300);
+ }
+
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qfxtextedit::hAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<TextEdit hAlign=\"" + hAlignmentStrings.at(j) + "\">" + standard.at(i) + "</TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<TextEdit hAlign=\"" + hAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qfxtextedit::vAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<TextEdit vAlign=\"" + vAlignmentStrings.at(j) + "\">" + standard.at(i) + "</TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "<TextEdit vAlign=\"" + vAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qfxtextedit::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "<TextEdit font.size=\"40\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->font()->size(), qreal(40));
+ QCOMPARE(textEditObject->font()->bold(), false);
+ QCOMPARE(textEditObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<TextEdit font.bold=\"true\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->font()->bold(), true);
+ QCOMPARE(textEditObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<TextEdit font.italic=\"true\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->font()->italic(), true);
+ QCOMPARE(textEditObject->font()->bold(), false);
+ }
+
+ {
+ QString componentStr = "<TextEdit font.family=\"Helvetica\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->font()->family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font()->bold(), false);
+ QCOMPARE(textEditObject->font()->italic(), false);
+ }
+
+ {
+ QString componentStr = "<TextEdit font.family=\"\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->font()->family(), QString(""));
+ }
+}
+
+void tst_qfxtextedit::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "<TextEdit color=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "<TextEdit color=\"" + colorStr + "\" text=\"Hello World\"/>";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+
+ QCOMPARE(textEditObject->color(), testColor);
+ }
+}
+QTEST_MAIN(tst_qfxtextedit)
+
+#include "tst_qfxtextedit.moc"
diff --git a/tests/auto/declarative/qmlbindengine/qmlbindengine.pro b/tests/auto/declarative/qmlbindengine/qmlbindengine.pro
new file mode 100644
index 0000000..6d84931
--- /dev/null
+++ b/tests/auto/declarative/qmlbindengine/qmlbindengine.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qmlbindengine.cpp
diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
new file mode 100644
index 0000000..f5b32e8
--- /dev/null
+++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
@@ -0,0 +1,123 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmlengine.h>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool trueProperty READ trueProperty)
+ Q_PROPERTY(bool falseProperty READ falseProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+public:
+ MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false) {}
+
+ bool trueProperty() const { return true; }
+ bool falseProperty() const { return false; }
+
+ QString stringProperty() const { return m_string; }
+ void setStringProperty(const QString &s) { m_string = s; }
+
+ bool methodCalled() const { return m_methodCalled; }
+ bool methodIntCalled() const { return m_methodIntCalled; }
+
+ QString string() const { return m_string; }
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c);
+
+public slots:
+ void method() { m_methodCalled = true; }
+ void method(int a) { if(a == 163) m_methodIntCalled = true; }
+ void setString(const QString &s) { m_string = s; }
+
+private:
+ friend class tst_qmlbindengine;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QString m_string;
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+QML_DEFINE_TYPE(MyQmlObject,MyQmlObject);
+
+class tst_qmlbindengine : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlbindengine() {}
+
+private slots:
+ void boolPropertiesEvaluateAsBool();
+ void methods();
+ void signalAssignment();
+
+private:
+ QmlEngine engine;
+};
+
+void tst_qmlbindengine::boolPropertiesEvaluateAsBool()
+{
+ {
+ QmlComponent component(&engine, "<MyQmlObject stringProperty=\"{trueProperty?'pass':'fail'}\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+ {
+ QmlComponent component(&engine, "<MyQmlObject stringProperty=\"{falseProperty?'fail':'pass'}\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+}
+
+void tst_qmlbindengine::signalAssignment()
+{
+ {
+ QmlComponent component(&engine, "<MyQmlObject onBasicSignal=\"setString('pass')\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->basicSignal();
+ QCOMPARE(object->string(), QString("pass"));
+ }
+
+ {
+ QmlComponent component(&engine, "<MyQmlObject onArgumentSignal=\"setString('pass ' + a + ' ' + b + ' ' + c)\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->argumentSignal(19, "Hello world!", 10.3);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
+ }
+}
+
+void tst_qmlbindengine::methods()
+{
+ {
+ QmlComponent component(&engine, "<MyQmlObject id=\"MyObject\" onBasicSignal=\"MyObject.method()\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), true);
+ QCOMPARE(object->methodIntCalled(), false);
+ }
+
+ {
+ QmlComponent component(&engine, "<MyQmlObject id=\"MyObject\" onBasicSignal=\"MyObject.method(163)\" />");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), true);
+ }
+}
+
+QTEST_MAIN(tst_qmlbindengine)
+
+#include "tst_qmlbindengine.moc"
diff --git a/tests/auto/declarative/qmllist/qmllist.pro b/tests/auto/declarative/qmllist/qmllist.pro
new file mode 100644
index 0000000..e5558f1
--- /dev/null
+++ b/tests/auto/declarative/qmllist/qmllist.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qmllist.cpp
diff --git a/tests/auto/declarative/qmllist/tst_qmllist.cpp b/tests/auto/declarative/qmllist/tst_qmllist.cpp
new file mode 100644
index 0000000..541ca64
--- /dev/null
+++ b/tests/auto/declarative/qmllist/tst_qmllist.cpp
@@ -0,0 +1,38 @@
+#include <qtest.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlprivate.h>
+
+class tst_QmlList : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QmlList() {}
+
+private slots:
+ void interface();
+};
+
+void tst_QmlList::interface()
+{
+ QmlConcreteList<QObject*> list;
+ QObject *obj = new QObject;
+ obj->setObjectName("foo");
+ list.append(obj);
+ QVERIFY(list.count() == 1);
+ QCOMPARE(list.at(0), obj);
+
+ QmlPrivate::ListInterface *li = (QmlPrivate::ListInterface*)&list;
+
+ void *ptr[1];
+ li->at(0, ptr);
+ QVERIFY(li->count() == 1);
+ QCOMPARE(ptr[0], obj);
+
+ li->removeAt(0);
+ QVERIFY(li->count() == 0);
+ QVERIFY(list.count() == 0);
+}
+
+QTEST_MAIN(tst_QmlList)
+
+#include "tst_qmllist.moc"
diff --git a/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro b/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
new file mode 100644
index 0000000..4aa0450
--- /dev/null
+++ b/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qmllistaccessor.cpp
diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
new file mode 100644
index 0000000..f5b57ea
--- /dev/null
+++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
@@ -0,0 +1,61 @@
+#include <qtest.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmllistaccessor.h>
+
+class tst_QmlListAccessor : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QmlListAccessor() {}
+
+private slots:
+ void qmllist();
+ //void qlist();
+ //void qstringlist();
+};
+
+void tst_QmlListAccessor::qmllist()
+{
+ QmlConcreteList<QObject*> list;
+ QObject *obj = new QObject;
+ list.append(obj);
+ QVERIFY(list.count() == 1);
+ QCOMPARE(list.at(0), obj);
+
+ QmlListAccessor accessor;
+ accessor.setList(qVariantFromValue((QmlList<QObject*>*)&list));
+
+ QVERIFY(accessor.isValid());
+ QVERIFY(accessor.count() == 1);
+
+ QVariant v = accessor.at(0);
+ QCOMPARE(qvariant_cast<QObject*>(v), obj);
+
+ accessor.removeAt(3);
+ QVERIFY(accessor.count() == 1);
+
+ accessor.removeAt(0);
+ QVERIFY(accessor.count() == 0);
+
+ accessor.insert(4, qVariantFromValue(obj));
+ QVERIFY(accessor.count() == 1);
+
+ v = accessor.at(0);
+ QCOMPARE(qvariant_cast<QObject*>(v), obj);
+
+ QObject *obj2 = new QObject;
+ accessor.append(qVariantFromValue(obj2));
+ QVERIFY(accessor.count() == 2);
+
+ v = accessor.at(1);
+ QCOMPARE(qvariant_cast<QObject*>(v), obj2);
+
+ accessor.clear();
+ QVERIFY(accessor.count() == 0);
+
+ QVERIFY(accessor.isValid());
+}
+
+QTEST_MAIN(tst_QmlListAccessor)
+
+#include "tst_qmllistaccessor.moc"
diff --git a/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
new file mode 100644
index 0000000..af67373
--- /dev/null
+++ b/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qmlmetaproperty.cpp
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
new file mode 100644
index 0000000..3a87070
--- /dev/null
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -0,0 +1,104 @@
+#include <qtest.h>
+#include <QtDeclarative/QmlEngine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmlmetaproperty.h>
+#include <QtGui/QLineEdit>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyQmlObject() {}
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+QML_DEFINE_TYPE(MyQmlObject,MyQmlObject);
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<MyQmlObject*>* children READ children)
+ Q_PROPERTY(QmlList<MyQmlObject*>* qmlChildren READ qmlChildren)
+public:
+ MyContainer() {}
+
+ QList<MyQmlObject*> *children() { return &m_children; }
+ QmlConcreteList<MyQmlObject *> *qmlChildren() { return &m_qmlChildren; }
+
+private:
+ QList<MyQmlObject*> m_children;
+ QmlConcreteList<MyQmlObject *> m_qmlChildren;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+QML_DEFINE_TYPE(MyContainer,MyContainer);
+
+class tst_QmlMetaProperty : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QmlMetaProperty() {}
+
+private slots:
+ void writeObjectToList();
+ void writeListToList();
+ void writeObjectToQmlList();
+
+ //writeToReadOnly();
+
+private:
+ QmlEngine engine;
+};
+
+void tst_QmlMetaProperty::writeObjectToList()
+{
+ QmlComponent containerComponent(&engine, "<MyContainer><children><MyQmlObject/></children></MyContainer>");
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->children()->size() == 1);
+
+ MyQmlObject *object = new MyQmlObject;
+ QmlMetaProperty prop(container, "children");
+ prop.write(qVariantFromValue(object));
+ QCOMPARE(container->children()->size(), 2);
+ QCOMPARE(container->children()->at(1), object);
+}
+
+Q_DECLARE_METATYPE(QList<QObject *>);
+void tst_QmlMetaProperty::writeListToList()
+{
+ QmlComponent containerComponent(&engine, "<MyContainer><children><MyQmlObject/></children></MyContainer>");
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->children()->size() == 1);
+
+ QList<QObject*> objList;
+ objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
+ QmlMetaProperty prop(container, "children");
+ prop.write(qVariantFromValue(objList));
+ QCOMPARE(container->children()->size(), 4);
+
+ //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
+ /*QList<MyQmlObject*> typedObjList;
+ typedObjList << new MyQmlObject();
+ prop.write(qVariantFromValue(&typedObjList));
+ QCOMPARE(container->children()->size(), 1);*/
+}
+
+void tst_QmlMetaProperty::writeObjectToQmlList()
+{
+ QmlComponent containerComponent(&engine, "<MyContainer><qmlChildren><MyQmlObject/></qmlChildren></MyContainer>");
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->qmlChildren()->size() == 1);
+
+ MyQmlObject *object = new MyQmlObject;
+ QmlMetaProperty prop(container, "qmlChildren");
+ prop.write(qVariantFromValue(object));
+ QCOMPARE(container->qmlChildren()->size(), 2);
+ QCOMPARE(container->qmlChildren()->at(1), object);
+}
+
+QTEST_MAIN(tst_QmlMetaProperty)
+
+#include "tst_qmlmetaproperty.moc"
diff --git a/tests/auto/declarative/qmlparser/qmlparser.pro b/tests/auto/declarative/qmlparser/qmlparser.pro
new file mode 100644
index 0000000..3e0b6ea
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/qmlparser.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qmlparser.cpp
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
new file mode 100644
index 0000000..24d3c22
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -0,0 +1,444 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+
+class MyInterface
+{
+public:
+ MyInterface() : id(913) {}
+ int id;
+};
+
+Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+QML_DECLARE_INTERFACE(MyInterface);
+QML_DEFINE_INTERFACE(MyInterface);
+
+class MyQmlObject : public QObject, public MyInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(QString readOnlyString READ readOnlyString)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect)
+ Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
+ Q_PROPERTY(MyInterface *interface READ interface WRITE setInterface)
+ Q_INTERFACES(MyInterface)
+public:
+ MyQmlObject() : m_value(-1), m_interface(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ QString readOnlyString() const { return QLatin1String(""); }
+
+ bool enabled() const { return false; }
+ void setEnabled(bool) {}
+
+ QRect rect() const { return QRect(); }
+ void setRect(const QRect&) {}
+
+ QMatrix matrix() const { return QMatrix(); }
+ void setMatrix(const QMatrix&) {}
+
+ MyInterface *interface() const { return m_interface; }
+ void setInterface(MyInterface *iface) { m_interface = iface; }
+
+ Q_CLASSINFO("defaultMethod", "basicSlot()");
+
+public slots:
+ void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
+
+signals:
+ void basicSignal();
+
+private:
+ friend class tst_qmlparser;
+ int m_value;
+ MyInterface *m_interface;
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+QML_DEFINE_TYPE(MyQmlObject,MyQmlObject);
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<QObject*>* children READ children)
+ Q_PROPERTY(QList<MyInterface*>* qlistInterfaces READ qlistInterfaces)
+ Q_PROPERTY(QmlList<MyInterface*>* qmllistInterfaces READ qmllistInterfaces)
+ Q_CLASSINFO("DefaultProperty", "children");
+public:
+ MyContainer() {}
+
+ QList<QObject*> *children() { return &m_children; }
+ QList<MyInterface *> *qlistInterfaces() { return &m_interfaces; }
+ QmlList<MyInterface *> *qmllistInterfaces() { return &m_qmlinterfaces; }
+ const QmlConcreteList<MyInterface *> &qmllistAccessor() const { return m_qmlinterfaces; }
+
+private:
+ QList<QObject*> m_children;
+ QList<MyInterface *> m_interfaces;
+ QmlConcreteList<MyInterface *> m_qmlinterfaces;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+QML_DEFINE_TYPE(MyContainer,MyContainer);
+
+class MyDotPropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyQmlObject *obj READ obj)
+ Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
+public:
+ MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
+ ~MyDotPropertyObject()
+ {
+ if (m_ownRWObj)
+ delete m_rwobj;
+ }
+
+ MyQmlObject *obj() { return 0; }
+
+ MyQmlObject *readWriteObj()
+ {
+ if (!m_rwobj) {
+ m_rwobj = new MyQmlObject;
+ m_ownRWObj = true;
+ }
+ return m_rwobj;
+ }
+
+ void setReadWriteObj(MyQmlObject *obj)
+ {
+ if (m_ownRWObj) {
+ delete m_rwobj;
+ m_ownRWObj = false;
+ }
+
+ m_rwobj = obj;
+ }
+
+private:
+ MyQmlObject *m_rwobj;
+ bool m_ownRWObj;
+};
+
+QML_DECLARE_TYPE(MyDotPropertyObject);
+QML_DEFINE_TYPE(MyDotPropertyObject,MyDotPropertyObject);
+
+class tst_qmlparser : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlparser() {}
+
+private slots:
+ void simpleObject();
+ void simpleContainer();
+ void unregisteredObject();
+ void nonexistantProperty();
+ void unsupportedProperty();
+ //void setProperties();
+ void wrongType();
+ void readOnly();
+ //void dotProperties();
+ void nullDotProperty();
+ void fakeDotProperty();
+ //void readWriteDotProperty();
+ void emptyInput();
+ void missingObject();
+ void invalidXML();
+ void duplicateIDs();
+ void invalidID();
+ void interfaceProperty();
+ void interfaceQmlList();
+ void interfaceQList();
+ void cannotAssignBindingToSignal();
+ void assignObjectToSignal();
+
+private:
+ QmlEngine engine;
+};
+
+void tst_qmlparser::simpleObject()
+{
+ QmlComponent component(&engine, "<MyQmlObject/>");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qmlparser::simpleContainer()
+{
+ QmlComponent component(&engine, "<MyContainer>\n<MyQmlObject/>\n<MyQmlObject/>\n</MyContainer>");
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->children()->count(),2);
+}
+
+void tst_qmlparser::unregisteredObject()
+{
+ QmlComponent component(&engine, "<UnRegisteredObject/>", QUrl("myprogram.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Unable to create object of type 'UnRegisteredObject' @myprogram.qml:1");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::nonexistantProperty()
+{
+ //NOTE: these first 3 should all have the same error message
+ {
+ QmlComponent component(&engine, "<MyQmlObject something=\"24\"/>");
+ QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ {
+ QmlComponent component(&engine, "<MyQmlObject>\n<something>24</something>\n</MyQmlObject>");
+ QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:2");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ //non-existant using binding
+ {
+ QmlComponent component(&engine, "<MyQmlObject something=\"{1}\"/>");
+ QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ {
+ QmlComponent component(&engine, "<MyQmlObject><something></something></MyQmlObject>");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ }
+
+ //non-existant value-type default property
+ {
+ QmlComponent component(&engine, "<MyQmlObject>\n24\n</MyQmlObject>");
+ QTest::ignoreMessage(QtWarningMsg, "Unable to resolve default property @<unspecified file>:3");
+ // XXX would 2 be a better line number in this case? Message should also be improved.
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ //non-existant object-type default property
+ {
+ QmlComponent component(&engine, "<MyQmlObject>\n<MyQmlObject/>\n</MyQmlObject>");
+ QTest::ignoreMessage(QtWarningMsg, "Unable to assign to non-existant property @<unspecified file>:2");
+ // XXX Message needs to be improved (and should be closer to value-type message).
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+}
+
+void tst_qmlparser::unsupportedProperty()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Property 'matrix' is of an unknown type @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject matrix=\"1,0,0,0,1,0,0,0,1\"/>");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::wrongType()
+{
+ //string for int
+ {
+ QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'value' @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject value=\"hello\"/>");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object == 0);
+ }
+
+ //int for bool
+ {
+ QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5' to property 'enabled' @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject enabled=\"5\"/>");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object == 0);
+ }
+
+ //bad format for rect
+ {
+ QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5,5x10' to property 'rect' @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject rect=\"5,5x10\"/>");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object == 0);
+ }
+
+ //TODO: more types (including float-to-int, complex types, etc)
+}
+
+void tst_qmlparser::readOnly()
+{
+ {
+ QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject readOnlyString=\"hello\"/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ {
+ QTest::ignoreMessage(QtWarningMsg, "Can't assign a binding to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject readOnlyString=\"{'hello'}\"/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+}
+
+void tst_qmlparser::nullDotProperty()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'obj' because it is null @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyDotPropertyObject obj.value=\"1\"/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::fakeDotProperty()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'value' because it isn't a known object type @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject value.something=\"hello\"/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+//XXX need to define correct behavior first
+/*void tst_qmlparser::readWriteDotProperty()
+{
+ QmlComponent component(&engine, "<MyDotPropertyObject readWriteObj.value=\"1\"/>");
+ MyDotPropertyObject *object = qobject_cast<MyDotPropertyObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->readWriteObj()->value(),1);
+
+ {
+ QmlComponent component(&engine, "<MyContainer><MyQmlObject id=\"Obj\" value=\"1\"/><MyDotPropertyObject readWriteObj=\"{Obj}\"/></MyContainer>");
+ MyContainer *object = qobject_cast<MyContainer*>(component.create());
+ QVERIFY(object != 0);
+ MyDotPropertyObject *dpo = qobject_cast<MyDotPropertyObject *>(object->children()->at(1));
+ QCOMPARE(dpo->readWriteObj()->value(),1);
+ }
+}*/
+
+void tst_qmlparser::emptyInput()
+{
+ QTest::ignoreMessage(QtCriticalMsg, "No Qml was specified for parsing.");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
+ QmlComponent component(&engine, "");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::missingObject()
+{
+ QTest::ignoreMessage(QtCriticalMsg, "Can't have a property with no object @<unspecified file>:1");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
+ QmlComponent component(&engine, "<something/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+
+void tst_qmlparser::invalidXML()
+{
+ //extra stuff on end
+ {
+ QTest::ignoreMessage(QtCriticalMsg, "Extra content at end of document. @myprogram.qml:1");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
+ QmlComponent component(&engine, "<MyQmlObject/><something/>", QUrl("myprogram.qml"));
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ //mismatched tags
+ {
+ QTest::ignoreMessage(QtCriticalMsg, "Opening and ending tag mismatch. @myprogram.qml:2");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
+ QmlComponent component(&engine, "<MyQmlObject>\n</MyContainer>", QUrl("myprogram.qml"));
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ {
+ QTest::ignoreMessage(QtCriticalMsg, "Expected '>' or '/', but got '<'. @myprogram.qml:1");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
+ QmlComponent component(&engine, "<MyQmlObject < />", QUrl("myprogram.qml"));
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ {
+ QTest::ignoreMessage(QtCriticalMsg, "Premature end of document. @myprogram.qml:1");
+ QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
+ QmlComponent component(&engine, "<MyQmlObject something=\" />", QUrl("myprogram.qml"));
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+}
+
+void tst_qmlparser::duplicateIDs()
+{
+ QTest::ignoreMessage(QtWarningMsg, "An id (\"MyID\") is not unique within its scope. @<unspecified file>:3");
+ QmlComponent component(&engine, "<MyContainer>\n<MyQmlObject id=\"MyID\"/>\n<MyQmlObject id=\"MyID\"/>\n</MyContainer>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::invalidID()
+{
+ QTest::ignoreMessage(QtWarningMsg, "'1' is not a valid id @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject id=\"1\"/>");
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+}
+
+void tst_qmlparser::interfaceProperty()
+{
+ QmlComponent component(&engine, "<MyQmlObject><interface>\n<MyQmlObject/></interface>\n</MyQmlObject>");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->interface());
+ QVERIFY(object->interface()->id == 913);
+}
+
+void tst_qmlparser::interfaceQmlList()
+{
+ QmlComponent component(&engine, "<MyContainer><qmllistInterfaces>\n<MyQmlObject/>\n<MyQmlObject/>\n</qmllistInterfaces>\n</MyContainer>");
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->qmllistAccessor().count() == 2);
+ for(int ii = 0; ii < 2; ++ii)
+ QVERIFY(container->qmllistAccessor().at(ii)->id == 913);
+}
+
+void tst_qmlparser::interfaceQList()
+{
+ QmlComponent component(&engine, "<MyContainer><qlistInterfaces>\n<MyQmlObject/>\n<MyQmlObject/>\n</qlistInterfaces>\n</MyContainer>");
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->qlistInterfaces()->count() == 2);
+ for(int ii = 0; ii < 2; ++ii)
+ QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
+}
+
+void tst_qmlparser::cannotAssignBindingToSignal()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Cannot assign binding to signal property @<unspecified file>:1");
+ QmlComponent component(&engine, "<MyQmlObject onBasicSignal=\"{print(1921)}\" />");
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container == 0);
+}
+
+void tst_qmlparser::assignObjectToSignal()
+{
+ QmlComponent component(&engine, "<MyQmlObject><onBasicSignal><MyQmlObject /></onBasicSignal></MyQmlObject>");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+}
+
+QTEST_MAIN(tst_qmlparser)
+
+#include "tst_qmlparser.moc"
diff --git a/tests/auto/declarative/repeater/data/repeater.xml b/tests/auto/declarative/repeater/data/repeater.xml
new file mode 100644
index 0000000..f863716
--- /dev/null
+++ b/tests/auto/declarative/repeater/data/repeater.xml
@@ -0,0 +1,7 @@
+<Rect id="container" width="240" height="320" color="white">
+ <Repeater id="repeater" width="240" height="320" dataSource="{testData}">
+ <Component>
+ <Text y="{index*20}" text="{modelData}"/>
+ </Component>
+ </Repeater>
+</Rect>
diff --git a/tests/auto/declarative/repeater/repeater.pro b/tests/auto/declarative/repeater/repeater.pro
new file mode 100644
index 0000000..0ecd7ee
--- /dev/null
+++ b/tests/auto/declarative/repeater/repeater.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_repeater.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
new file mode 100644
index 0000000..cdf1716
--- /dev/null
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -0,0 +1,91 @@
+#include <QtTest/QtTest>
+#include <qlistmodelinterface.h>
+#include <qfxview.h>
+#include <qfxrepeater.h>
+#include <qfxtext.h>
+#include <qmlcontext.h>
+
+class tst_QFxRepeater : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QFxRepeater();
+
+private slots:
+ void stringList();
+
+private:
+ QFxView *createView(const QString &filename);
+ template<typename T>
+ T *findItem(QFxItem *parent, const QString &id);
+};
+
+tst_QFxRepeater::tst_QFxRepeater()
+{
+}
+
+void tst_QFxRepeater::stringList()
+{
+ QFxView *canvas = createView(SRCDIR "/data/repeater.xml");
+
+ QStringList data;
+ data << "One";
+ data << "Two";
+ data << "Three";
+ data << "Four";
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setProperty("testData", data);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QFxRepeater *repeater = findItem<QFxRepeater>(canvas->root(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QFxItem *container = findItem<QFxItem>(canvas->root(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->children()->count(), data.count() + 1);
+
+ for (int i = 1; i < container->children()->count(); ++i) {
+ QFxText *name = qobject_cast<QFxText*>(container->children()->at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-1));
+ }
+
+ delete canvas;
+}
+
+
+QFxView *tst_QFxRepeater::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+ canvas->setFixedSize(240,320);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setXml(xml, filename);
+
+ return canvas;
+}
+
+template<typename T>
+T *tst_QFxRepeater::findItem(QFxItem *parent, const QString &id)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ if (mo.cast(parent) && (id.isEmpty() || parent->id() == id))
+ return static_cast<T*>(parent);
+ for (int i = 0; i < parent->children()->count(); ++i) {
+ QFxItem *item = findItem<T>(parent->children()->at(i), id);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QFxRepeater)
+
+#include "tst_repeater.moc"
diff --git a/tests/auto/declarative/simplecanvasitem/data/test.xml b/tests/auto/declarative/simplecanvasitem/data/test.xml
new file mode 100644
index 0000000..9b8f10a
--- /dev/null
+++ b/tests/auto/declarative/simplecanvasitem/data/test.xml
@@ -0,0 +1,12 @@
+<Item width="320" height="480">
+ <Rect color="blue" x="20" y="20" width="20" height="20">
+ <Rect color="black" x="20" y="20" width="10" height="10"/>
+ </Rect>
+ <Rect color="red" x="40" y="20" width="20" height="20"/>
+ <Rect color="green" x="60" y="20" width="20" height="20"/>
+ <Rect color="yellow" x="20" y="40" width="20" height="20"/>
+ <Rect color="purple" x="20" y="60" width="20" height="20"/>
+ <Rect color="white" x="40" y="40" width="20" height="20"/>
+ <Rect anchors.fill="{parent}" color="gray" z="-1"/>
+</Item>
+
diff --git a/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro b/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
new file mode 100644
index 0000000..114be8e
--- /dev/null
+++ b/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_simplecanvasitem.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
new file mode 100644
index 0000000..47608a0
--- /dev/null
+++ b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
@@ -0,0 +1,79 @@
+#include <QtTest/QtTest>
+#include <qfxview.h>
+#include <qfxitem.h>
+#include <qsimplecanvasitem.h>
+
+/*
+ Note: this autotest is specifically to test SimpleCanvasItem as a component of
+ Qt Declarative, and therefore will have all items created in XML.
+*/
+class tst_SimpleCanvasItem : public QObject
+{
+ Q_OBJECT
+public:
+ tst_SimpleCanvasItem();
+
+private slots:
+ void test_pos();
+ void test_scenePos();
+private:
+ QFxView *createView(const QString &filename);
+};
+
+tst_SimpleCanvasItem::tst_SimpleCanvasItem()
+{
+}
+
+void tst_SimpleCanvasItem::test_pos()
+{
+ QFxView *canvas = createView(SRCDIR "/data/test.xml");
+ canvas->execute();
+ qApp->processEvents();
+ QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
+ QVERIFY(root);
+
+ QCOMPARE(root->pos(), QPointF(0,0));
+ QCOMPARE(root->children().at(0)->pos(), QPointF(20,20));
+ QCOMPARE(root->children().at(0)->children().at(0)->pos(), QPointF(20,20));
+ QCOMPARE(root->children().at(2)->pos(), QPointF(60,20));
+ QCOMPARE(root->children().at(3)->pos(), QPointF(20,40));
+ QCOMPARE(root->children().at(5)->pos(), QPointF(40,40));
+}
+
+void tst_SimpleCanvasItem::test_scenePos()
+{
+ QFxView *canvas = createView(SRCDIR "/data/test.xml");
+ canvas->execute();
+ qApp->processEvents();
+ QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
+ QVERIFY(root);
+
+#ifdef CANVAS_GL
+ QCOMPARE(root->transform(), QMatrix4x4());
+#else
+ QCOMPARE(root->transform(), QTransform());
+#endif
+ QCOMPARE(root->scenePos(), QPointF(0,0));
+ QCOMPARE(root->children().at(0)->scenePos(), QPointF(20,20));
+ QCOMPARE(root->children().at(0)->children().at(0)->scenePos(), QPointF(40,40));
+ QCOMPARE(root->children().at(2)->scenePos(), QPointF(60,20));
+ QCOMPARE(root->children().at(3)->scenePos(), QPointF(20,40));
+ QCOMPARE(root->children().at(5)->scenePos(), QPointF(40,40));
+}
+
+QFxView *tst_SimpleCanvasItem::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+ canvas->setFixedSize(240,320);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setXml(xml, filename);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_SimpleCanvasItem)
+
+#include "tst_simplecanvasitem.moc"
diff --git a/tests/auto/declarative/visual/ListView/basic1/basic1.xml b/tests/auto/declarative/visual/ListView/basic1/basic1.xml
new file mode 100644
index 0000000..5038c0a
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic1/basic1.xml
@@ -0,0 +1,19 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <ListView anchors.fill="{parent}">
+ <delegate>
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </delegate>
+ <model>
+ <ListModel>
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ </model>
+ </ListView>
+</Rect>
diff --git a/tests/auto/declarative/visual/ListView/basic1/data/opengl/image0.png b/tests/auto/declarative/visual/ListView/basic1/data/opengl/image0.png
new file mode 100644
index 0000000..403b407
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic1/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/ListView/basic1/data/opengl/manifest.xml b/tests/auto/declarative/visual/ListView/basic1/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic1/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/ListView/basic1/test b/tests/auto/declarative/visual/ListView/basic1/test
new file mode 100644
index 0000000..62f0665
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic1/test
@@ -0,0 +1 @@
+basic1.xml
diff --git a/tests/auto/declarative/visual/ListView/basic2/basic2.xml b/tests/auto/declarative/visual/ListView/basic2/basic2.xml
new file mode 100644
index 0000000..5e139fe
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic2/basic2.xml
@@ -0,0 +1,20 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <Component id="Delegate">
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </Component>
+
+ <ListView anchors.fill="{parent}" delegate="{Delegate}">
+ <model>
+ <ListModel>
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ </model>
+ </ListView>
+</Rect>
diff --git a/tests/auto/declarative/visual/ListView/basic2/data/opengl/image0.png b/tests/auto/declarative/visual/ListView/basic2/data/opengl/image0.png
new file mode 100644
index 0000000..403b407
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic2/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/ListView/basic2/data/opengl/manifest.xml b/tests/auto/declarative/visual/ListView/basic2/data/opengl/manifest.xml
new file mode 100644
index 0000000..f3fa6c9
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic2/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="31" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/ListView/basic2/test b/tests/auto/declarative/visual/ListView/basic2/test
new file mode 100644
index 0000000..ae974fe
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic2/test
@@ -0,0 +1 @@
+basic2.xml
diff --git a/tests/auto/declarative/visual/ListView/basic3/basic3.xml b/tests/auto/declarative/visual/ListView/basic3/basic3.xml
new file mode 100644
index 0000000..a587b82
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic3/basic3.xml
@@ -0,0 +1,18 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <ListModel id="Model">
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+
+ <ListView anchors.fill="{parent}" model="{Model}">
+ <delegate>
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </delegate>
+ </ListView>
+</Rect>
diff --git a/tests/auto/declarative/visual/ListView/basic3/data/opengl/image0.png b/tests/auto/declarative/visual/ListView/basic3/data/opengl/image0.png
new file mode 100644
index 0000000..403b407
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic3/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/ListView/basic3/data/opengl/manifest.xml b/tests/auto/declarative/visual/ListView/basic3/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic3/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/ListView/basic3/test b/tests/auto/declarative/visual/ListView/basic3/test
new file mode 100644
index 0000000..ea3154e
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic3/test
@@ -0,0 +1 @@
+basic3.xml
diff --git a/tests/auto/declarative/visual/ListView/basic4/basic4.xml b/tests/auto/declarative/visual/ListView/basic4/basic4.xml
new file mode 100644
index 0000000..4b9201c
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic4/basic4.xml
@@ -0,0 +1,19 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <ListModel id="Model">
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+
+ <Component id="Delegate">
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </Component>
+
+ <ListView anchors.fill="{parent}" model="{Model}" delegate="{Delegate}">
+ </ListView>
+</Rect>
diff --git a/tests/auto/declarative/visual/ListView/basic4/data/opengl/image0.png b/tests/auto/declarative/visual/ListView/basic4/data/opengl/image0.png
new file mode 100644
index 0000000..403b407
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic4/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/ListView/basic4/data/opengl/manifest.xml b/tests/auto/declarative/visual/ListView/basic4/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic4/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/ListView/basic4/test b/tests/auto/declarative/visual/ListView/basic4/test
new file mode 100644
index 0000000..891e0be
--- /dev/null
+++ b/tests/auto/declarative/visual/ListView/basic4/test
@@ -0,0 +1 @@
+basic4.xml
diff --git a/tests/auto/declarative/visual/bindinganimation/bindinganimation.xml b/tests/auto/declarative/visual/bindinganimation/bindinganimation.xml
new file mode 100644
index 0000000..30b0b6a
--- /dev/null
+++ b/tests/auto/declarative/visual/bindinganimation/bindinganimation.xml
@@ -0,0 +1,19 @@
+<Rect color="blue" width="320" height="240" id="Page">
+ <Rect id="MyRect" width="100" height="100" color="red" x="{10}" />
+
+ <states>
+ <State name="hello">
+ <SetProperty target="{MyRect}" property="x" binding="100" />
+ <SetProperty target="{MyMouseRegion}" property="onClick" value="Page.currentState = ''" />
+ </State>
+ </states>
+
+ <transitions>
+ <Transition>
+ <NumericAnimation properties="x" />
+ </Transition>
+ </transitions>
+
+ <MouseRegion id="MyMouseRegion" anchors.fill="{parent}" onClick="Page.currentState= 'hello'" />
+
+</Rect>
diff --git a/tests/auto/declarative/visual/bindinganimation/data/opengl/image0.png b/tests/auto/declarative/visual/bindinganimation/data/opengl/image0.png
new file mode 100644
index 0000000..2cda3fa
--- /dev/null
+++ b/tests/auto/declarative/visual/bindinganimation/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest-play.xml b/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest-play.xml
new file mode 100644
index 0000000..6c5856f
--- /dev/null
+++ b/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest-play.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="1770" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="1860" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="1860" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="1920" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="1950" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="1980" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="2010" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="2040" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="2070" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="2100" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="2130" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="2160" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="2190" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="2220" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="2250" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="2280" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="2310" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="2340" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="2370" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="2400" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestMouse time="2820" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="2910" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="2910" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestFrame time="2970" hash="ADC501A3A2B8AAF72F58BA985B57424E"/>
+ <TestFrame time="3000" hash="BFA51B7C19753EF7B16D78AFFFC7B9DD"/>
+ <TestFrame time="3030" hash="A93F930EC8528F954CD4A770C9A8171B"/>
+ <TestFrame time="3060" hash="0B0C6419E1E5B016D9C22BD98FD452B1"/>
+ <TestFrame time="3090" hash="1D5CD86AB732DA3705A7BB1DEAB77923"/>
+ <TestFrame time="3120" hash="69058485CED6BC992A1A7C5EE34ADD4C"/>
+ <TestFrame time="3150" hash="72731478D80F024076EA639B55152360"/>
+ <TestFrame time="3180" hash="37739777A5979F3EBF85E47E63341660"/>
+ <TestFrame time="3210" hash="FCAE0317F81A3DDD713F4DB1349A9DA0"/>
+ <TestFrame time="3240" hash="82363265ED2B611A54F8D48B2AF22F11"/>
+ <TestFrame time="3270" hash="5FAE0BDC65C609CB766CE585B8C649DB"/>
+ <TestFrame time="3300" hash="2D21B4AF3780EF2BBCCFCEC957CE49C8"/>
+ <TestFrame time="3330" hash="4AB21E266919FB8D340F87091D8E1F62"/>
+ <TestFrame time="3360" hash="5F5DA43901938FA244F536336FFD2DFC"/>
+ <TestFrame time="3390" hash="9B7685F5933C5E06883EE4D1BB2BD2C6"/>
+ <TestFrame time="3420" hash="96C077E3A572EDFF04FA9B2F7020FFD0"/>
+ <TestFrame time="3450" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestMouse time="3840" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="3930" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="3930" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="3990" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="4020" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="4050" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="4080" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="4110" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="4140" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="4170" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="4200" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="4230" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="4260" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="4290" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="4320" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="4350" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="4380" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="4410" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="4440" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="4470" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestMouse time="4920" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="5010" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="5010" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestFrame time="5070" hash="ADC501A3A2B8AAF72F58BA985B57424E"/>
+ <TestFrame time="5100" hash="BFA51B7C19753EF7B16D78AFFFC7B9DD"/>
+ <TestFrame time="5130" hash="A93F930EC8528F954CD4A770C9A8171B"/>
+ <TestFrame time="5160" hash="0B0C6419E1E5B016D9C22BD98FD452B1"/>
+ <TestFrame time="5190" hash="1D5CD86AB732DA3705A7BB1DEAB77923"/>
+ <TestFrame time="5220" hash="69058485CED6BC992A1A7C5EE34ADD4C"/>
+ <TestFrame time="5250" hash="72731478D80F024076EA639B55152360"/>
+ <TestFrame time="5280" hash="37739777A5979F3EBF85E47E63341660"/>
+ <TestFrame time="5310" hash="FCAE0317F81A3DDD713F4DB1349A9DA0"/>
+ <TestFrame time="5340" hash="82363265ED2B611A54F8D48B2AF22F11"/>
+ <TestFrame time="5370" hash="5FAE0BDC65C609CB766CE585B8C649DB"/>
+ <TestFrame time="5400" hash="2D21B4AF3780EF2BBCCFCEC957CE49C8"/>
+ <TestFrame time="5430" hash="4AB21E266919FB8D340F87091D8E1F62"/>
+ <TestFrame time="5460" hash="5F5DA43901938FA244F536336FFD2DFC"/>
+ <TestFrame time="5490" hash="9B7685F5933C5E06883EE4D1BB2BD2C6"/>
+ <TestFrame time="5520" hash="96C077E3A572EDFF04FA9B2F7020FFD0"/>
+ <TestFrame time="5550" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestMouse time="5910" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="6030" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="6030" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="6090" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="6120" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="6150" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="6180" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="6210" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="6240" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="6270" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="6300" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="6330" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="6360" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="6390" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="6420" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="6450" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="6480" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="6510" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="6540" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="6570" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest.xml b/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest.xml
new file mode 100644
index 0000000..6c5856f
--- /dev/null
+++ b/tests/auto/declarative/visual/bindinganimation/data/opengl/manifest.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="1770" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="1860" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="1860" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="1920" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="1950" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="1980" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="2010" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="2040" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="2070" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="2100" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="2130" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="2160" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="2190" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="2220" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="2250" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="2280" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="2310" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="2340" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="2370" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="2400" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestMouse time="2820" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="2910" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="2910" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestFrame time="2970" hash="ADC501A3A2B8AAF72F58BA985B57424E"/>
+ <TestFrame time="3000" hash="BFA51B7C19753EF7B16D78AFFFC7B9DD"/>
+ <TestFrame time="3030" hash="A93F930EC8528F954CD4A770C9A8171B"/>
+ <TestFrame time="3060" hash="0B0C6419E1E5B016D9C22BD98FD452B1"/>
+ <TestFrame time="3090" hash="1D5CD86AB732DA3705A7BB1DEAB77923"/>
+ <TestFrame time="3120" hash="69058485CED6BC992A1A7C5EE34ADD4C"/>
+ <TestFrame time="3150" hash="72731478D80F024076EA639B55152360"/>
+ <TestFrame time="3180" hash="37739777A5979F3EBF85E47E63341660"/>
+ <TestFrame time="3210" hash="FCAE0317F81A3DDD713F4DB1349A9DA0"/>
+ <TestFrame time="3240" hash="82363265ED2B611A54F8D48B2AF22F11"/>
+ <TestFrame time="3270" hash="5FAE0BDC65C609CB766CE585B8C649DB"/>
+ <TestFrame time="3300" hash="2D21B4AF3780EF2BBCCFCEC957CE49C8"/>
+ <TestFrame time="3330" hash="4AB21E266919FB8D340F87091D8E1F62"/>
+ <TestFrame time="3360" hash="5F5DA43901938FA244F536336FFD2DFC"/>
+ <TestFrame time="3390" hash="9B7685F5933C5E06883EE4D1BB2BD2C6"/>
+ <TestFrame time="3420" hash="96C077E3A572EDFF04FA9B2F7020FFD0"/>
+ <TestFrame time="3450" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestMouse time="3840" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="3930" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="3930" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="3990" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="4020" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="4050" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="4080" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="4110" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="4140" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="4170" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="4200" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="4230" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="4260" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="4290" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="4320" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="4350" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="4380" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="4410" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="4440" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="4470" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestMouse time="4920" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="5010" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="5010" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+ <TestFrame time="5070" hash="ADC501A3A2B8AAF72F58BA985B57424E"/>
+ <TestFrame time="5100" hash="BFA51B7C19753EF7B16D78AFFFC7B9DD"/>
+ <TestFrame time="5130" hash="A93F930EC8528F954CD4A770C9A8171B"/>
+ <TestFrame time="5160" hash="0B0C6419E1E5B016D9C22BD98FD452B1"/>
+ <TestFrame time="5190" hash="1D5CD86AB732DA3705A7BB1DEAB77923"/>
+ <TestFrame time="5220" hash="69058485CED6BC992A1A7C5EE34ADD4C"/>
+ <TestFrame time="5250" hash="72731478D80F024076EA639B55152360"/>
+ <TestFrame time="5280" hash="37739777A5979F3EBF85E47E63341660"/>
+ <TestFrame time="5310" hash="FCAE0317F81A3DDD713F4DB1349A9DA0"/>
+ <TestFrame time="5340" hash="82363265ED2B611A54F8D48B2AF22F11"/>
+ <TestFrame time="5370" hash="5FAE0BDC65C609CB766CE585B8C649DB"/>
+ <TestFrame time="5400" hash="2D21B4AF3780EF2BBCCFCEC957CE49C8"/>
+ <TestFrame time="5430" hash="4AB21E266919FB8D340F87091D8E1F62"/>
+ <TestFrame time="5460" hash="5F5DA43901938FA244F536336FFD2DFC"/>
+ <TestFrame time="5490" hash="9B7685F5933C5E06883EE4D1BB2BD2C6"/>
+ <TestFrame time="5520" hash="96C077E3A572EDFF04FA9B2F7020FFD0"/>
+ <TestFrame time="5550" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestMouse time="5910" type="2" button="1" buttons="1" globalPos="614,528" pos="175,131"/>
+ <TestMouse time="6030" type="3" button="1" buttons="0" globalPos="614,528" pos="175,131"/>
+ <TestFrame time="6030" hash="7CB5FC371040E587DE9F06CE14A4B29A"/>
+ <TestFrame time="6090" hash="8F88EE8780C32F038C9ACDC7172DE04E"/>
+ <TestFrame time="6120" hash="BE859D598C5DB953A8FC506DED4940EB"/>
+ <TestFrame time="6150" hash="16FE17B15900FF0464AB20EA921E5B1F"/>
+ <TestFrame time="6180" hash="FCB17070EF24575C61046928A8BBE440"/>
+ <TestFrame time="6210" hash="4F58226BDBDA7339D972ECA065F75766"/>
+ <TestFrame time="6240" hash="D9AF30557F99B086BB1A185A946B580D"/>
+ <TestFrame time="6270" hash="082E0E7650D187A54EF0948CCCA98E5A"/>
+ <TestFrame time="6300" hash="4F41101378A104E72228EEB4BA395CA8"/>
+ <TestFrame time="6330" hash="3223ED179C828FADB3ECA9C6373176C1"/>
+ <TestFrame time="6360" hash="DAFCCE427161A70C3513841AC22AEA00"/>
+ <TestFrame time="6390" hash="7F465A99FCA50503736E470A0B4E1C7A"/>
+ <TestFrame time="6420" hash="97542160B249135B1F3957DBBB329C2E"/>
+ <TestFrame time="6450" hash="F9F74A2E38B52C9266F33E428B6ACD9D"/>
+ <TestFrame time="6480" hash="65AD7E0189C096792331BD1BB0DAF0DB"/>
+ <TestFrame time="6510" hash="BA403842BA3128B1CDF6A9CB28C90751"/>
+ <TestFrame time="6540" hash="1BCDCD0E8166D69F4349E05D5E92FD9D"/>
+ <TestFrame time="6570" hash="383BA6B9EFCC58FCA512982A207631F6"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/bindinganimation/test b/tests/auto/declarative/visual/bindinganimation/test
new file mode 100644
index 0000000..964c489
--- /dev/null
+++ b/tests/auto/declarative/visual/bindinganimation/test
@@ -0,0 +1 @@
+bindinganimation.xml
diff --git a/tests/auto/declarative/visual/colorAnimation/colorAnimation.xml b/tests/auto/declarative/visual/colorAnimation/colorAnimation.xml
new file mode 100644
index 0000000..39d08be
--- /dev/null
+++ b/tests/auto/declarative/visual/colorAnimation/colorAnimation.xml
@@ -0,0 +1,18 @@
+<Rect id="mainrect" currentState="first">
+<states>
+ <State name="first">
+ <SetProperty target="{mainrect}" property="color" value="red"/>
+ </State>
+ <State name="second" >
+ <SetProperty target="{mainrect}" property="color" value="blue"/>
+ </State>
+</states>
+<transitions>
+ <Transition fromState="first" toState="second" reversible="true" >
+ <SerialAnimation>
+ <ColorAnimation duration="2000" target="{mainrect}" property="color" />
+ </SerialAnimation>
+ </Transition>
+</transitions>
+<MouseRegion anchors.fill="{parent}" onClick="mainrect.currentState = 'second'" />
+</Rect>
diff --git a/tests/auto/declarative/visual/colorAnimation/image0.png b/tests/auto/declarative/visual/colorAnimation/image0.png
new file mode 100644
index 0000000..9e1caf7
--- /dev/null
+++ b/tests/auto/declarative/visual/colorAnimation/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/colorAnimation/manifest-play.xml b/tests/auto/declarative/visual/colorAnimation/manifest-play.xml
new file mode 100644
index 0000000..8e3de2e
--- /dev/null
+++ b/tests/auto/declarative/visual/colorAnimation/manifest-play.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="480" type="2" button="1" buttons="1" globalPos="93,129" pos="89,102"/>
+ <TestMouse time="570" type="3" button="1" buttons="0" globalPos="93,129" pos="89,102"/>
+ <TestFrame time="630" hash="D42762ECD293C6922C5F9593126DE636"/>
+ <TestFrame time="660" hash="8962505FCCB2E7559A99A8EDD325A82B"/>
+ <TestFrame time="690" hash="6812EFDA80607D4FA05CD3A5077F8EF7"/>
+ <TestFrame time="720" hash="A116DF73809679C1C5F9261F49B989F0"/>
+ <TestFrame time="750" hash="DC1B9D40AEE306171AD6625DDCA4EB45"/>
+ <TestFrame time="780" hash="B2DAF0E4C32080229664A8B0A155DE3B"/>
+ <TestFrame time="810" hash="496677B0D8707B91566D1244C46D50DB"/>
+ <TestFrame time="840" hash="A6558D8B0D1FB1D11BEBE36C078386CE"/>
+ <TestFrame time="870" hash="601436BB436D391B0BD5FCC289666208"/>
+ <TestFrame time="900" hash="8CF3CF9EAD875497870CC7C1035802DC"/>
+ <TestFrame time="930" hash="FF6BA6BAC30DADD3DBBFD96F127EB1FE"/>
+ <TestFrame time="960" hash="1D97A2A6890078DCF4CE9E508E5F9F08"/>
+ <TestFrame time="990" hash="58C9116FDDD03DD036820EFCD0DCD392"/>
+ <TestFrame time="1020" hash="E51287B911C140B41D350FCB2091AB80"/>
+ <TestFrame time="1050" hash="7B107411B436FABE469A069E6E5B0C3C"/>
+ <TestFrame time="1080" hash="9D1CB0E58F2BD00DDA0FB463F6BFF526"/>
+ <TestFrame time="1110" hash="35AB7788489B79E5A5C6F2BE11AFC9E1"/>
+ <TestFrame time="1140" hash="C82177AC4A7A497469292C5F0F8C4913"/>
+ <TestFrame time="1170" hash="18763D1B911FDC524DB9E7B2569FE984"/>
+ <TestFrame time="1200" hash="27F63572AAEF6D835272D5D65FCF608B"/>
+ <TestFrame time="1230" hash="585727CAEC1F83ADB9E422BAF058A622"/>
+ <TestFrame time="1260" hash="2C3BBFEFBE6E5FDA1905E9F50985E1B4"/>
+ <TestFrame time="1290" hash="81675C4ABB2696D960BC5F204F05F16B"/>
+ <TestFrame time="1320" hash="6D0F3CCC06EF1E3A895ECC9A8DE90039"/>
+ <TestFrame time="1350" hash="0BF36093CCAEA8BDAE96D4939A8DDE20"/>
+ <TestFrame time="1380" hash="5A1CBC68AB59977B65492B0F8A664418"/>
+ <TestFrame time="1410" hash="C35831A8C59D56193CED2C4AADB4DFCE"/>
+ <TestFrame time="1440" hash="ED15973425A8B8528896B344A61393AA"/>
+ <TestFrame time="1470" hash="EA8FC02A8606680C089F0C0CE454ABE3"/>
+ <TestFrame time="1500" hash="CFB5CFBA0A0BC62C0D03908FB9599A8E"/>
+ <TestFrame time="1530" hash="09FAA04AFB50B48BD6A83F9E25F9DDDB"/>
+ <TestFrame time="1560" hash="0FDD0B8CDCCEB78C7C67AB0F5EA74D6A"/>
+ <TestFrame time="1590" hash="058D26146879900B5E5CCE05AE38BA0E"/>
+ <TestFrame time="1620" hash="80F9074C50F967C99D4C3A3FF9EC3E71"/>
+ <TestFrame time="1650" hash="AD9BDCEEC1C058D6B658C5BA0D0BC1F0"/>
+ <TestFrame time="1680" hash="AC14DF5458F91001181154F8C68BCE2B"/>
+ <TestFrame time="1710" hash="AE9225263E4C8E75E4D0F1D7192B4260"/>
+ <TestFrame time="1740" hash="D3D50F1B7F476E79E5B99E0E6D4CF827"/>
+ <TestFrame time="1770" hash="A1367445C5232ACCBF4904A415416EA4"/>
+ <TestFrame time="1800" hash="A21C0F1DA9B64A5B000558BA1F2E495D"/>
+ <TestFrame time="1830" hash="61AF477B6FB22E38E698375EA5793D22"/>
+ <TestFrame time="1860" hash="B3AD3501D527939CEAA4F124AB10B2DF"/>
+ <TestFrame time="1890" hash="0C2BF65A43AE87AFB0068F9FA4A74707"/>
+ <TestFrame time="1920" hash="5B7F96C797BEE4FD1B04538DE5549C1B"/>
+ <TestFrame time="1950" hash="4C861E936A3F1AFE323395E30174F8CC"/>
+ <TestFrame time="1980" hash="87F1966E5B0E924EB7CEED5520D120BF"/>
+ <TestFrame time="2010" hash="1980755E0D80469D4DC0B9B0309F2DEB"/>
+ <TestFrame time="2040" hash="38A7ACC2E5607FC0965B7B376A0D3524"/>
+ <TestFrame time="2070" hash="4434746833EFF5A3A76491024763990A"/>
+ <TestFrame time="2100" hash="A8BAD928F92E851B45723068B7FEF739"/>
+ <TestFrame time="2130" hash="A96F5C522C0ECA5C78E982E4235218CB"/>
+ <TestFrame time="2160" hash="135F0EFEDE2832B76F49966EBD629879"/>
+ <TestFrame time="2190" hash="A51C6E443413F184CAAE8A7F98A369C8"/>
+ <TestFrame time="2220" hash="62A7521EE62E6A2543B3141C1EFCE72A"/>
+ <TestFrame time="2250" hash="D416A41125659167B3E6AD68F66F6E64"/>
+ <TestFrame time="2280" hash="0F653B5E965665A43F50437724DC704C"/>
+ <TestFrame time="2310" hash="13A6E2485179501FF3AA8BA91A5050B4"/>
+ <TestFrame time="2340" hash="9423475D3832FBABEC56B80FA9161020"/>
+ <TestFrame time="2370" hash="497B21108A6CB127DB066B32D06D992A"/>
+ <TestFrame time="2400" hash="22F01CB9B4F8FF01410566A61E281373"/>
+ <TestFrame time="2430" hash="A099640BC088E14E20585CB87FC5C6F1"/>
+ <TestFrame time="2460" hash="AC2954553C333EA1D524CE51CD35958A"/>
+ <TestFrame time="2490" hash="771E882CC788BECAA82E71E6FBAB150D"/>
+ <TestFrame time="2520" hash="42CEDA45D88A8D2B3DA5B749F4C3C1BF"/>
+ <TestFrame time="2550" hash="C6E1F91B917E47246E012D1B203E0DC2"/>
+ <TestFrame time="2580" hash="EFB3E57CF265B6E36AA4DF72771D119C"/>
+ <TestFrame time="2610" hash="657FC7FD496E5A2FC84F63930E0D1DE3"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/colorAnimation/manifest.xml b/tests/auto/declarative/visual/colorAnimation/manifest.xml
new file mode 100644
index 0000000..8e3de2e
--- /dev/null
+++ b/tests/auto/declarative/visual/colorAnimation/manifest.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="480" type="2" button="1" buttons="1" globalPos="93,129" pos="89,102"/>
+ <TestMouse time="570" type="3" button="1" buttons="0" globalPos="93,129" pos="89,102"/>
+ <TestFrame time="630" hash="D42762ECD293C6922C5F9593126DE636"/>
+ <TestFrame time="660" hash="8962505FCCB2E7559A99A8EDD325A82B"/>
+ <TestFrame time="690" hash="6812EFDA80607D4FA05CD3A5077F8EF7"/>
+ <TestFrame time="720" hash="A116DF73809679C1C5F9261F49B989F0"/>
+ <TestFrame time="750" hash="DC1B9D40AEE306171AD6625DDCA4EB45"/>
+ <TestFrame time="780" hash="B2DAF0E4C32080229664A8B0A155DE3B"/>
+ <TestFrame time="810" hash="496677B0D8707B91566D1244C46D50DB"/>
+ <TestFrame time="840" hash="A6558D8B0D1FB1D11BEBE36C078386CE"/>
+ <TestFrame time="870" hash="601436BB436D391B0BD5FCC289666208"/>
+ <TestFrame time="900" hash="8CF3CF9EAD875497870CC7C1035802DC"/>
+ <TestFrame time="930" hash="FF6BA6BAC30DADD3DBBFD96F127EB1FE"/>
+ <TestFrame time="960" hash="1D97A2A6890078DCF4CE9E508E5F9F08"/>
+ <TestFrame time="990" hash="58C9116FDDD03DD036820EFCD0DCD392"/>
+ <TestFrame time="1020" hash="E51287B911C140B41D350FCB2091AB80"/>
+ <TestFrame time="1050" hash="7B107411B436FABE469A069E6E5B0C3C"/>
+ <TestFrame time="1080" hash="9D1CB0E58F2BD00DDA0FB463F6BFF526"/>
+ <TestFrame time="1110" hash="35AB7788489B79E5A5C6F2BE11AFC9E1"/>
+ <TestFrame time="1140" hash="C82177AC4A7A497469292C5F0F8C4913"/>
+ <TestFrame time="1170" hash="18763D1B911FDC524DB9E7B2569FE984"/>
+ <TestFrame time="1200" hash="27F63572AAEF6D835272D5D65FCF608B"/>
+ <TestFrame time="1230" hash="585727CAEC1F83ADB9E422BAF058A622"/>
+ <TestFrame time="1260" hash="2C3BBFEFBE6E5FDA1905E9F50985E1B4"/>
+ <TestFrame time="1290" hash="81675C4ABB2696D960BC5F204F05F16B"/>
+ <TestFrame time="1320" hash="6D0F3CCC06EF1E3A895ECC9A8DE90039"/>
+ <TestFrame time="1350" hash="0BF36093CCAEA8BDAE96D4939A8DDE20"/>
+ <TestFrame time="1380" hash="5A1CBC68AB59977B65492B0F8A664418"/>
+ <TestFrame time="1410" hash="C35831A8C59D56193CED2C4AADB4DFCE"/>
+ <TestFrame time="1440" hash="ED15973425A8B8528896B344A61393AA"/>
+ <TestFrame time="1470" hash="EA8FC02A8606680C089F0C0CE454ABE3"/>
+ <TestFrame time="1500" hash="CFB5CFBA0A0BC62C0D03908FB9599A8E"/>
+ <TestFrame time="1530" hash="09FAA04AFB50B48BD6A83F9E25F9DDDB"/>
+ <TestFrame time="1560" hash="0FDD0B8CDCCEB78C7C67AB0F5EA74D6A"/>
+ <TestFrame time="1590" hash="058D26146879900B5E5CCE05AE38BA0E"/>
+ <TestFrame time="1620" hash="80F9074C50F967C99D4C3A3FF9EC3E71"/>
+ <TestFrame time="1650" hash="AD9BDCEEC1C058D6B658C5BA0D0BC1F0"/>
+ <TestFrame time="1680" hash="AC14DF5458F91001181154F8C68BCE2B"/>
+ <TestFrame time="1710" hash="AE9225263E4C8E75E4D0F1D7192B4260"/>
+ <TestFrame time="1740" hash="D3D50F1B7F476E79E5B99E0E6D4CF827"/>
+ <TestFrame time="1770" hash="A1367445C5232ACCBF4904A415416EA4"/>
+ <TestFrame time="1800" hash="A21C0F1DA9B64A5B000558BA1F2E495D"/>
+ <TestFrame time="1830" hash="61AF477B6FB22E38E698375EA5793D22"/>
+ <TestFrame time="1860" hash="B3AD3501D527939CEAA4F124AB10B2DF"/>
+ <TestFrame time="1890" hash="0C2BF65A43AE87AFB0068F9FA4A74707"/>
+ <TestFrame time="1920" hash="5B7F96C797BEE4FD1B04538DE5549C1B"/>
+ <TestFrame time="1950" hash="4C861E936A3F1AFE323395E30174F8CC"/>
+ <TestFrame time="1980" hash="87F1966E5B0E924EB7CEED5520D120BF"/>
+ <TestFrame time="2010" hash="1980755E0D80469D4DC0B9B0309F2DEB"/>
+ <TestFrame time="2040" hash="38A7ACC2E5607FC0965B7B376A0D3524"/>
+ <TestFrame time="2070" hash="4434746833EFF5A3A76491024763990A"/>
+ <TestFrame time="2100" hash="A8BAD928F92E851B45723068B7FEF739"/>
+ <TestFrame time="2130" hash="A96F5C522C0ECA5C78E982E4235218CB"/>
+ <TestFrame time="2160" hash="135F0EFEDE2832B76F49966EBD629879"/>
+ <TestFrame time="2190" hash="A51C6E443413F184CAAE8A7F98A369C8"/>
+ <TestFrame time="2220" hash="62A7521EE62E6A2543B3141C1EFCE72A"/>
+ <TestFrame time="2250" hash="D416A41125659167B3E6AD68F66F6E64"/>
+ <TestFrame time="2280" hash="0F653B5E965665A43F50437724DC704C"/>
+ <TestFrame time="2310" hash="13A6E2485179501FF3AA8BA91A5050B4"/>
+ <TestFrame time="2340" hash="9423475D3832FBABEC56B80FA9161020"/>
+ <TestFrame time="2370" hash="497B21108A6CB127DB066B32D06D992A"/>
+ <TestFrame time="2400" hash="22F01CB9B4F8FF01410566A61E281373"/>
+ <TestFrame time="2430" hash="A099640BC088E14E20585CB87FC5C6F1"/>
+ <TestFrame time="2460" hash="AC2954553C333EA1D524CE51CD35958A"/>
+ <TestFrame time="2490" hash="771E882CC788BECAA82E71E6FBAB150D"/>
+ <TestFrame time="2520" hash="42CEDA45D88A8D2B3DA5B749F4C3C1BF"/>
+ <TestFrame time="2550" hash="C6E1F91B917E47246E012D1B203E0DC2"/>
+ <TestFrame time="2580" hash="EFB3E57CF265B6E36AA4DF72771D119C"/>
+ <TestFrame time="2610" hash="657FC7FD496E5A2FC84F63930E0D1DE3"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/easing/easing.xml b/tests/auto/declarative/visual/easing/easing.xml
new file mode 100644
index 0000000..01a7d6c
--- /dev/null
+++ b/tests/auto/declarative/visual/easing/easing.xml
@@ -0,0 +1,70 @@
+<Rect id="item" width="600" height="{layout.height}" color="white">
+ <resources>
+ <ListModel id="easingtypes">
+ <ListItem><type>easeNone</type></ListItem>
+ <ListItem><type>easeInQuad</type></ListItem>
+ <ListItem><type>easeOutQuad</type></ListItem>
+ <ListItem><type>easeInOutQuad</type></ListItem>
+ <ListItem><type>easeOutInQuad</type></ListItem>
+ <ListItem><type>easeInCubic</type></ListItem>
+ <ListItem><type>easeOutCubic</type></ListItem>
+ <ListItem><type>easeInOutCubic</type></ListItem>
+ <ListItem><type>easeOutInCubic</type></ListItem>
+ <ListItem><type>easeInQuart</type></ListItem>
+ <ListItem><type>easeOutQuart</type></ListItem>
+ <ListItem><type>easeInOutQuart</type></ListItem>
+ <ListItem><type>easeOutInQuart</type></ListItem>
+ <ListItem><type>easeInQuint</type></ListItem>
+ <ListItem><type>easeOutQuint</type></ListItem>
+ <ListItem><type>easeInOutQuint</type></ListItem>
+ <ListItem><type>easeOutInQuint</type></ListItem>
+ <ListItem><type>easeInSine</type></ListItem>
+ <ListItem><type>easeOutSine</type></ListItem>
+ <ListItem><type>easeInOutSine</type></ListItem>
+ <ListItem><type>easeOutInSine</type></ListItem>
+ <ListItem><type>easeInExpo</type></ListItem>
+ <ListItem><type>easeOutExpo</type></ListItem>
+ <ListItem><type>easeInOutExpo</type></ListItem>
+ <ListItem><type>easeOutInExpo</type></ListItem>
+ <ListItem><type>easeInCirc</type></ListItem>
+ <ListItem><type>easeOutCirc</type></ListItem>
+ <ListItem><type>easeInOutCirc</type></ListItem>
+ <ListItem><type>easeOutInCirc</type></ListItem>
+ <ListItem><type>easeInElastic</type></ListItem>
+ <ListItem><type>easeOutElastic</type></ListItem>
+ <ListItem><type>easeInOutElastic</type></ListItem>
+ <ListItem><type>easeOutInElastic</type></ListItem>
+ <ListItem><type>easeInBack</type></ListItem>
+ <ListItem><type>easeOutBack</type></ListItem>
+ <ListItem><type>easeInOutBack</type></ListItem>
+ <ListItem><type>easeOutInBack</type></ListItem>
+ <ListItem><type>easeOutBounce</type></ListItem>
+ <ListItem><type>easeInBounce</type></ListItem>
+ <ListItem><type>easeInOutBounce</type></ListItem>
+ <ListItem><type>easeOutInBounce</type></ListItem>
+ </ListModel>
+ </resources>
+
+ <VerticalLayout id="layout" anchors.left="{item.left}" anchors.right="{item.right}">
+ <Repeater dataSource="{easingtypes}" >
+ <Component>
+ <Text id="text" text="{type}" height="18" font.italic="true" color="black">
+ <states>
+ <State name="from" when="{!mouse.pressed}">
+ <SetProperty target="{text}" property="x" value="0"/>
+ </State>
+ <State name="to" when="{mouse.pressed}">
+ <SetProperty target="{text}" property="x" value="{item.width-100}"/>
+ </State>
+ </states>
+ <transitions>
+ <Transition fromState="*" toState="to" reversible="true">
+ <NumericAnimation properties="x" easing="{type}" />
+ </Transition>
+ </transitions>
+ </Text>
+ </Component>
+ </Repeater>
+ </VerticalLayout>
+ <MouseRegion id="mouse" anchors.fill="{layout}"/>
+</Rect>
diff --git a/tests/auto/declarative/visual/easing/image0.png b/tests/auto/declarative/visual/easing/image0.png
new file mode 100644
index 0000000..dbe03aa
--- /dev/null
+++ b/tests/auto/declarative/visual/easing/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/easing/manifest-play.xml b/tests/auto/declarative/visual/easing/manifest-play.xml
new file mode 100644
index 0000000..3c84452
--- /dev/null
+++ b/tests/auto/declarative/visual/easing/manifest-play.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="480" type="2" button="1" buttons="1" globalPos="487,444" pos="483,417"/>
+ <TestFrame time="510" hash="83FB660D6CABAAFCB27C6EC001B14110"/>
+ <TestFrame time="540" hash="27FCD68F610024000CA6D3A8D9F0CF09"/>
+ <TestFrame time="570" hash="14728A6160AF51FCA8562D6A020BBA79"/>
+ <TestFrame time="600" hash="BDDB81682B30A6918927ACB59608D14E"/>
+ <TestFrame time="630" hash="03F16A41DCD31E41935E54763757C6D5"/>
+ <TestFrame time="660" hash="2D04EA1EBEDC77CF5D42A1B491A57EA6"/>
+ <TestFrame time="690" hash="762C36B33B75F24427CA45F4AD06B64E"/>
+ <TestFrame time="720" hash="AA02624CC889C95A99BBE58365F4FAAD"/>
+ <TestFrame time="750" hash="0529200188188708A18CE0F931780DBD"/>
+ <TestFrame time="780" hash="56036B63822AF34F26B149069CD189C6"/>
+ <TestFrame time="810" hash="CFFC6583E2BA1E47E1439BED6FE69665"/>
+ <TestFrame time="840" hash="25A1AFDC945D5264FF0337A421143A3C"/>
+ <TestFrame time="870" hash="601FA34B5E15E7B87E6490580C2E1858"/>
+ <TestFrame time="900" hash="1CA085F6CB8509957A51F6182F7F5443"/>
+ <TestFrame time="930" hash="09B5849DF18F6817F7450230DFEC0E95"/>
+ <TestFrame time="960" hash="15D212C1291DF97E3DEA5AA8793AD5CB"/>
+ <TestFrame time="990" hash="D6E42E8F4D06BDDBAE998079AC2C79AD"/>
+ <TestFrame time="1020" hash="7016B5C435006D859AB087A73299B6D5"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/easing/manifest.xml b/tests/auto/declarative/visual/easing/manifest.xml
new file mode 100644
index 0000000..3c84452
--- /dev/null
+++ b/tests/auto/declarative/visual/easing/manifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="480" type="2" button="1" buttons="1" globalPos="487,444" pos="483,417"/>
+ <TestFrame time="510" hash="83FB660D6CABAAFCB27C6EC001B14110"/>
+ <TestFrame time="540" hash="27FCD68F610024000CA6D3A8D9F0CF09"/>
+ <TestFrame time="570" hash="14728A6160AF51FCA8562D6A020BBA79"/>
+ <TestFrame time="600" hash="BDDB81682B30A6918927ACB59608D14E"/>
+ <TestFrame time="630" hash="03F16A41DCD31E41935E54763757C6D5"/>
+ <TestFrame time="660" hash="2D04EA1EBEDC77CF5D42A1B491A57EA6"/>
+ <TestFrame time="690" hash="762C36B33B75F24427CA45F4AD06B64E"/>
+ <TestFrame time="720" hash="AA02624CC889C95A99BBE58365F4FAAD"/>
+ <TestFrame time="750" hash="0529200188188708A18CE0F931780DBD"/>
+ <TestFrame time="780" hash="56036B63822AF34F26B149069CD189C6"/>
+ <TestFrame time="810" hash="CFFC6583E2BA1E47E1439BED6FE69665"/>
+ <TestFrame time="840" hash="25A1AFDC945D5264FF0337A421143A3C"/>
+ <TestFrame time="870" hash="601FA34B5E15E7B87E6490580C2E1858"/>
+ <TestFrame time="900" hash="1CA085F6CB8509957A51F6182F7F5443"/>
+ <TestFrame time="930" hash="09B5849DF18F6817F7450230DFEC0E95"/>
+ <TestFrame time="960" hash="15D212C1291DF97E3DEA5AA8793AD5CB"/>
+ <TestFrame time="990" hash="D6E42E8F4D06BDDBAE998079AC2C79AD"/>
+ <TestFrame time="1020" hash="7016B5C435006D859AB087A73299B6D5"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/easing/pics/qtlogo.png b/tests/auto/declarative/visual/easing/pics/qtlogo.png
new file mode 100644
index 0000000..399bd0b
--- /dev/null
+++ b/tests/auto/declarative/visual/easing/pics/qtlogo.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flickable/Day.qml b/tests/auto/declarative/visual/flickable/Day.qml
new file mode 100644
index 0000000..0765e2f
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/Day.qml
@@ -0,0 +1,8 @@
+<Rect width="400" height="500" radius="7" pen.color="black" id="Page">
+ <properties>
+ <Property name="day" type="string" />
+ </properties>
+
+ <Image x="10" y="10" file="cork.jpg" opaque="true"/>
+ <Text x="20" y="20" height="40" font.size="14" font.bold="true" width="370" text="{day}" style="Outline" styleColor="#dedede"/>
+</Rect>
diff --git a/tests/auto/declarative/visual/flickable/cork.jpg b/tests/auto/declarative/visual/flickable/cork.jpg
new file mode 100644
index 0000000..d4d706c
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/cork.jpg
Binary files differ
diff --git a/tests/auto/declarative/visual/flickable/flickable.xml b/tests/auto/declarative/visual/flickable/flickable.xml
new file mode 100644
index 0000000..78bf42f
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/flickable.xml
@@ -0,0 +1,43 @@
+<Rect color="lightSteelBlue" width="800" height="500">
+ <ListModel id="List">
+ <Day>
+ <name>Sunday</name>
+ <dayColor>#808080</dayColor>
+ </Day>
+ <Day>
+ <name>Monday</name>
+ <dayColor>blue</dayColor>
+ </Day>
+ <Day>
+ <name>Tuesday</name>
+ <dayColor>yellow</dayColor>
+ </Day>
+ <Day>
+ <name>Wednesday</name>
+ <dayColor>purple</dayColor>
+ </Day>
+ <Day>
+ <name>Thursday</name>
+ <dayColor>blue</dayColor>
+ </Day>
+ <Day>
+ <name>Friday</name>
+ <dayColor>green</dayColor>
+ </Day>
+ <Day>
+ <name>Saturday</name>
+ <dayColor>orange</dayColor>
+ </Day>
+ </ListModel>
+
+ <Flickable id="Flick" anchors.fill="{parent}" viewportWidth="{Lay.width}">
+ <HorizontalLayout id="Lay">
+ <Repeater dataSource="{List}">
+ <Component>
+ <Day day="{name}" color="{dayColor}" />
+ </Component>
+ </Repeater>
+ </HorizontalLayout>
+ </Flickable>
+
+</Rect>
diff --git a/tests/auto/declarative/visual/flickable/image0.png b/tests/auto/declarative/visual/flickable/image0.png
new file mode 100644
index 0000000..a70ec71
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flickable/manifest-fail.xml b/tests/auto/declarative/visual/flickable/manifest-fail.xml
new file mode 100644
index 0000000..0701fa1
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/manifest-fail.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="930" type="2" button="1" buttons="1" globalPos="1459,490" pos="712,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1457,490" pos="710,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1454,490" pos="707,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1446,488" pos="699,461"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1438,488" pos="691,461"/>
+ <TestFrame time="1020" hash="3A44CE7B924456B70E9ACAA4D6211036"/>
+ <TestMouse time="1050" type="5" button="0" buttons="1" globalPos="1402,484" pos="655,457"/>
+ <TestMouse time="1050" type="5" button="0" buttons="1" globalPos="1386,484" pos="639,457"/>
+ <TestFrame time="1050" hash="CC4B8F76C3758329C4792CC2499588B9"/>
+ <TestMouse time="1080" type="5" button="0" buttons="1" globalPos="1328,478" pos="581,451"/>
+ <TestFrame time="1080" hash="A314FC89F9915A0F62E77C649052F30B"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1306,476" pos="559,449"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1258,472" pos="511,445"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1234,468" pos="487,441"/>
+ <TestFrame time="1110" hash="496BEE45FD87ACA4335EB656DAB38E7C"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1206,466" pos="459,439"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1140,460" pos="393,433"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1106,454" pos="359,427"/>
+ <TestFrame time="1140" hash="9052B7F038D1BE19B5C603F2B376D95C"/>
+ <TestMouse time="1170" type="5" button="0" buttons="1" globalPos="980,438" pos="233,411"/>
+ <TestFrame time="1170" hash="75EBD16D2210983178EC267DD5C7E3DC"/>
+ <TestMouse time="1200" type="5" button="0" buttons="1" globalPos="930,432" pos="183,405"/>
+ <TestMouse time="1200" type="3" button="1" buttons="0" globalPos="930,432" pos="183,405"/>
+ <TestFrame time="1200" hash="A016C7981ACC7C26D0CDE0CF7D71E929"/>
+ <TestFrame time="1260" hash="A2EA153F54B2D98DEC895FC72D3279F0"/>
+ <TestFrame time="1290" hash="2702B6D7429FC955B2061C368910309F"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/flickable/manifest.xml b/tests/auto/declarative/visual/flickable/manifest.xml
new file mode 100644
index 0000000..84d6890
--- /dev/null
+++ b/tests/auto/declarative/visual/flickable/manifest.xml
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="930" type="2" button="1" buttons="1" globalPos="1459,490" pos="712,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1457,490" pos="710,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1454,490" pos="707,463"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1446,488" pos="699,461"/>
+ <TestMouse time="1020" type="5" button="0" buttons="1" globalPos="1438,488" pos="691,461"/>
+ <TestFrame time="1020" hash="3A44CE7B924456B70E9ACAA4D6211036"/>
+ <TestMouse time="1050" type="5" button="0" buttons="1" globalPos="1402,484" pos="655,457"/>
+ <TestMouse time="1050" type="5" button="0" buttons="1" globalPos="1386,484" pos="639,457"/>
+ <TestFrame time="1050" hash="CC4B8F76C3758329C4792CC2499588B9"/>
+ <TestMouse time="1080" type="5" button="0" buttons="1" globalPos="1328,478" pos="581,451"/>
+ <TestFrame time="1080" hash="A314FC89F9915A0F62E77C649052F30B"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1306,476" pos="559,449"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1258,472" pos="511,445"/>
+ <TestMouse time="1110" type="5" button="0" buttons="1" globalPos="1234,468" pos="487,441"/>
+ <TestFrame time="1110" hash="496BEE45FD87ACA4335EB656DAB38E7C"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1206,466" pos="459,439"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1140,460" pos="393,433"/>
+ <TestMouse time="1140" type="5" button="0" buttons="1" globalPos="1106,454" pos="359,427"/>
+ <TestFrame time="1140" hash="9052B7F038D1BE19B5C603F2B376D95C"/>
+ <TestMouse time="1170" type="5" button="0" buttons="1" globalPos="980,438" pos="233,411"/>
+ <TestFrame time="1170" hash="75EBD16D2210983178EC267DD5C7E3DC"/>
+ <TestMouse time="1200" type="5" button="0" buttons="1" globalPos="930,432" pos="183,405"/>
+ <TestMouse time="1200" type="3" button="1" buttons="0" globalPos="930,432" pos="183,405"/>
+ <TestFrame time="1200" hash="A016C7981ACC7C26D0CDE0CF7D71E929"/>
+ <TestFrame time="1260" hash="203B3D2224AA0B9CB9DB64C837402047"/>
+ <TestFrame time="1290" hash="E9974E5662F22716C9BC2CF8D1FF12FE"/>
+ <TestFrame time="1320" hash="1218CCCC399AE53D5D99D3E7AFD73A16"/>
+ <TestFrame time="1350" hash="FA5D19578629F56972955E9FE530BE59"/>
+ <TestFrame time="1380" hash="B5B23BBDF1FEB6E6B55AE3909F607D96"/>
+ <TestFrame time="1410" hash="17EDC257AF24F178455CDEE7B9D73A9F"/>
+ <TestFrame time="1440" hash="F62E75656DC8AEF20426535DC25FC9F7"/>
+ <TestFrame time="1470" hash="973D39071B13FBBC700964CA1E4995DA"/>
+ <TestFrame time="1500" hash="391C67A59AC71B498381FC4D3DA1E8BB"/>
+ <TestFrame time="1530" hash="C1D86256E4BE487CB61AB1CC8D277FF2"/>
+ <TestFrame time="1560" hash="D5324FF0B16AA4B532007236222FEEAA"/>
+ <TestFrame time="1590" hash="4B14446DE1B9DE22D3DFF86A7CC46A05"/>
+ <TestFrame time="1620" hash="49E6FF8DEB537ECE9BDF56135FCB8BE3"/>
+ <TestFrame time="1650" hash="25D8D454CD32513F2E711D1B09DF87AF"/>
+ <TestFrame time="1680" hash="AB511F44DD761AC1070733CB81731451"/>
+ <TestFrame time="1710" hash="3441D361DB85B2522C8CCB8C21D95E70"/>
+ <TestFrame time="1740" hash="DB333DF49E6DB519F1F5436F6EEEF18E"/>
+ <TestFrame time="1770" hash="97044C41A8C27B534707352334CB100E"/>
+ <TestFrame time="1800" hash="C9EE4321669BB45A574D2CD3448553FE"/>
+ <TestFrame time="1830" hash="6E1067FB547479F8AC0214B1DE4F1ABD"/>
+ <TestFrame time="1860" hash="9AC3067759043EF1C8138C6E3D3B26D1"/>
+ <TestFrame time="1890" hash="F90BB455E7D0266C631BFD6657AC673F"/>
+ <TestFrame time="1920" hash="064CA0BCE5BCE1E5409F7E95F501843A"/>
+ <TestFrame time="1950" hash="AC5489FE171E537E5AF6EC9F8B5241DA"/>
+ <TestFrame time="1980" hash="BBF5D953DCF7FF64D99BF10E244FACE0"/>
+ <TestFrame time="2010" hash="309FC8E37A3EC93C41BC5E2F8F2962DB"/>
+ <TestFrame time="2040" hash="192B13ADD78B36E54E3D39E998641F82"/>
+ <TestFrame time="2070" hash="10F9D012CD1ECD9C8A872AA28191599E"/>
+ <TestFrame time="2100" hash="E3C9CE476A02915B7EEAA5D16747BD74"/>
+ <TestFrame time="2130" hash="24AD4F88A8BE8E4059517DA5AB9EC3F9"/>
+ <TestFrame time="2160" hash="74CE8AFFE7BAC8380E9EE27E482107E8"/>
+ <TestFrame time="2190" hash="C3377013131C3D1EEFFAEC37C0359E7B"/>
+ <TestFrame time="2220" hash="1850C61F261E6E148E12C9D9508411E4"/>
+ <TestFrame time="2250" hash="30EEAD3AC4C869FEB9A2E2F18BB5F335"/>
+ <TestFrame time="2280" hash="EB0F744274AF8FF27CAFC73053B63C87"/>
+ <TestFrame time="2310" hash="ADF16B9E820CF7F77E17E2383E0BF345"/>
+ <TestFrame time="2340" hash="8623C727CB6605607679B7C973E5CE61"/>
+ <TestFrame time="2370" hash="DE795BC19AD3B24FF091D6EB500C0C9A"/>
+ <TestFrame time="2400" hash="E85F53F766BE13A62272442916217181"/>
+ <TestFrame time="2430" hash="B5B05BF6D74AC22BC0DC5ECF8AFFD571"/>
+ <TestFrame time="2460" hash="C9DB0041AEA560EA3569FA6A37A8E226"/>
+ <TestFrame time="2490" hash="96B6E45404C4CB7C65A7113294679C96"/>
+ <TestFrame time="2520" hash="780599814A9AEEB63B6604F8627966FC"/>
+ <TestFrame time="2550" hash="40D7E36CD63DC9B6F5E0340F8E61DE4F"/>
+ <TestFrame time="2580" hash="127E4A92CC2AF9B6C7B5686ECED260E3"/>
+ <TestFrame time="2610" hash="10FEB4963AAD931587BAC2101367CB92"/>
+ <TestFrame time="2640" hash="2926893CD68516281E47EAD04720E4DB"/>
+ <TestFrame time="2670" hash="23F790EF701E37C3959465BF5298C9C2"/>
+ <TestFrame time="2700" hash="461224D0A6662450BA361FAF90CA3087"/>
+ <TestFrame time="2730" hash="3779C1CC5CD18633C70CE5614C2FCA33"/>
+ <TestFrame time="2760" hash="D93F3000F95110464793C9BAEF58D694"/>
+ <TestFrame time="2790" hash="0BFCCED8AE73FBCAC251442F002D603C"/>
+ <TestFrame time="2820" hash="AC1D13A5508255DCA994CC4685FB0AE3"/>
+ <TestFrame time="2850" hash="A6709853B44AB203FC8806D3F4159639"/>
+ <TestFrame time="2880" hash="171589A0F67D72F1685836F5EFF2DD10"/>
+ <TestFrame time="2910" hash="D4984C2B663CFA0CDE95F9AD5BC9937B"/>
+ <TestFrame time="2940" hash="1BB6D261C9E800004B180FB8EC0B45AD"/>
+ <TestFrame time="2970" hash="46CD4E37C989FACF2B7CD71A16DB495A"/>
+ <TestFrame time="3000" hash="8ED436FF855C96A8CEB795AE175A7C54"/>
+ <TestFrame time="3030" hash="8ED436FF855C96A8CEB795AE175A7C54"/>
+ <TestFrame time="3060" hash="138D8CC351C847F266C63F323BABD7FE"/>
+ <TestFrame time="3090" hash="8D90560CCF5EEB1475F3AA46295E4DD0"/>
+ <TestFrame time="3120" hash="DD893A953B945365B0F9287A79826A6D"/>
+ <TestFrame time="3150" hash="386A768FD485BB66C9DC1465399B58C8"/>
+ <TestFrame time="3180" hash="21340437F1A05C216005157A8E8A9EEF"/>
+ <TestFrame time="3210" hash="6E2DA9DA5964F59715B08FD59D8BC3EF"/>
+ <TestFrame time="3240" hash="DC7108F44E225D70349889D9E3F62E74"/>
+ <TestMouse time="4110" type="2" button="1" buttons="1" globalPos="853,492" pos="106,465"/>
+ <TestMouse time="4170" type="5" button="0" buttons="1" globalPos="854,493" pos="107,466"/>
+ <TestMouse time="4170" type="5" button="0" buttons="1" globalPos="855,493" pos="108,466"/>
+ <TestMouse time="4170" type="5" button="0" buttons="1" globalPos="856,494" pos="109,467"/>
+ <TestMouse time="4170" type="5" button="0" buttons="1" globalPos="857,494" pos="110,467"/>
+ <TestMouse time="4200" type="5" button="0" buttons="1" globalPos="859,494" pos="112,467"/>
+ <TestMouse time="4200" type="5" button="0" buttons="1" globalPos="860,495" pos="113,468"/>
+ <TestMouse time="4200" type="5" button="0" buttons="1" globalPos="862,495" pos="115,468"/>
+ <TestFrame time="4200" hash="3946A595E81E4388AFDDDB2539B21BF3"/>
+ <TestMouse time="4230" type="5" button="0" buttons="1" globalPos="864,495" pos="117,468"/>
+ <TestMouse time="4230" type="5" button="0" buttons="1" globalPos="869,495" pos="122,468"/>
+ <TestMouse time="4230" type="5" button="0" buttons="1" globalPos="872,495" pos="125,468"/>
+ <TestFrame time="4230" hash="D9F7C86886CC5309846694F5DA98A123"/>
+ <TestMouse time="4260" type="5" button="0" buttons="1" globalPos="875,495" pos="128,468"/>
+ <TestMouse time="4260" type="5" button="0" buttons="1" globalPos="892,497" pos="145,470"/>
+ <TestFrame time="4260" hash="0B923428F4EAF40CB032FE8880B10943"/>
+ <TestMouse time="4290" type="5" button="0" buttons="1" globalPos="911,499" pos="164,472"/>
+ <TestMouse time="4290" type="5" button="0" buttons="1" globalPos="919,499" pos="172,472"/>
+ <TestFrame time="4290" hash="F1FCED7910188DBEDC62E289EC98D14A"/>
+ <TestMouse time="4320" type="5" button="0" buttons="1" globalPos="938,499" pos="191,472"/>
+ <TestFrame time="4320" hash="71A01976611816A5D42BBB6BC6DE5336"/>
+ <TestMouse time="4350" type="5" button="0" buttons="1" globalPos="957,501" pos="210,474"/>
+ <TestMouse time="4350" type="5" button="0" buttons="1" globalPos="960,501" pos="213,474"/>
+ <TestFrame time="4350" hash="204D5511DFAA28AF3E499FD5E503592A"/>
+ <TestMouse time="4380" type="5" button="0" buttons="1" globalPos="968,501" pos="221,474"/>
+ <TestMouse time="4380" type="5" button="0" buttons="1" globalPos="986,503" pos="239,476"/>
+ <TestMouse time="4380" type="5" button="0" buttons="1" globalPos="989,503" pos="242,476"/>
+ <TestFrame time="4380" hash="E7F2934FB80FD155AAE4E558B1D31AF9"/>
+ <TestMouse time="4410" type="5" button="0" buttons="1" globalPos="1015,501" pos="268,474"/>
+ <TestMouse time="4410" type="5" button="0" buttons="1" globalPos="1025,499" pos="278,472"/>
+ <TestFrame time="4410" hash="DE795BC19AD3B24FF091D6EB500C0C9A"/>
+ <TestMouse time="4440" type="5" button="0" buttons="1" globalPos="1065,497" pos="318,470"/>
+ <TestFrame time="4440" hash="3A2D5734CCC3E5690EF24D412B5ADE32"/>
+ <TestMouse time="4470" type="5" button="0" buttons="1" globalPos="1083,495" pos="336,468"/>
+ <TestMouse time="4470" type="5" button="0" buttons="1" globalPos="1135,493" pos="388,466"/>
+ <TestMouse time="4470" type="5" button="0" buttons="1" globalPos="1171,489" pos="424,462"/>
+ <TestFrame time="4470" hash="A5F66816E008610C1DA44270F837C9DF"/>
+ <TestMouse time="4500" type="5" button="0" buttons="1" globalPos="1215,489" pos="468,462"/>
+ <TestMouse time="4500" type="5" button="0" buttons="1" globalPos="1319,483" pos="572,456"/>
+ <TestMouse time="4500" type="5" button="0" buttons="1" globalPos="1379,479" pos="632,452"/>
+ <TestFrame time="4500" hash="6AE11928E7948AD5F9CE5EE07B5E7390"/>
+ <TestMouse time="4530" type="5" button="0" buttons="1" globalPos="1441,475" pos="694,448"/>
+ <TestMouse time="4530" type="3" button="1" buttons="0" globalPos="1441,475" pos="694,448"/>
+ <TestFrame time="4530" hash="47B438BC833CFF7984D3E158B54F0EA5"/>
+ <TestFrame time="4590" hash="DA134DD6826A87BC08F3BE59F3D2866D"/>
+ <TestFrame time="4620" hash="D1E87BD1C6264CE83979D34500EEB85B"/>
+ <TestFrame time="4650" hash="37C13A368649152DD1D43BDD17BEEE97"/>
+ <TestFrame time="4680" hash="C461AE2C388F4B06E958C12B543E53C0"/>
+ <TestFrame time="4710" hash="6070DD498E15C27243F09FD8CF8C0D2F"/>
+ <TestFrame time="4740" hash="FB74E95CF41BDA785991BA01369E9320"/>
+ <TestFrame time="4770" hash="F52AE455BBA3BAD36ABB4DB2480549D6"/>
+ <TestFrame time="4800" hash="9BC4E043F6595493ED32BBAAB949CC15"/>
+ <TestFrame time="4830" hash="4C87F70F6A46B2066021A68435BB285D"/>
+ <TestFrame time="4860" hash="282A523039F702F22C5D7F2B00BCA1F4"/>
+ <TestFrame time="4890" hash="D1623E75F20C00F6F357346F57E5C343"/>
+ <TestFrame time="4920" hash="F96CC72E3671C64D87719E5DF8303FA9"/>
+ <TestFrame time="4950" hash="44D4E09F9AB5C20E7A7F1AEF920B3599"/>
+ <TestFrame time="4980" hash="BBAD1BD87E29C1F0834B16DA9C1317A4"/>
+ <TestFrame time="5010" hash="66DF69AD2EA4823E59F6FC296910822F"/>
+ <TestFrame time="5040" hash="A0DCE22CFADFE091C5474C231EAD191E"/>
+ <TestFrame time="5070" hash="AE67DD3CD8B77D001288558E3C67E675"/>
+ <TestFrame time="5100" hash="B028CC11B70C5288436E49DD439F9F46"/>
+ <TestFrame time="5130" hash="2FBEFA9C751317D668A1074E8BCB8B10"/>
+ <TestFrame time="5160" hash="2DB3A59F7CB89B89CD45B86008CC0541"/>
+ <TestFrame time="5190" hash="AFE0FD3CB16F9DDD3E8DAD46656BE099"/>
+ <TestFrame time="5220" hash="90C04F980A0C008D4B919D9A4B663762"/>
+ <TestFrame time="5250" hash="215CB75F6359548B7A4A408E83049A25"/>
+ <TestFrame time="5280" hash="8EC68EA3F6B54415EC9B860B0207351E"/>
+ <TestFrame time="5310" hash="8FC14C2EB103B4FDC5B17E6E0F2386D1"/>
+ <TestFrame time="5340" hash="938DA507656430E1758CB8B5E9D874B1"/>
+ <TestFrame time="5370" hash="30A3166F0169715DA9FECD48DA257625"/>
+ <TestFrame time="5400" hash="0C24CD68AFE9C24380178417FE835494"/>
+ <TestFrame time="5430" hash="C8A18880023CB12BA98EBDFF65875874"/>
+ <TestFrame time="5460" hash="FE3BCA8DC715A19161FCD48C728366A0"/>
+ <TestFrame time="5490" hash="4771F9D8AA2A177A190879EB543FA138"/>
+ <TestFrame time="5520" hash="971D611BC939AB20B998D659DF2235FE"/>
+ <TestFrame time="5550" hash="7AF899892AE28C61B71A5682F9540DB5"/>
+ <TestFrame time="5580" hash="CCF349DCA802D5D68B6C9CB368104EF8"/>
+ <TestFrame time="5610" hash="3DC13F8B693648ABBE8FD6935832BEC7"/>
+ <TestFrame time="5640" hash="ED2AD5E716D69FD1A87133209695E911"/>
+ <TestFrame time="5670" hash="037B45A66950DF70D8BD7BC0E000ECC7"/>
+ <TestFrame time="5700" hash="43B59CF46A829CAFF7D9C0A6D1175581"/>
+ <TestFrame time="5730" hash="6FF016CE82BFD220418C0A9A644F2F81"/>
+ <TestFrame time="5760" hash="96D37AFF283210D59287526798E9376D"/>
+ <TestFrame time="5790" hash="7289570ABB671359AC2F2DF1898748CA"/>
+ <TestFrame time="5820" hash="2B3AF6424765512B8949BBB9BF6571DC"/>
+ <TestFrame time="5850" hash="23054E1F931342B8A6C5F6D30A9FF158"/>
+ <TestFrame time="5880" hash="E3D6EBB07FC90AD2483E95C09CB9E074"/>
+ <TestFrame time="5910" hash="08EE4C4D9F161AB4118EAD4F4AA8D5B3"/>
+ <TestFrame time="5940" hash="96D37AFF283210D59287526798E9376D"/>
+ <TestFrame time="5970" hash="40FB8747AACD078576573CF346E2C418"/>
+ <TestFrame time="6000" hash="4095D9B46D265D28C88DE0D0E02AC840"/>
+ <TestFrame time="6030" hash="E370C2A5451DC73AE4F742D52E3DAD4D"/>
+ <TestFrame time="6060" hash="AC4DC18BEFE0895C1ADF8EE2E3094A09"/>
+ <TestFrame time="6090" hash="AC4DC18BEFE0895C1ADF8EE2E3094A09"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/flipable/flipable.xml b/tests/auto/declarative/visual/flipable/flipable.xml
new file mode 100644
index 0000000..d769e55
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/flipable.xml
@@ -0,0 +1,138 @@
+<Rect color="lightsteelblue" height="400" width="500">
+ <VisualModel id="MyVisualModel">
+ <model>
+ <ListModel id="ListModel">
+ <Person>
+ <name>Jessica</name>
+ <picture>face.png</picture>
+ </Person>
+ <Person>
+ <name>John</name>
+ <picture>photo0.png</picture>
+ </Person>
+ <Person>
+ <name>Susan</name>
+ <picture>photo10.png</picture>
+ </Person>
+ <Person>
+ <name>Samantha</name>
+ <picture>photo1.png</picture>
+ </Person>
+ <Person>
+ <name>Mark</name>
+ <picture>photo2.png</picture>
+ </Person>
+ <Person>
+ <name>Sarah</name>
+ <picture>photo3.png</picture>
+ </Person>
+ <Person>
+ <name>Pam</name>
+ <picture>photo4.png</picture>
+ </Person>
+ <Person>
+ <name>April</name>
+ <picture>photo5.png</picture>
+ </Person>
+ <Person>
+ <name>Tarryn</name>
+ <picture>photo6.png</picture>
+ </Person>
+ <Person>
+ <name>Geoff</name>
+ <picture>photo7.png</picture>
+ </Person>
+ <Person>
+ <name>Bill</name>
+ <picture>photo8.png</picture>
+ </Person>
+ <Person>
+ <name>Stuart</name>
+ <picture>photo9.png</picture>
+ </Person>
+ </ListModel>
+ </model>
+ <delegate>
+ <Package>
+ <Flipable id="MeRect" width="100" height="100">
+ <properties>
+ <Property name="r" type="Real" />
+ </properties>
+ <transform>
+ <Perspective angle="90" x="50" y="50" aspect="1" scale="256"/>
+ <Axis xStart="50" xEnd="50" yStart="0" yEnd="1" rotation="{MeRect.r}" />
+ </transform>
+
+ <front>
+ <Rect radius="5" color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </front>
+
+ <back>
+ <Rect radius="5" color="red" width="100" height="100">
+ <Image anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}" file="{picture}" />
+ </Rect>
+ </back>
+ </Flipable>
+
+ <Item Package.name="leftBox" id="LeftBox"
+ width="100" height="100">
+ <Rect opacity="0.1" width="80" height="80" radius="4"
+ color="grey" x="10" y="10">
+ <Text text="{name}" />
+ <MouseRegion anchors.fill="{parent}" onClick="if(MyItem.currentState=='left') MyItem.currentState='right'; else MyItem.currentState='left';" />
+ </Rect>
+ </Item>
+ <Item Package.name="rightBox" id="RightBox"
+ width="100" height="100">
+ <Rect opacity="0.1" width="80" height="80" radius="4"
+ color="grey" x="10" y="10">
+ <Text text="{name}" />
+ <MouseRegion anchors.fill="{parent}" onClick="if(MyItem.currentState=='left') MyItem.currentState='right'; else MyItem.currentState='left';" />
+ </Rect>
+ </Item>
+ <Item id="MyItem">
+ <states>
+ <State name="left">
+ <SetProperty target="{MeRect}" property="moveToParent" value="{LeftBox}" />
+ </State>
+ <State name="right">
+ <SetProperty target="{MeRect}" property="moveToParent" value="{RightBox}" />
+ <SetProperty target="{MeRect}" property="r" value="180" />
+ </State>
+ </states>
+ <transitions>
+ <Transition fromState="*" toState="*">
+ <NumericAnimation property="r" duration="500" />
+ <SerialAnimation>
+ <SetPropertyAction target="{MeRect}" property="moveToParent" value="{Bounce}" />
+ <ParallelAnimation>
+ <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250" />
+ <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeInQuad" duration="250"/>
+ </ParallelAnimation>
+ <SetPropertyAction target="{MeRect}" property="moveToParent" />
+ <ParallelAnimation>
+ <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250"/>
+ <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeOutQuad" duration="250"/>
+ </ParallelAnimation>
+ </SerialAnimation>
+ </Transition>
+ </transitions>
+ <currentState>left</currentState>
+ </Item>
+
+ </Package>
+ </delegate>
+ </VisualModel>
+
+ <Item width="800" height="400" clip="true">
+ <Item z="100" id="Bounce" x="200" y="300" />
+ <ListView id="MyListView" width="400" height="400" x="400"
+ model="{MyVisualModel.parts.rightBox}" />
+
+ <ListView id="MyListView2" width="400" height="400"
+ model="{MyVisualModel.parts.leftBox}" />
+ </Item>
+
+</Rect>
diff --git a/tests/auto/declarative/visual/flipable/image0.png b/tests/auto/declarative/visual/flipable/image0.png
new file mode 100644
index 0000000..affb8a5
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/manifest-play.xml b/tests/auto/declarative/visual/flipable/manifest-play.xml
new file mode 100644
index 0000000..81c08e4
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/manifest-play.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="2040" type="2" button="1" buttons="1" globalPos="812,72" pos="65,45"/>
+ <TestMouse time="2100" type="3" button="1" buttons="0" globalPos="812,72" pos="65,45"/>
+ <TestFrame time="2130" hash="210454ECF70EEA9CA43DD391BC23178B"/>
+ <TestFrame time="2160" hash="F6612DAD879208F4AF100337271C445C"/>
+ <TestFrame time="2190" hash="C77FC41100D0B066F8F0BF4ABCF2F0BF"/>
+ <TestFrame time="2220" hash="1AB3A42E6FC271E049E6071A88AB8EE4"/>
+ <TestFrame time="2250" hash="DB3D5BC6882699DCC0208E4F5294B609"/>
+ <TestFrame time="2280" hash="DC5A8B44283DA4A81D3994B873FC5695"/>
+ <TestFrame time="2310" hash="5149027ECF7813BA64D3AB8FFE0265F5"/>
+ <TestFrame time="2340" hash="B7E801DF476C012AC3E9E48A9D4AA321"/>
+ <TestFrame time="2370" hash="F31A647A6A3EC86D7F16EB3147E5FC29"/>
+ <TestFrame time="2400" hash="FBB068C39D5188A175075667B584F1BE"/>
+ <TestFrame time="2430" hash="EC487AB66384A4A3A718D03555EBFD41"/>
+ <TestFrame time="2460" hash="C7AD11EB051B11ACBA38027013215A05"/>
+ <TestFrame time="2490" hash="AA38FD8E97EC394488274127630E7946"/>
+ <TestFrame time="2520" hash="1CA2B617AC966B54FFA1A61914F68A9D"/>
+ <TestFrame time="2550" hash="1726C0BAA930CAF282154F14AC2FD120"/>
+ <TestFrame time="2580" hash="58F8196148C8B64191AF7B897A811CFB"/>
+ <TestFrame time="2610" hash="D56D3FA137AA63A0215611450B40F3E0"/>
+ <TestFrame time="2640" hash="5E1BCDF996B2903D1EAEAC65E17783C2"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/flipable/manifest.xml b/tests/auto/declarative/visual/flipable/manifest.xml
new file mode 100644
index 0000000..81c08e4
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/manifest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestMouse time="2040" type="2" button="1" buttons="1" globalPos="812,72" pos="65,45"/>
+ <TestMouse time="2100" type="3" button="1" buttons="0" globalPos="812,72" pos="65,45"/>
+ <TestFrame time="2130" hash="210454ECF70EEA9CA43DD391BC23178B"/>
+ <TestFrame time="2160" hash="F6612DAD879208F4AF100337271C445C"/>
+ <TestFrame time="2190" hash="C77FC41100D0B066F8F0BF4ABCF2F0BF"/>
+ <TestFrame time="2220" hash="1AB3A42E6FC271E049E6071A88AB8EE4"/>
+ <TestFrame time="2250" hash="DB3D5BC6882699DCC0208E4F5294B609"/>
+ <TestFrame time="2280" hash="DC5A8B44283DA4A81D3994B873FC5695"/>
+ <TestFrame time="2310" hash="5149027ECF7813BA64D3AB8FFE0265F5"/>
+ <TestFrame time="2340" hash="B7E801DF476C012AC3E9E48A9D4AA321"/>
+ <TestFrame time="2370" hash="F31A647A6A3EC86D7F16EB3147E5FC29"/>
+ <TestFrame time="2400" hash="FBB068C39D5188A175075667B584F1BE"/>
+ <TestFrame time="2430" hash="EC487AB66384A4A3A718D03555EBFD41"/>
+ <TestFrame time="2460" hash="C7AD11EB051B11ACBA38027013215A05"/>
+ <TestFrame time="2490" hash="AA38FD8E97EC394488274127630E7946"/>
+ <TestFrame time="2520" hash="1CA2B617AC966B54FFA1A61914F68A9D"/>
+ <TestFrame time="2550" hash="1726C0BAA930CAF282154F14AC2FD120"/>
+ <TestFrame time="2580" hash="58F8196148C8B64191AF7B897A811CFB"/>
+ <TestFrame time="2610" hash="D56D3FA137AA63A0215611450B40F3E0"/>
+ <TestFrame time="2640" hash="5E1BCDF996B2903D1EAEAC65E17783C2"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/flipable/pics/arrow.png b/tests/auto/declarative/visual/flipable/pics/arrow.png
new file mode 100644
index 0000000..997190d
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/arrow.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/face.png b/tests/auto/declarative/visual/flipable/pics/face.png
new file mode 100644
index 0000000..e9529ac
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/face.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo0.png b/tests/auto/declarative/visual/flipable/pics/photo0.png
new file mode 100644
index 0000000..26bbf5b
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo1.png b/tests/auto/declarative/visual/flipable/pics/photo1.png
new file mode 100644
index 0000000..2230f71
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo10.png b/tests/auto/declarative/visual/flipable/pics/photo10.png
new file mode 100644
index 0000000..119f142
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo2.png b/tests/auto/declarative/visual/flipable/pics/photo2.png
new file mode 100644
index 0000000..e3d58c1
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo3.png b/tests/auto/declarative/visual/flipable/pics/photo3.png
new file mode 100644
index 0000000..4b58df4
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo4.png b/tests/auto/declarative/visual/flipable/pics/photo4.png
new file mode 100644
index 0000000..4ed4bd2
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo5.png b/tests/auto/declarative/visual/flipable/pics/photo5.png
new file mode 100644
index 0000000..eb26704
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo6.png b/tests/auto/declarative/visual/flipable/pics/photo6.png
new file mode 100644
index 0000000..69875ce
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo7.png b/tests/auto/declarative/visual/flipable/pics/photo7.png
new file mode 100644
index 0000000..0b117c9
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo8.png b/tests/auto/declarative/visual/flipable/pics/photo8.png
new file mode 100644
index 0000000..b77b997
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/flipable/pics/photo9.png b/tests/auto/declarative/visual/flipable/pics/photo9.png
new file mode 100644
index 0000000..8a974d6
--- /dev/null
+++ b/tests/auto/declarative/visual/flipable/pics/photo9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/pauseAnimation/image0.png b/tests/auto/declarative/visual/pauseAnimation/image0.png
new file mode 100644
index 0000000..80fd4d1
--- /dev/null
+++ b/tests/auto/declarative/visual/pauseAnimation/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/pauseAnimation/manifest-play.xml b/tests/auto/declarative/visual/pauseAnimation/manifest-play.xml
new file mode 100644
index 0000000..6b15341
--- /dev/null
+++ b/tests/auto/declarative/visual/pauseAnimation/manifest-play.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestFrame time="60" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="90" hash="6579681C59DD571DF0EE4429D74FB5C7"/>
+ <TestFrame time="120" hash="7DA50C2984E012F217DC44F79AD86D55"/>
+ <TestFrame time="150" hash="D5E2A4ABDCA59FA26FCE968AB11F0719"/>
+ <TestFrame time="180" hash="005ACBEF952A8EE536E6308A48223E65"/>
+ <TestFrame time="210" hash="C4F844EE71F23635BB3EC7375F6A134F"/>
+ <TestFrame time="240" hash="D9604BE23A91327E6AB454609A9D4A13"/>
+ <TestFrame time="270" hash="DA60100DC55023C3BAB367D97C8F6A85"/>
+ <TestFrame time="300" hash="79EC710576427DF73DD03F39FBA6E2EB"/>
+ <TestFrame time="330" hash="FFD39C1122FE2F7877EF30591B539B40"/>
+ <TestFrame time="360" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="390" hash="29ECE1BCA4D21FB5862091317D430A13"/>
+ <TestFrame time="420" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="450" hash="4AC43A03CC6F2020AB5F894D704092AC"/>
+ <TestFrame time="480" hash="6CC9DE62A0C8FA5E42EAC1B01E99AC32"/>
+ <TestFrame time="510" hash="D754D35D0793F9F7D4F6249A874E4C45"/>
+ <TestFrame time="540" hash="B2C778A5EFF5F01EDC54F03D8B4DE8C7"/>
+ <TestFrame time="570" hash="A4D9DFDBF32C0AD31794B04A2E23A0DB"/>
+ <TestFrame time="600" hash="5025EB75C88F0760F637E0342B7F88A2"/>
+ <TestFrame time="630" hash="F4732FF2DF93FE67CB850DEC34184924"/>
+ <TestFrame time="660" hash="97566CE9558D13EA0780BCE233097B27"/>
+ <TestFrame time="690" hash="2AD64CB01C9D50E0118D5ECE0A644DF2"/>
+ <TestFrame time="720" hash="721D7061811B5439C2E8E395917494BC"/>
+ <TestFrame time="750" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="780" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="810" hash="336D31586171F22D541B989D24B95CBB"/>
+ <TestFrame time="840" hash="6D63FB5C8A80F0280E88B2CDF8641BB9"/>
+ <TestFrame time="870" hash="EF8941674CB61F54853DC33652BB854E"/>
+ <TestFrame time="900" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="930" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="960" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="990" hash="A88A8129259F86DF5A73ADDC3649AD37"/>
+ <TestFrame time="1020" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="1050" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="1080" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1110" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1140" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1170" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1200" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="1230" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="1260" hash="A8B624EBFC9AB713D1CE55F318A6E90D"/>
+ <TestFrame time="1290" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="1320" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="1350" hash="BC426FB7C31751665B0D3F16E2CB0173"/>
+ <TestFrame time="1380" hash="DD60CBAFF6F34027474E92315DBC0EBC"/>
+ <TestFrame time="1410" hash="F0D8132489C2F2EF760E905B3C093726"/>
+ <TestFrame time="1440" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1470" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="1500" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1530" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="1560" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="1590" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="1620" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1650" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1680" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1710" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1740" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="1770" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="1800" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="1830" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1860" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="1890" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1920" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1950" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="1980" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="2010" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="2040" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="3060" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="3090" hash="6579681C59DD571DF0EE4429D74FB5C7"/>
+ <TestFrame time="3120" hash="7DA50C2984E012F217DC44F79AD86D55"/>
+ <TestFrame time="3150" hash="D5E2A4ABDCA59FA26FCE968AB11F0719"/>
+ <TestFrame time="3180" hash="005ACBEF952A8EE536E6308A48223E65"/>
+ <TestFrame time="3210" hash="C4F844EE71F23635BB3EC7375F6A134F"/>
+ <TestFrame time="3240" hash="D9604BE23A91327E6AB454609A9D4A13"/>
+ <TestFrame time="3270" hash="DA60100DC55023C3BAB367D97C8F6A85"/>
+ <TestFrame time="3300" hash="79EC710576427DF73DD03F39FBA6E2EB"/>
+ <TestFrame time="3330" hash="FFD39C1122FE2F7877EF30591B539B40"/>
+ <TestFrame time="3360" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="3390" hash="29ECE1BCA4D21FB5862091317D430A13"/>
+ <TestFrame time="3420" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="3450" hash="4AC43A03CC6F2020AB5F894D704092AC"/>
+ <TestFrame time="3480" hash="6CC9DE62A0C8FA5E42EAC1B01E99AC32"/>
+ <TestFrame time="3510" hash="D754D35D0793F9F7D4F6249A874E4C45"/>
+ <TestFrame time="3540" hash="B2C778A5EFF5F01EDC54F03D8B4DE8C7"/>
+ <TestFrame time="3570" hash="A4D9DFDBF32C0AD31794B04A2E23A0DB"/>
+ <TestFrame time="3600" hash="5025EB75C88F0760F637E0342B7F88A2"/>
+ <TestFrame time="3630" hash="F4732FF2DF93FE67CB850DEC34184924"/>
+ <TestFrame time="3660" hash="97566CE9558D13EA0780BCE233097B27"/>
+ <TestFrame time="3690" hash="2AD64CB01C9D50E0118D5ECE0A644DF2"/>
+ <TestFrame time="3720" hash="721D7061811B5439C2E8E395917494BC"/>
+ <TestFrame time="3750" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="3780" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="3810" hash="336D31586171F22D541B989D24B95CBB"/>
+ <TestFrame time="3840" hash="6D63FB5C8A80F0280E88B2CDF8641BB9"/>
+ <TestFrame time="3870" hash="EF8941674CB61F54853DC33652BB854E"/>
+ <TestFrame time="3900" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="3930" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="3960" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="3990" hash="A88A8129259F86DF5A73ADDC3649AD37"/>
+ <TestFrame time="4020" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="4050" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="4080" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4110" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4140" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4170" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4200" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="4230" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="4260" hash="A8B624EBFC9AB713D1CE55F318A6E90D"/>
+ <TestFrame time="4290" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="4320" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="4350" hash="BC426FB7C31751665B0D3F16E2CB0173"/>
+ <TestFrame time="4380" hash="DD60CBAFF6F34027474E92315DBC0EBC"/>
+ <TestFrame time="4410" hash="F0D8132489C2F2EF760E905B3C093726"/>
+ <TestFrame time="4440" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4470" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="4500" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4530" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="4560" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="4590" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="4620" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4650" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4680" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4710" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4740" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="4770" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="4800" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="4830" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4860" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="4890" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4920" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4950" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="4980" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="5010" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="5040" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/pauseAnimation/manifest.xml b/tests/auto/declarative/visual/pauseAnimation/manifest.xml
new file mode 100644
index 0000000..6b15341
--- /dev/null
+++ b/tests/auto/declarative/visual/pauseAnimation/manifest.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+ <TestFrame time="60" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="90" hash="6579681C59DD571DF0EE4429D74FB5C7"/>
+ <TestFrame time="120" hash="7DA50C2984E012F217DC44F79AD86D55"/>
+ <TestFrame time="150" hash="D5E2A4ABDCA59FA26FCE968AB11F0719"/>
+ <TestFrame time="180" hash="005ACBEF952A8EE536E6308A48223E65"/>
+ <TestFrame time="210" hash="C4F844EE71F23635BB3EC7375F6A134F"/>
+ <TestFrame time="240" hash="D9604BE23A91327E6AB454609A9D4A13"/>
+ <TestFrame time="270" hash="DA60100DC55023C3BAB367D97C8F6A85"/>
+ <TestFrame time="300" hash="79EC710576427DF73DD03F39FBA6E2EB"/>
+ <TestFrame time="330" hash="FFD39C1122FE2F7877EF30591B539B40"/>
+ <TestFrame time="360" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="390" hash="29ECE1BCA4D21FB5862091317D430A13"/>
+ <TestFrame time="420" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="450" hash="4AC43A03CC6F2020AB5F894D704092AC"/>
+ <TestFrame time="480" hash="6CC9DE62A0C8FA5E42EAC1B01E99AC32"/>
+ <TestFrame time="510" hash="D754D35D0793F9F7D4F6249A874E4C45"/>
+ <TestFrame time="540" hash="B2C778A5EFF5F01EDC54F03D8B4DE8C7"/>
+ <TestFrame time="570" hash="A4D9DFDBF32C0AD31794B04A2E23A0DB"/>
+ <TestFrame time="600" hash="5025EB75C88F0760F637E0342B7F88A2"/>
+ <TestFrame time="630" hash="F4732FF2DF93FE67CB850DEC34184924"/>
+ <TestFrame time="660" hash="97566CE9558D13EA0780BCE233097B27"/>
+ <TestFrame time="690" hash="2AD64CB01C9D50E0118D5ECE0A644DF2"/>
+ <TestFrame time="720" hash="721D7061811B5439C2E8E395917494BC"/>
+ <TestFrame time="750" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="780" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="810" hash="336D31586171F22D541B989D24B95CBB"/>
+ <TestFrame time="840" hash="6D63FB5C8A80F0280E88B2CDF8641BB9"/>
+ <TestFrame time="870" hash="EF8941674CB61F54853DC33652BB854E"/>
+ <TestFrame time="900" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="930" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="960" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="990" hash="A88A8129259F86DF5A73ADDC3649AD37"/>
+ <TestFrame time="1020" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="1050" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="1080" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1110" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1140" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1170" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="1200" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="1230" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="1260" hash="A8B624EBFC9AB713D1CE55F318A6E90D"/>
+ <TestFrame time="1290" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="1320" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="1350" hash="BC426FB7C31751665B0D3F16E2CB0173"/>
+ <TestFrame time="1380" hash="DD60CBAFF6F34027474E92315DBC0EBC"/>
+ <TestFrame time="1410" hash="F0D8132489C2F2EF760E905B3C093726"/>
+ <TestFrame time="1440" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1470" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="1500" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1530" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="1560" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="1590" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="1620" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1650" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1680" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1710" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="1740" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="1770" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="1800" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="1830" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1860" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="1890" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1920" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="1950" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="1980" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="2010" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="2040" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="3060" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="3090" hash="6579681C59DD571DF0EE4429D74FB5C7"/>
+ <TestFrame time="3120" hash="7DA50C2984E012F217DC44F79AD86D55"/>
+ <TestFrame time="3150" hash="D5E2A4ABDCA59FA26FCE968AB11F0719"/>
+ <TestFrame time="3180" hash="005ACBEF952A8EE536E6308A48223E65"/>
+ <TestFrame time="3210" hash="C4F844EE71F23635BB3EC7375F6A134F"/>
+ <TestFrame time="3240" hash="D9604BE23A91327E6AB454609A9D4A13"/>
+ <TestFrame time="3270" hash="DA60100DC55023C3BAB367D97C8F6A85"/>
+ <TestFrame time="3300" hash="79EC710576427DF73DD03F39FBA6E2EB"/>
+ <TestFrame time="3330" hash="FFD39C1122FE2F7877EF30591B539B40"/>
+ <TestFrame time="3360" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="3390" hash="29ECE1BCA4D21FB5862091317D430A13"/>
+ <TestFrame time="3420" hash="C1A7B7D6D64AC5584C073C2881290696"/>
+ <TestFrame time="3450" hash="4AC43A03CC6F2020AB5F894D704092AC"/>
+ <TestFrame time="3480" hash="6CC9DE62A0C8FA5E42EAC1B01E99AC32"/>
+ <TestFrame time="3510" hash="D754D35D0793F9F7D4F6249A874E4C45"/>
+ <TestFrame time="3540" hash="B2C778A5EFF5F01EDC54F03D8B4DE8C7"/>
+ <TestFrame time="3570" hash="A4D9DFDBF32C0AD31794B04A2E23A0DB"/>
+ <TestFrame time="3600" hash="5025EB75C88F0760F637E0342B7F88A2"/>
+ <TestFrame time="3630" hash="F4732FF2DF93FE67CB850DEC34184924"/>
+ <TestFrame time="3660" hash="97566CE9558D13EA0780BCE233097B27"/>
+ <TestFrame time="3690" hash="2AD64CB01C9D50E0118D5ECE0A644DF2"/>
+ <TestFrame time="3720" hash="721D7061811B5439C2E8E395917494BC"/>
+ <TestFrame time="3750" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="3780" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="3810" hash="336D31586171F22D541B989D24B95CBB"/>
+ <TestFrame time="3840" hash="6D63FB5C8A80F0280E88B2CDF8641BB9"/>
+ <TestFrame time="3870" hash="EF8941674CB61F54853DC33652BB854E"/>
+ <TestFrame time="3900" hash="0C20D12464ABBDC45041EA5D9F2719B1"/>
+ <TestFrame time="3930" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="3960" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="3990" hash="A88A8129259F86DF5A73ADDC3649AD37"/>
+ <TestFrame time="4020" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="4050" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="4080" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4110" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4140" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4170" hash="1373545E43FFF7251CEC9E8375EA267F"/>
+ <TestFrame time="4200" hash="E553F365912586C6408C8C53B1B7D118"/>
+ <TestFrame time="4230" hash="3DB5E30EF19EA693C21CCF72892C4390"/>
+ <TestFrame time="4260" hash="A8B624EBFC9AB713D1CE55F318A6E90D"/>
+ <TestFrame time="4290" hash="AF3120FE262D2489C0ED33FBBEE1549F"/>
+ <TestFrame time="4320" hash="53AE93140252373EAA4D9DA73756BD8E"/>
+ <TestFrame time="4350" hash="BC426FB7C31751665B0D3F16E2CB0173"/>
+ <TestFrame time="4380" hash="DD60CBAFF6F34027474E92315DBC0EBC"/>
+ <TestFrame time="4410" hash="F0D8132489C2F2EF760E905B3C093726"/>
+ <TestFrame time="4440" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4470" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="4500" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4530" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="4560" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="4590" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="4620" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4650" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4680" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4710" hash="3042003C067B257DE2CB32F650DDE693"/>
+ <TestFrame time="4740" hash="A725B59B4947357546BBFC7DF3D830AF"/>
+ <TestFrame time="4770" hash="CE57E27AF329EBA4FAC3AB891F0407CE"/>
+ <TestFrame time="4800" hash="41BA853C3403F68A23E708DF82E21C53"/>
+ <TestFrame time="4830" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4860" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+ <TestFrame time="4890" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4920" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="4950" hash="DCF2867C127E041970047EC8F3EDC04F"/>
+ <TestFrame time="4980" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="5010" hash="675EBBDD22DD22CE45993DF4AF1ACFE9"/>
+ <TestFrame time="5040" hash="A350B70C5238A340E85FD4A3EC0390A3"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.xml b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.xml
new file mode 100644
index 0000000..bb411e2
--- /dev/null
+++ b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.xml
@@ -0,0 +1,13 @@
+<Rect id="rect" width="120" height="200" color="white">
+ <Image id="img" file="pics/qtlogo.png"
+ x="{60-img.width/2}" y="{200-img.height}">
+ <y>
+ <SerialAnimation running="true" repeat="true">
+ <NumericAnimation to="{200-img.height}"
+ easing="easeOutBounce(amplitude:100)"
+ duration="2000" />
+ <PauseAnimation duration="1000" />
+ </SerialAnimation>
+ </y>
+ </Image>
+</Rect>
diff --git a/tests/auto/declarative/visual/pauseAnimation/pics/qtlogo.png b/tests/auto/declarative/visual/pauseAnimation/pics/qtlogo.png
new file mode 100644
index 0000000..399bd0b
--- /dev/null
+++ b/tests/auto/declarative/visual/pauseAnimation/pics/qtlogo.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qfxtext/elide/data/opengl/image0.png b/tests/auto/declarative/visual/qfxtext/elide/data/opengl/image0.png
new file mode 100644
index 0000000..7d45407
--- /dev/null
+++ b/tests/auto/declarative/visual/qfxtext/elide/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qfxtext/elide/data/opengl/manifest.xml b/tests/auto/declarative/visual/qfxtext/elide/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/qfxtext/elide/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/qfxtext/elide/elide.xml b/tests/auto/declarative/visual/qfxtext/elide/elide.xml
new file mode 100644
index 0000000..398da82
--- /dev/null
+++ b/tests/auto/declarative/visual/qfxtext/elide/elide.xml
@@ -0,0 +1,6 @@
+<VerticalLayout width="80" height="{Text.height*4}">
+ <Text elide="ElideLeft" text="aaa bbb ccc ddd eee fff" width="80" color="white" id="Text"/>
+ <Text elide="ElideMiddle" text="aaa bbb ccc ddd eee fff" width="80" color="white"/>
+ <Text elide="ElideRight" text="aaa bbb ccc ddd eee fff" width="80" color="white"/>
+ <Text elide="ElideNone" text="aaa bbb ccc ddd eee fff" width="80" color="white"/>
+</VerticalLayout>
diff --git a/tests/auto/declarative/visual/qfxtext/elide/test b/tests/auto/declarative/visual/qfxtext/elide/test
new file mode 100644
index 0000000..d35cbc9
--- /dev/null
+++ b/tests/auto/declarative/visual/qfxtext/elide/test
@@ -0,0 +1 @@
+elide.xml
diff --git a/tests/auto/declarative/visual/repeater/basic1/basic1.xml b/tests/auto/declarative/visual/repeater/basic1/basic1.xml
new file mode 100644
index 0000000..def809f
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic1/basic1.xml
@@ -0,0 +1,21 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <HorizontalLayout>
+ <Repeater >
+ <component>
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </component>
+ <dataSource>
+ <ListModel>
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ </dataSource>
+ </Repeater>
+ </HorizontalLayout>
+</Rect>
diff --git a/tests/auto/declarative/visual/repeater/basic1/data/opengl/image0.png b/tests/auto/declarative/visual/repeater/basic1/data/opengl/image0.png
new file mode 100644
index 0000000..f0be97f
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic1/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/repeater/basic1/data/opengl/manifest.xml b/tests/auto/declarative/visual/repeater/basic1/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic1/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/repeater/basic1/test b/tests/auto/declarative/visual/repeater/basic1/test
new file mode 100644
index 0000000..62f0665
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic1/test
@@ -0,0 +1 @@
+basic1.xml
diff --git a/tests/auto/declarative/visual/repeater/basic2/basic2.xml b/tests/auto/declarative/visual/repeater/basic2/basic2.xml
new file mode 100644
index 0000000..b16fbfe
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic2/basic2.xml
@@ -0,0 +1,22 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <Component id="Delegate">
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </Component>
+
+ <HorizontalLayout>
+ <Repeater component="{Delegate}">
+ <dataSource>
+ <ListModel>
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ </dataSource>
+ </Repeater>
+ </HorizontalLayout>
+</Rect>
diff --git a/tests/auto/declarative/visual/repeater/basic2/data/opengl/image0.png b/tests/auto/declarative/visual/repeater/basic2/data/opengl/image0.png
new file mode 100644
index 0000000..f0be97f
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic2/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/repeater/basic2/data/opengl/manifest.xml b/tests/auto/declarative/visual/repeater/basic2/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic2/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/repeater/basic2/test b/tests/auto/declarative/visual/repeater/basic2/test
new file mode 100644
index 0000000..ae974fe
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic2/test
@@ -0,0 +1 @@
+basic2.xml
diff --git a/tests/auto/declarative/visual/repeater/basic3/basic3.xml b/tests/auto/declarative/visual/repeater/basic3/basic3.xml
new file mode 100644
index 0000000..1135f16
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic3/basic3.xml
@@ -0,0 +1,19 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <ListModel id="DataSource">
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ <HorizontalLayout>
+ <Repeater dataSource="{DataSource}">
+ <component>
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </component>
+ </Repeater>
+ </HorizontalLayout>
+</Rect>
diff --git a/tests/auto/declarative/visual/repeater/basic3/data/opengl/image0.png b/tests/auto/declarative/visual/repeater/basic3/data/opengl/image0.png
new file mode 100644
index 0000000..f0be97f
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic3/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/repeater/basic3/data/opengl/manifest.xml b/tests/auto/declarative/visual/repeater/basic3/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic3/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/repeater/basic3/test b/tests/auto/declarative/visual/repeater/basic3/test
new file mode 100644
index 0000000..ea3154e
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic3/test
@@ -0,0 +1 @@
+basic3.xml
diff --git a/tests/auto/declarative/visual/repeater/basic4/basic4.xml b/tests/auto/declarative/visual/repeater/basic4/basic4.xml
new file mode 100644
index 0000000..53b8ff9
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic4/basic4.xml
@@ -0,0 +1,18 @@
+<Rect color="blue" width="800" height="600" id="Page">
+ <ListModel id="DataSource">
+ <Month>
+ <name>January</name>
+ </Month>
+ <Month>
+ <name>February</name>
+ </Month>
+ </ListModel>
+ <Component id="Delegate">
+ <Rect color="red" width="100" height="100">
+ <Text text="{name}" />
+ </Rect>
+ </Component>
+ <HorizontalLayout>
+ <Repeater dataSource="{DataSource}" component="{Delegate}" />
+ </HorizontalLayout>
+</Rect>
diff --git a/tests/auto/declarative/visual/repeater/basic4/data/opengl/image0.png b/tests/auto/declarative/visual/repeater/basic4/data/opengl/image0.png
new file mode 100644
index 0000000..f0be97f
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic4/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/repeater/basic4/data/opengl/manifest.xml b/tests/auto/declarative/visual/repeater/basic4/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic4/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/repeater/basic4/test b/tests/auto/declarative/visual/repeater/basic4/test
new file mode 100644
index 0000000..891e0be
--- /dev/null
+++ b/tests/auto/declarative/visual/repeater/basic4/test
@@ -0,0 +1 @@
+basic4.xml
diff --git a/tests/auto/declarative/visual/runtests.sh b/tests/auto/declarative/visual/runtests.sh
new file mode 100755
index 0000000..f690381
--- /dev/null
+++ b/tests/auto/declarative/visual/runtests.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+for a in `cat tests`; do ./tst_visual -testdir $a; done
diff --git a/tests/auto/declarative/visual/tests b/tests/auto/declarative/visual/tests
new file mode 100644
index 0000000..ca72e9e
--- /dev/null
+++ b/tests/auto/declarative/visual/tests
@@ -0,0 +1,11 @@
+ListView/basic1
+ListView/basic2
+ListView/basic3
+ListView/basic4
+bindinganimation
+repeater/basic1
+repeater/basic2
+repeater/basic3
+repeater/basic4
+webview/autosize
+qfxtext/elide
diff --git a/tests/auto/declarative/visual/tst_visual.cpp b/tests/auto/declarative/visual/tst_visual.cpp
new file mode 100644
index 0000000..f077994
--- /dev/null
+++ b/tests/auto/declarative/visual/tst_visual.cpp
@@ -0,0 +1,72 @@
+#include <qtest.h>
+#include <QFxView>
+#include <QApplication>
+#include <QFxTestView>
+#include <QFile>
+
+static QString testdir;
+class tst_visual : public QObject
+{
+ Q_OBJECT
+public:
+ tst_visual() {}
+
+private slots:
+ void visual();
+};
+
+#ifdef QT_OPENGL_ES
+#define RASTER_TESTDIR "/data/opengl"
+#else
+#define RASTER_TESTDIR "/data/raster"
+#endif
+
+void tst_visual::visual()
+{
+ QVERIFY(!testdir.isEmpty());
+
+ QFile configFile(QLatin1String(QT_TEST_SOURCE_DIR) + "/" + testdir + "/test");
+ QVERIFY(configFile.open(QIODevice::ReadOnly));
+
+ QString testfile = configFile.readLine().trimmed();
+ QVERIFY(!testfile.isEmpty());
+
+ if(testfile.startsWith("QTDIR/")) {
+ testfile.remove(0, 6);
+ testfile.prepend(QLatin1String(QT_TEST_SOURCE_DIR) + "/../../../../");
+ } else {
+ testfile.prepend(QLatin1String(QT_TEST_SOURCE_DIR) + "/" + testdir + "/");
+ }
+
+ QFxTestView *view = new QFxTestView(testfile, QLatin1String(QT_TEST_SOURCE_DIR) + "/" + testdir + RASTER_TESTDIR);
+ QVERIFY(view->runTest());
+}
+
+#include <QtTest/qtest_gui.h>
+
+int main(int argc, char *argv[])
+{
+ int newArgc = 1;
+ char **newArgv = new char*[argc];
+
+ newArgv[0] = argv[0];
+
+ QApplication app(newArgc, newArgv);
+
+ for(int ii = 1; ii < argc; ii++) {
+ if(QLatin1String(argv[ii]) == "-testdir" && (ii + 1) < argc) {
+ testdir = QLatin1String(argv[ii + 1]);
+ ii++;
+ } else {
+ newArgv[newArgc++] = argv[ii];
+ }
+ }
+
+ tst_visual tc;
+ int rv = QTest::qExec(&tc, newArgc, newArgv);
+
+ delete [] newArgv;
+ return rv;
+}
+
+#include "tst_visual.moc"
diff --git a/tests/auto/declarative/visual/visual.pro b/tests/auto/declarative/visual/visual.pro
new file mode 100644
index 0000000..203b691
--- /dev/null
+++ b/tests/auto/declarative/visual/visual.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_visual.cpp
+
+DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
diff --git a/tests/auto/declarative/visual/webview/autosize/data/opengl/image0.png b/tests/auto/declarative/visual/webview/autosize/data/opengl/image0.png
new file mode 100644
index 0000000..351a7b7
--- /dev/null
+++ b/tests/auto/declarative/visual/webview/autosize/data/opengl/image0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/webview/autosize/data/opengl/manifest.xml b/tests/auto/declarative/visual/webview/autosize/data/opengl/manifest.xml
new file mode 100644
index 0000000..b784f42
--- /dev/null
+++ b/tests/auto/declarative/visual/webview/autosize/data/opengl/manifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestLog>
+ <TestFullFrame time="30" frameId="0"/>
+</TestLog>
diff --git a/tests/auto/declarative/visual/webview/autosize/test b/tests/auto/declarative/visual/webview/autosize/test
new file mode 100644
index 0000000..446d3f9
--- /dev/null
+++ b/tests/auto/declarative/visual/webview/autosize/test
@@ -0,0 +1 @@
+QTDIR/examples/declarative/webview/autosize.qml
diff --git a/tests/auto/dynamicobject/dynamicobject.pro b/tests/auto/dynamicobject/dynamicobject.pro
new file mode 100644
index 0000000..1b2a075
--- /dev/null
+++ b/tests/auto/dynamicobject/dynamicobject.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+SOURCES += tst_qobject.cpp qmetaobjectbuilder.cpp qdynamicmetaobject.cpp
+HEADERS += qmetaobjectbuilder.h qdynamicmetaobject.h
+
+QT = core
+
diff --git a/tests/auto/dynamicobject/qdynamicmetaobject.cpp b/tests/auto/dynamicobject/qdynamicmetaobject.cpp
new file mode 100644
index 0000000..b44555f
--- /dev/null
+++ b/tests/auto/dynamicobject/qdynamicmetaobject.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <qcoreapplication.h>
+
+#include <qmetaobject.h>
+
+#include "qobject.h"
+#include "private/qobject_p.h"
+#include "qmetaobjectbuilder.h"
+#include "qdynamicmetaobject.h"
+
+class QDynamicMetaObjectData
+{
+public:
+ QDynamicMetaObjectData() : ref(1), baseMeta(0), meta(0) {}
+ ~QDynamicMetaObjectData() { qFree(meta); }
+
+ QAtomicInt ref;
+ QMetaObjectBuilder builder;
+ const QMetaObject *baseMeta;
+ QMetaObject *meta;
+};
+
+/*!
+ \class QDynamicMetaObject
+ \brief The QDynamicMetaObject class allows adding signals, slots and properties to
+ QObjects at runtime.
+
+ Any QObject derived class can be extended by creating a QDynamicMetaObject
+ based on the QObject's QMetaObject.
+
+ QObject::setDynamicMetaObject() is called to set the dynamic meta-object for
+ the QObject.
+
+ \sa QMetaObject
+*/
+
+/*!
+ Constructs a dynamic meta-object based on \a baseMetaObject.
+
+ QObject::setDynamicMetaObject() should be called to install it.
+*/
+QDynamicMetaObject::QDynamicMetaObject(const QMetaObject *baseMetaObject)
+{
+ data_ptr = new QDynamicMetaObjectData;
+ data_ptr->baseMeta = baseMetaObject;
+ data_ptr->builder.setSuperClass(data_ptr->baseMeta);
+ data_ptr->builder.setClassName(data_ptr->baseMeta->className());
+ updateMetaData();
+}
+
+/*!
+ Constructs a dynamic meta-object that is a copy of \a other.
+*/
+QDynamicMetaObject::QDynamicMetaObject(const QDynamicMetaObject &other)
+{
+ data_ptr = other.data_ptr;
+ data_ptr->ref.ref();
+}
+
+/*!
+ Destroys the dynamic meta-ovject.
+*/
+QDynamicMetaObject::~QDynamicMetaObject()
+{
+ if (!data_ptr->ref.deref())
+ delete data_ptr;
+}
+
+/*!
+ Copies the dynamic metadata from \a that. The static metadata must be identical,
+ i.e. the dynamic metadata is constructed for the same class.
+*/
+QDynamicMetaObject &QDynamicMetaObject::operator=(const QDynamicMetaObject &that)
+{
+ Q_ASSERT(data_ptr->baseMeta == that.data_ptr->baseMeta);
+ qAtomicAssign(data_ptr, that.data_ptr);
+ return *this;
+}
+
+/*!
+ \internal
+*/
+QDynamicMetaObject &QDynamicMetaObject::operator=(const QMetaObject &that)
+{
+ static_cast<QMetaObject*>(this)->d = that.d;
+ return *this;
+}
+
+/*!
+ \internal
+*/
+void QDynamicMetaObject::detach()
+{
+ if (data_ptr->ref == 1)
+ return;
+
+ //XXX copy builder faster.
+ QByteArray buf;
+ QDataStream ds(&buf, QIODevice::ReadWrite);
+ data_ptr->builder.serialize(ds);
+ if (!data_ptr->ref.deref())
+ delete data_ptr;
+ data_ptr = new QDynamicMetaObjectData;
+ QMap<QByteArray, const QMetaObject *> refs;
+ data_ptr->builder.deserialize(ds, refs);
+ updateMetaData();
+}
+
+/*!
+ Adds the signal with \a signature.
+*/
+void QDynamicMetaObject::addSignal(const char *signature)
+{
+ detach();
+ data_ptr->builder.addSignal(signature);
+ updateMetaData();
+}
+
+/*!
+ Adds the signal with \a signature and sets the \a parameterNames.
+*/
+void QDynamicMetaObject::addSignal(const char *signature, const QList<QByteArray> &parameterNames)
+{
+ detach();
+ QMetaMethodBuilder method = data_ptr->builder.addSignal(signature);
+ method.setParameterNames(parameterNames);
+ updateMetaData();
+}
+
+/*!
+ Adds the slot with \a signature.
+*/
+void QDynamicMetaObject::addSlot(const char *signature)
+{
+ detach();
+ data_ptr->builder.addSlot(signature);
+ updateMetaData();
+}
+
+
+/*!
+ Adds the slot with \a signature and sets the \a parameterNames.
+*/
+void QDynamicMetaObject::addSlot(const char *signature, const QList<QByteArray> &parameterNames)
+{
+ detach();
+ QMetaMethodBuilder method = data_ptr->builder.addSlot(signature);
+ method.setParameterNames(parameterNames);
+ updateMetaData();
+}
+
+/*!
+ Adds the property with \a name of \a type. If \a notifier specified it is
+ set as the change notifier for the property.
+*/
+void QDynamicMetaObject::addProperty(const char *name, const char *type, const char *notifier)
+{
+ int notifierId = -1;
+ if (notifier)
+ notifierId = data_ptr->builder.indexOfSignal(notifier);
+ data_ptr->builder.addProperty(name, type, notifierId);
+ updateMetaData();
+}
+
+/*!
+ Adds the property with \a name of \a type. If \a notifierId is specified it is
+ set as the change notifier for the property.
+*/
+void QDynamicMetaObject::addProperty(const char *name, const char *type, int notifierId)
+{
+ data_ptr->builder.addProperty(name, type, notifierId);
+ updateMetaData();
+}
+
+/*!
+ \reimp
+*/
+int QDynamicMetaObject::metaCall(QObject *object, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod && _id >= data_ptr->baseMeta->methodCount()) {
+ QMetaMethod metaMethod = method(_id);
+ if (metaMethod.methodType() == QMetaMethod::Slot) {
+ if (metaMethod.parameterTypes().count() == 0) {
+ static QList<QVariant> noArgs;
+ callSlot(object, _id, noArgs);
+ } else {
+ QList<QVariant> args;
+ for (int i = 0; i < metaMethod.parameterTypes().count(); ++i) {
+ int typeId = QVariant::nameToType(metaMethod.parameterTypes().at(i));
+ args.append(QVariant(typeId, _a[i+1]));
+ }
+ callSlot(object, _id, args);
+ }
+ } else if (metaMethod.methodType() == QMetaMethod::Signal)
+ activate(object, _id, _a);
+ _id = -1;
+ } else if (_c == QMetaObject::ReadProperty && _id >= data_ptr->baseMeta->propertyCount()) {
+ *(reinterpret_cast<QVariant*>(_a[1])) = readProperty(object, _id);
+ _id = -1;
+ } else if (_c == QMetaObject::WriteProperty && _id >= data_ptr->baseMeta->propertyCount()) {
+ writeProperty(object, _id, *(reinterpret_cast<QVariant*>(_a[1])));
+ if (property(_id).hasNotifySignal())
+ activate(object, property(_id).notifySignalIndex(), 0);
+ _id = -1;
+ } else {
+ _id = object->qt_metacall(_c, _id, _a);
+ }
+
+ return _id;
+}
+
+/*!
+ The slot with \a id has been called for \a object. The parameters are available via \a args.
+*/
+void QDynamicMetaObject::callSlot(QObject *object, int id, const QList<QVariant> &args)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(id);
+ Q_UNUSED(args);
+}
+
+/*!
+ The \a value of property with \a id has changed for \a object.
+*/
+void QDynamicMetaObject::writeProperty(QObject *object, int id, const QVariant &value)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(id);
+ Q_UNUSED(value);
+}
+
+/*!
+ Return the value of the property with \a id belonging to \a object.
+*/
+QVariant QDynamicMetaObject::readProperty(QObject *object, int id) const
+{
+ Q_UNUSED(object);
+ Q_UNUSED(id);
+ return QVariant();
+}
+
+void QDynamicMetaObject::updateMetaData()
+{
+ qFree(data_ptr->meta);
+ data_ptr->meta = data_ptr->builder.toMetaObject();
+ *this = *data_ptr->meta;
+}
+
diff --git a/tests/auto/dynamicobject/qdynamicmetaobject.h b/tests/auto/dynamicobject/qdynamicmetaobject.h
new file mode 100644
index 0000000..747d118
--- /dev/null
+++ b/tests/auto/dynamicobject/qdynamicmetaobject.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#ifndef _QDYNAMICMETAOBJECT_H_
+#define _QDYNAMICMETAOBJECT_H_
+
+#include <qmetaobject.h>
+#include <qobject.h>
+
+class QDynamicMetaObjectData;
+
+class QDynamicMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QDynamicMetaObject(const QMetaObject *baseMetaObject);
+ QDynamicMetaObject(const QDynamicMetaObject &other);
+ virtual ~QDynamicMetaObject();
+
+ QDynamicMetaObject &operator=(const QDynamicMetaObject &that);
+
+ void addSignal(const char *sigName);
+ void addSignal(const char *sigName, const QList<QByteArray> &parameterNames);
+ void addSlot(const char *slotName);
+ void addSlot(const char *slotName, const QList<QByteArray> &parameterNames);
+ void addProperty(const char *name, const char *type, const char *notifier);
+ void addProperty(const char *name, const char *type, int notifierId=-1);
+
+protected:
+ virtual int metaCall(QObject *object, QMetaObject::Call _c, int _id, void **_a);
+ virtual void callSlot(QObject *object, int id, const QList<QVariant> &args);
+ virtual void writeProperty(QObject *object, int id, const QVariant &value);
+ virtual QVariant readProperty(QObject *object, int id) const;
+
+private:
+ void detach();
+ void updateMetaData();
+ QDynamicMetaObject &operator=(const QMetaObject &that);
+
+private:
+ QDynamicMetaObjectData *data_ptr;
+};
+
+#endif
diff --git a/tests/auto/dynamicobject/qmetaobjectbuilder.cpp b/tests/auto/dynamicobject/qmetaobjectbuilder.cpp
new file mode 100644
index 0000000..3927f6a
--- /dev/null
+++ b/tests/auto/dynamicobject/qmetaobjectbuilder.cpp
@@ -0,0 +1,2347 @@
+/****************************************************************************
+**
+** This file is part of the $PACKAGE_NAME$.
+**
+** Copyright (C) $THISYEAR$ $COMPANY_NAME$.
+**
+** $QT_EXTENDED_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include "qmetaobjectbuilder.h"
+#include <QDebug>
+
+/*!
+ \class QMetaObjectBuilder
+ \brief The QMetaObjectBuilder class supports the building of QMetaObject objects at runtime.
+
+ See the QDynamicMetaObject class documentation for an example
+ of using this class.
+
+ \sa QDynamicMetaObject, QDynamicObject
+*/
+
+/*!
+ \enum QMetaObjectBuilder::AddMember
+ This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject()
+
+ \value ClassName Add the class name.
+ \value SuperClass Add the super class.
+ \value Methods Add methods that aren't signals or slots.
+ \value Signals Add signals.
+ \value Slots Add slots.
+ \value Constructors Add constructors.
+ \value Properties Add properties.
+ \value Enumerators Add enumerators.
+ \value ClassInfos Add items of class information.
+ \value RelatedMetaObjects Add related meta objects.
+ \value StaticMetacall Add the static metacall function.
+ \value PublicMethods Add public methods (ignored for signals).
+ \value ProtectedMethods Add protected methods (ignored for signals).
+ \value PrivateMethods All private methods (ignored for signals).
+ \value AllMembers Add all members.
+ \value AllPrimaryMembers Add everything except the class name, super class, and static metacall function.
+*/
+
+// copied from qmetaobject.cpp
+// do not touch without touching the moc as well
+enum PropertyFlags {
+ Invalid = 0x00000000,
+ Readable = 0x00000001,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ EnumOrFlag = 0x00000008,
+ StdCppSet = 0x00000100,
+// Override = 0x00000200,
+ Designable = 0x00001000,
+ ResolveDesignable = 0x00002000,
+ Scriptable = 0x00004000,
+ ResolveScriptable = 0x00008000,
+ Stored = 0x00010000,
+ ResolveStored = 0x00020000,
+ Editable = 0x00040000,
+ ResolveEditable = 0x00080000,
+ User = 0x00100000,
+ ResolveUser = 0x00200000,
+ Notify = 0x00400000
+};
+
+enum MethodFlags {
+ AccessPrivate = 0x00,
+ AccessProtected = 0x01,
+ AccessPublic = 0x02,
+ AccessMask = 0x03, //mask
+
+ MethodMethod = 0x00,
+ MethodSignal = 0x04,
+ MethodSlot = 0x08,
+ MethodConstructor = 0x0c,
+ MethodTypeMask = 0x0c,
+
+ MethodCompatibility = 0x10,
+ MethodCloned = 0x20,
+ MethodScriptable = 0x40
+};
+
+struct QMetaObjectPrivate
+{
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ int propertyCount, propertyData;
+ int enumeratorCount, enumeratorData;
+ int constructorCount, constructorData;
+};
+
+static inline const QMetaObjectPrivate *priv(const uint* data)
+{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
+// end of copied lines from qmetaobject.cpp
+
+class QMetaMethodBuilderPrivate
+{
+public:
+ QMetaMethodBuilderPrivate
+ (QMetaMethod::MethodType _methodType,
+ const QByteArray& _signature,
+ const QByteArray& _returnType = QByteArray(),
+ QMetaMethod::Access _access = QMetaMethod::Public)
+ : signature(QMetaObject::normalizedSignature(_signature.constData())),
+ returnType(QMetaObject::normalizedType(_returnType)),
+ attributes(((int)_access) | (((int)_methodType) << 2))
+ {
+ }
+
+ QByteArray signature;
+ QByteArray returnType;
+ QList<QByteArray> parameterNames;
+ QByteArray tag;
+ int attributes;
+
+ QMetaMethod::MethodType methodType() const
+ {
+ return (QMetaMethod::MethodType)((attributes & MethodTypeMask) >> 2);
+ }
+
+ QMetaMethod::Access access() const
+ {
+ return (QMetaMethod::Access)(attributes & AccessMask);
+ }
+
+ void setAccess(QMetaMethod::Access value)
+ {
+ attributes = ((attributes & ~AccessMask) | (int)value);
+ }
+};
+
+class QMetaPropertyBuilderPrivate
+{
+public:
+ QMetaPropertyBuilderPrivate
+ (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1)
+ : name(_name),
+ type(QMetaObject::normalizedType(_type.constData())),
+ flags(Readable | Writable), notifySignal(-1)
+ {
+ if (notifierIdx >= 0) {
+ flags |= Notify;
+ notifySignal = notifierIdx;
+ }
+ }
+
+ QByteArray name;
+ QByteArray type;
+ int flags;
+ int notifySignal;
+
+ bool flag(int f) const
+ {
+ return ((flags & f) != 0);
+ }
+
+ void setFlag(int f, bool value)
+ {
+ if (value)
+ flags |= f;
+ else
+ flags &= ~f;
+ }
+};
+
+class QMetaEnumBuilderPrivate
+{
+public:
+ QMetaEnumBuilderPrivate(const QByteArray& _name)
+ : name(_name), isFlag(false)
+ {
+ }
+
+ QByteArray name;
+ bool isFlag;
+ QList<QByteArray> keys;
+ QList<int> values;
+};
+
+class QMetaObjectBuilderPrivate
+{
+public:
+ QMetaObjectBuilderPrivate()
+ {
+ superClass = &QObject::staticMetaObject;
+ staticMetacallFunction = 0;
+ }
+
+ QByteArray className;
+ const QMetaObject *superClass;
+ QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
+ QList<QMetaMethodBuilderPrivate> methods;
+ QList<QMetaMethodBuilderPrivate> constructors;
+ QList<QMetaPropertyBuilderPrivate> properties;
+ QList<QByteArray> classInfoNames;
+ QList<QByteArray> classInfoValues;
+ QList<QMetaEnumBuilderPrivate> enumerators;
+ QList<const QMetaObject *> relatedMetaObjects;
+};
+
+/*!
+ Constructs a new QMetaObjectBuilder.
+*/
+QMetaObjectBuilder::QMetaObjectBuilder()
+{
+ d = new QMetaObjectBuilderPrivate();
+}
+
+/*!
+ Constructs a new QMetaObjectBuilder which is a copy of the
+ meta object information in \a prototype. Note: the super class
+ contents for \a prototype are not copied, only the immediate
+ class that is defined by \a prototype.
+
+ The \a members parameter indicates which members of \a prototype
+ should be added. The default is AllMembers.
+
+ \sa addMetaObject()
+*/
+QMetaObjectBuilder::QMetaObjectBuilder
+ (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
+{
+ d = new QMetaObjectBuilderPrivate();
+ addMetaObject(prototype, members);
+}
+
+/*!
+ Destroys this meta object builder.
+*/
+QMetaObjectBuilder::~QMetaObjectBuilder()
+{
+ delete d;
+}
+
+/*!
+ Returns the name of the class being constructed by this
+ meta object builder. The default value is an empty QByteArray.
+
+ \sa setClassName(), superClass()
+*/
+QByteArray QMetaObjectBuilder::className() const
+{
+ return d->className;
+}
+
+/*!
+ Sets the \a name of the class being constructed by this
+ meta object builder.
+
+ \sa className(), setSuperClass()
+*/
+void QMetaObjectBuilder::setClassName(const QByteArray& name)
+{
+ d->className = name;
+}
+
+/*!
+ Returns the superclass meta object of the class being constructed
+ by this meta object builder. The default value is the meta object
+ for QObject.
+
+ \sa setSuperClass(), className()
+*/
+const QMetaObject *QMetaObjectBuilder::superClass() const
+{
+ return d->superClass;
+}
+
+/*!
+ Sets the superclass meta object of the class being constructed
+ by this meta object builder to \a meta. The \a meta parameter
+ must not be null.
+
+ \sa superClass(), setClassName()
+*/
+void QMetaObjectBuilder::setSuperClass(const QMetaObject *meta)
+{
+ Q_ASSERT(meta);
+ d->superClass = meta;
+}
+
+/*!
+ Returns the number of methods in this class, excluding the number
+ of methods in the base class. These include signals and slots
+ as well as normal member functions.
+
+ \sa addMethod(), method(), removeMethod(), indexOfMethod()
+*/
+int QMetaObjectBuilder::methodCount() const
+{
+ return d->methods.size();
+}
+
+/*!
+ Returns the number of constructors in this class.
+
+ \sa addConstructor(), constructor(), removeConstructor(), indexOfConstructor()
+*/
+int QMetaObjectBuilder::constructorCount() const
+{
+ return d->constructors.size();
+}
+
+/*!
+ Returns the number of properties in this class, excluding the number
+ of properties in the base class.
+
+ \sa addProperty(), property(), removeProperty(), indexOfProperty()
+*/
+int QMetaObjectBuilder::propertyCount() const
+{
+ return d->properties.size();
+}
+
+/*!
+ Returns the number of enumerators in this class, excluding the
+ number of enumerators in the base class.
+
+ \sa addEnumerator(), enumerator(), removeEnumerator()
+ \sa indexOfEnumerator()
+*/
+int QMetaObjectBuilder::enumeratorCount() const
+{
+ return d->enumerators.size();
+}
+
+/*!
+ Returns the number of items of class information in this class,
+ exclusing the number of items of class information in the base class.
+
+ \sa addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo()
+ \sa indexOfClassInfo()
+*/
+int QMetaObjectBuilder::classInfoCount() const
+{
+ return d->classInfoNames.size();
+}
+
+/*!
+ Returns the number of related meta objects that are associated
+ with this class.
+
+ Related meta objects are used when resolving the enumerated type
+ associated with a property, where the enumerated type is in a
+ different class from the property.
+
+ \sa addRelatedMetaObject(), relatedMetaObject()
+ \sa removeRelatedMetaObject()
+*/
+int QMetaObjectBuilder::relatedMetaObjectCount() const
+{
+ return d->relatedMetaObjects.size();
+}
+
+/*!
+ Adds a new public method to this class with the specified \a signature.
+ Returns an object that can be used to adjust the other attributes
+ of the method. The \a signature will be normalized before it is
+ added to the class.
+
+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
+{
+ int index = d->methods.size();
+ d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
+ return QMetaMethodBuilder(this, index);
+}
+
+/*!
+ Adds a new public method to this class with the specified
+ \a signature and \a returnType. Returns an object that can be
+ used to adjust the other attributes of the method. The \a signature
+ and \a returnType will be normalized before they are added to
+ the class. If \a returnType is empty, then it indicates that
+ the method has \c{void} as its return type.
+
+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addMethod
+ (const QByteArray& signature, const QByteArray& returnType)
+{
+ int index = d->methods.size();
+ d->methods.append(QMetaMethodBuilderPrivate
+ (QMetaMethod::Method, signature, returnType));
+ return QMetaMethodBuilder(this, index);
+}
+
+/*!
+ Adds a new public method to this class that has the same information as
+ \a prototype. This is used to clone the methods of an existing
+ QMetaObject. Returns an object that can be used to adjust the
+ attributes of the method.
+
+ This function will detect if \a prototype is an ordinary method,
+ signal, slot, or constructor and act accordingly.
+
+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
+{
+ QMetaMethodBuilder method;
+ if (prototype.methodType() == QMetaMethod::Method)
+ method = addMethod(prototype.signature());
+ else if (prototype.methodType() == QMetaMethod::Signal)
+ method = addSignal(prototype.signature());
+ else if (prototype.methodType() == QMetaMethod::Slot)
+ method = addSlot(prototype.signature());
+ else if (prototype.methodType() == QMetaMethod::Constructor)
+ method = addConstructor(prototype.signature());
+ method.setReturnType(prototype.typeName());
+ method.setParameterNames(prototype.parameterNames());
+ method.setTag(prototype.tag());
+ method.setAccess(prototype.access());
+ method.setAttributes(prototype.attributes());
+ return method;
+}
+
+/*!
+ Adds a new public slot to this class with the specified \a signature.
+ Returns an object that can be used to adjust the other attributes
+ of the slot. The \a signature will be normalized before it is
+ added to the class.
+
+ \sa addMethod(), addSignal(), indexOfSlot()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
+{
+ int index = d->methods.size();
+ d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
+ return QMetaMethodBuilder(this, index);
+}
+
+/*!
+ Adds a new signal to this class with the specified \a signature.
+ Returns an object that can be used to adjust the other attributes
+ of the signal. The \a signature will be normalized before it is
+ added to the class.
+
+ \sa addMethod(), addSlot(), indexOfSignal()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
+{
+ int index = d->methods.size();
+ d->methods.append(QMetaMethodBuilderPrivate
+ (QMetaMethod::Signal, signature, QByteArray(), QMetaMethod::Protected));
+ return QMetaMethodBuilder(this, index);
+}
+
+/*!
+ Adds a new constructor to this class with the specified \a signature.
+ Returns an object that can be used to adjust the other attributes
+ of the constructor. The \a signature will be normalized before it is
+ added to the class.
+
+ \sa constructor(), constructorCount(), removeConstructor()
+ \sa indexOfConstructor()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
+{
+ int index = d->constructors.size();
+ d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature));
+ return QMetaMethodBuilder(this, -(index + 1));
+}
+
+/*!
+ Adds a new constructor to this class that has the same information as
+ \a prototype. This is used to clone the constructors of an existing
+ QMetaObject. Returns an object that can be used to adjust the
+ attributes of the constructor.
+
+ This function requires that \a prototype be a constructor.
+
+ \sa constructor(), constructorCount(), removeConstructor()
+ \sa indexOfConstructor()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype)
+{
+ Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor);
+ QMetaMethodBuilder ctor = addConstructor(prototype.signature());
+ ctor.setReturnType(prototype.typeName());
+ ctor.setParameterNames(prototype.parameterNames());
+ ctor.setTag(prototype.tag());
+ ctor.setAccess(prototype.access());
+ ctor.setAttributes(prototype.attributes());
+ return ctor;
+}
+
+/*!
+ Adds a new readable/writable property to this class with the specified
+ \a name and \a type. Returns an object that can be used to adjust
+ the other attributes of the property. The \a type will be
+ normalized before it is added to the class.
+
+ \sa property(), propertyCount(), removeProperty(), indexOfProperty()
+*/
+QMetaPropertyBuilder QMetaObjectBuilder::addProperty
+ (const QByteArray& name, const QByteArray& type, int notifierId)
+{
+ int index = d->properties.size();
+ d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
+ return QMetaPropertyBuilder(this, index);
+}
+
+/*!
+ Adds a new property to this class that has the same information as
+ \a prototype. This is used to clone the properties of an existing
+ QMetaObject. Returns an object that can be used to adjust the
+ attributes of the property.
+
+ \sa property(), propertyCount(), removeProperty(), indexOfProperty()
+*/
+QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype)
+{
+ QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
+ property.setReadable(prototype.isReadable());
+ property.setWritable(prototype.isWritable());
+ property.setResettable(prototype.isResettable());
+ property.setDesignable(prototype.isDesignable());
+ property.setScriptable(prototype.isScriptable());
+ property.setStored(prototype.isStored());
+ property.setEditable(prototype.isEditable());
+ property.setUser(prototype.isUser());
+ property.setStdCppSet(prototype.hasStdCppSet());
+ property.setEnumOrFlag(prototype.isEnumType());
+ if (prototype.hasNotifySignal()) {
+ // Find an existing method for the notify signal, or add a new one.
+ QMetaMethod method = prototype.notifySignal();
+ int index = indexOfMethod(method.signature());
+ if (index == -1)
+ index = addMethod(method).index();
+ d->properties[property._index].notifySignal = index;
+ d->properties[property._index].setFlag(Notify, true);
+ }
+ return property;
+}
+
+/*!
+ Adds a new enumerator to this class with the specified
+ \a name. Returns an object that can be used to adjust
+ the other attributes of the enumerator.
+
+ \sa enumerator(), enumeratorCount(), removeEnumerator(),
+ \sa indexOfEnumerator()
+*/
+QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
+{
+ int index = d->enumerators.size();
+ d->enumerators.append(QMetaEnumBuilderPrivate(name));
+ return QMetaEnumBuilder(this, index);
+}
+
+/*!
+ Adds a new enumerator to this class that has the same information as
+ \a prototype. This is used to clone the enumerators of an existing
+ QMetaObject. Returns an object that can be used to adjust the
+ attributes of the enumerator.
+
+ \sa enumerator(), enumeratorCount(), removeEnumerator(),
+ \sa indexOfEnumerator()
+*/
+QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
+{
+ QMetaEnumBuilder en = addEnumerator(prototype.name());
+ en.setIsFlag(prototype.isFlag());
+ int count = prototype.keyCount();
+ for (int index = 0; index < count; ++index)
+ en.addKey(prototype.key(index), prototype.value(index));
+ return en;
+}
+
+/*!
+ Adds \a name and \a value as an item of class information to this class.
+ Returns the index of the new item of class information.
+
+ \sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
+ \sa indexOfClassInfo()
+*/
+int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& value)
+{
+ int index = d->classInfoNames.size();
+ d->classInfoNames += name;
+ d->classInfoValues += value;
+ return index;
+}
+
+/*!
+ Adds \a meta to this class as a related meta object. Returns
+ the index of the new related meta object entry.
+
+ Related meta objects are used when resolving the enumerated type
+ associated with a property, where the enumerated type is in a
+ different class from the property.
+
+ \sa relatedMetaObjectCount(), relatedMetaObject()
+ \sa removeRelatedMetaObject()
+*/
+int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
+{
+ Q_ASSERT(meta);
+ int index = d->relatedMetaObjects.size();
+ d->relatedMetaObjects.append(meta);
+ return index;
+}
+
+/*!
+ Adds the contents of \a prototype to this meta object builder.
+ This function is useful for cloning the contents of an existing QMetaObject.
+
+ The \a members parameter indicates which members of \a prototype
+ should be added. The default is AllMembers.
+*/
+void QMetaObjectBuilder::addMetaObject
+ (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
+{
+ Q_ASSERT(prototype);
+ int index;
+
+ if ((members & ClassName) != 0)
+ d->className = prototype->className();
+
+ if ((members & SuperClass) != 0)
+ d->superClass = prototype->superClass();
+
+ if ((members & (Methods | Signals | Slots)) != 0) {
+ for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) {
+ QMetaMethod method = prototype->method(index);
+ if (method.methodType() != QMetaMethod::Signal) {
+ if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0)
+ continue;
+ if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0)
+ continue;
+ if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0)
+ continue;
+ }
+ if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) {
+ addMethod(method);
+ } else if (method.methodType() == QMetaMethod::Signal &&
+ (members & Signals) != 0) {
+ addMethod(method);
+ } else if (method.methodType() == QMetaMethod::Slot &&
+ (members & Slots) != 0) {
+ addMethod(method);
+ }
+ }
+ }
+
+ if ((members & Constructors) != 0) {
+ for (index = 0; index < prototype->constructorCount(); ++index)
+ addConstructor(prototype->constructor(index));
+ }
+
+ if ((members & Properties) != 0) {
+ for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index)
+ addProperty(prototype->property(index));
+ }
+
+ if ((members & Enumerators) != 0) {
+ for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index)
+ addEnumerator(prototype->enumerator(index));
+ }
+
+ if ((members & ClassInfos) != 0) {
+ for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) {
+ QMetaClassInfo ci = prototype->classInfo(index);
+ addClassInfo(ci.name(), ci.value());
+ }
+ }
+
+ if ((members & RelatedMetaObjects) != 0) {
+ const QMetaObject **objects;
+ if (priv(prototype->d.data)->revision < 2) {
+ objects = (const QMetaObject **)(prototype->d.extradata);
+ } else {
+ const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
+ if (extra)
+ objects = extra->objects;
+ else
+ objects = 0;
+ }
+ if (objects) {
+ while (*objects != 0) {
+ addRelatedMetaObject(*objects);
+ ++objects;
+ }
+ }
+ }
+
+ if ((members & StaticMetacall) != 0) {
+ if (priv(prototype->d.data)->revision >= 2) {
+ const QMetaObjectExtraData *extra =
+ (const QMetaObjectExtraData *)(prototype->d.extradata);
+ if (extra && extra->static_metacall)
+ setStaticMetacallFunction(extra->static_metacall);
+ }
+ }
+}
+
+/*!
+ Returns the method at \a index in this class.
+
+ \sa methodCount(), addMethod(), removeMethod(), indexOfMethod()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
+{
+ if (index >= 0 && index < d->methods.size())
+ return QMetaMethodBuilder(this, index);
+ else
+ return QMetaMethodBuilder();
+}
+
+/*!
+ Returns the constructor at \a index in this class.
+
+ \sa methodCount(), addMethod(), removeMethod(), indexOfConstructor()
+*/
+QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
+{
+ if (index >= 0 && index < d->constructors.size())
+ return QMetaMethodBuilder(this, -(index + 1));
+ else
+ return QMetaMethodBuilder();
+}
+
+/*!
+ Returns the property at \a index in this class.
+
+ \sa methodCount(), addMethod(), removeMethod(), indexOfProperty()
+*/
+QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
+{
+ if (index >= 0 && index < d->properties.size())
+ return QMetaPropertyBuilder(this, index);
+ else
+ return QMetaPropertyBuilder();
+}
+
+/*!
+ Returns the enumerator at \a index in this class.
+
+ \sa enumeratorCount(), addEnumerator(), removeEnumerator()
+ \sa indexOfEnumerator()
+*/
+QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
+{
+ if (index >= 0 && index < d->enumerators.size())
+ return QMetaEnumBuilder(this, index);
+ else
+ return QMetaEnumBuilder();
+}
+
+/*!
+ Returns the related meta object at \a index in this class.
+
+ Related meta objects are used when resolving the enumerated type
+ associated with a property, where the enumerated type is in a
+ different class from the property.
+
+ \sa relatedMetaObjectCount(), addRelatedMetaObject()
+ \sa removeRelatedMetaObject()
+*/
+const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const
+{
+ if (index >= 0 && index < d->relatedMetaObjects.size())
+ return d->relatedMetaObjects[index];
+ else
+ return 0;
+}
+
+/*!
+ Returns the name of the item of class information at \a index
+ in this class.
+
+ \sa classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo()
+ \sa indexOfClassInfo()
+*/
+QByteArray QMetaObjectBuilder::classInfoName(int index) const
+{
+ if (index >= 0 && index < d->classInfoNames.size())
+ return d->classInfoNames[index];
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns the value of the item of class information at \a index
+ in this class.
+
+ \sa classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo()
+ \sa indexOfClassInfo()
+*/
+QByteArray QMetaObjectBuilder::classInfoValue(int index) const
+{
+ if (index >= 0 && index < d->classInfoValues.size())
+ return d->classInfoValues[index];
+ else
+ return QByteArray();
+}
+
+/*!
+ Removes the method at \a index from this class. The indices of
+ all following methods will be adjusted downwards by 1. If the
+ method is registered as a notify signal on a property, then the
+ notify signal will be removed from the property.
+
+ \sa methodCount(), addMethod(), method(), indexOfMethod()
+*/
+void QMetaObjectBuilder::removeMethod(int index)
+{
+ if (index >= 0 && index < d->methods.size()) {
+ d->methods.removeAt(index);
+ for (int prop = 0; prop < d->properties.size(); ++prop) {
+ // Adjust the indices of property notify signal references.
+ if (d->properties[prop].notifySignal == index)
+ d->properties[prop].notifySignal = -1;
+ else if (d->properties[prop].notifySignal > index)
+ (d->properties[prop].notifySignal)--;
+ }
+ }
+}
+
+/*!
+ Removes the constructor at \a index from this class. The indices of
+ all following constructors will be adjusted downwards by 1.
+
+ \sa constructorCount(), addConstructor(), constructor()
+ \sa indexOfConstructor()
+*/
+void QMetaObjectBuilder::removeConstructor(int index)
+{
+ if (index >= 0 && index < d->constructors.size())
+ d->constructors.removeAt(index);
+}
+
+/*!
+ Removes the property at \a index from this class. The indices of
+ all following properties will be adjusted downwards by 1.
+
+ \sa propertyCount(), addProperty(), property(), indexOfProperty()
+*/
+void QMetaObjectBuilder::removeProperty(int index)
+{
+ if (index >= 0 && index < d->properties.size())
+ d->properties.removeAt(index);
+}
+
+/*!
+ Removes the enumerator at \a index from this class. The indices of
+ all following enumerators will be adjusted downwards by 1.
+
+ \sa enumertorCount(), addEnumerator(), enumerator()
+ \sa indexOfEnumerator()
+*/
+void QMetaObjectBuilder::removeEnumerator(int index)
+{
+ if (index >= 0 && index < d->enumerators.size())
+ d->enumerators.removeAt(index);
+}
+
+/*!
+ Removes the item of class information at \a index from this class.
+ The indices of all following items will be adjusted downwards by 1.
+
+ \sa classInfoCount(), addClassInfo(), classInfoName(), classInfoValue()
+ \sa indexOfClassInfo()
+*/
+void QMetaObjectBuilder::removeClassInfo(int index)
+{
+ if (index >= 0 && index < d->classInfoNames.size()) {
+ d->classInfoNames.removeAt(index);
+ d->classInfoValues.removeAt(index);
+ }
+}
+
+/*!
+ Removes the related meta object at \a index from this class.
+ The indices of all following related meta objects will be adjusted
+ downwards by 1.
+
+ Related meta objects are used when resolving the enumerated type
+ associated with a property, where the enumerated type is in a
+ different class from the property.
+
+ \sa relatedMetaObjectCount(), addRelatedMetaObject()
+ \sa relatedMetaObject()
+*/
+void QMetaObjectBuilder::removeRelatedMetaObject(int index)
+{
+ if (index >= 0 && index < d->relatedMetaObjects.size())
+ d->relatedMetaObjects.removeAt(index);
+}
+
+/*!
+ Finds a method with the specified \a signature and returns its index;
+ otherwise returns -1. The \a signature will be normalized by this method.
+
+ \sa method(), methodCount(), addMethod(), removeMethod()
+*/
+int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
+{
+ QByteArray sig = QMetaObject::normalizedSignature(signature);
+ for (int index = 0; index < d->methods.size(); ++index) {
+ if (sig == d->methods[index].signature)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds a signal with the specified \a signature and returns its index;
+ otherwise returns -1. The \a signature will be normalized by this method.
+
+ \sa indexOfMethod(), indexOfSlot()
+*/
+int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
+{
+ QByteArray sig = QMetaObject::normalizedSignature(signature);
+ for (int index = 0; index < d->methods.size(); ++index) {
+ if (sig == d->methods[index].signature &&
+ d->methods[index].methodType() == QMetaMethod::Signal)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds a slot with the specified \a signature and returns its index;
+ otherwise returns -1. The \a signature will be normalized by this method.
+
+ \sa indexOfMethod(), indexOfSignal()
+*/
+int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
+{
+ QByteArray sig = QMetaObject::normalizedSignature(signature);
+ for (int index = 0; index < d->methods.size(); ++index) {
+ if (sig == d->methods[index].signature &&
+ d->methods[index].methodType() == QMetaMethod::Slot)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds a constructor with the specified \a signature and returns its index;
+ otherwise returns -1. The \a signature will be normalized by this method.
+
+ \sa constructor(), constructorCount(), addConstructor(), removeConstructor()
+*/
+int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
+{
+ QByteArray sig = QMetaObject::normalizedSignature(signature);
+ for (int index = 0; index < d->constructors.size(); ++index) {
+ if (sig == d->constructors[index].signature)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds a property with the specified \a name and returns its index;
+ otherwise returns -1.
+
+ \sa property(), propertyCount(), addProperty(), removeProperty()
+*/
+int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
+{
+ for (int index = 0; index < d->properties.size(); ++index) {
+ if (name == d->properties[index].name)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds an enumerator with the specified \a name and returns its index;
+ otherwise returns -1.
+
+ \sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()
+*/
+int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
+{
+ for (int index = 0; index < d->enumerators.size(); ++index) {
+ if (name == d->enumerators[index].name)
+ return index;
+ }
+ return -1;
+}
+
+/*!
+ Finds an item of class information with the specified \a name and
+ returns its index; otherwise returns -1.
+
+ \sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
+ \sa removeClassInfo()
+*/
+int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name)
+{
+ for (int index = 0; index < d->classInfoNames.size(); ++index) {
+ if (name == d->classInfoNames[index])
+ return index;
+ }
+ return -1;
+}
+
+// Align on a specific type boundary.
+#define ALIGN(size,type) \
+ (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1)
+
+// Build a string into a QMetaObject representation. Returns the
+// position in the string table where the string was placed.
+static int buildString
+ (char *buf, char *str, int *offset, const QByteArray& value, int empty)
+{
+ if (value.size() == 0 && empty >= 0)
+ return empty;
+ if (buf) {
+ memcpy(str + *offset, value.constData(), value.size());
+ str[*offset + value.size()] = '\0';
+ }
+ int posn = *offset;
+ *offset += value.size() + 1;
+ return posn;
+}
+
+// Build the parameter array string for a method.
+static QByteArray buildParameterNames
+ (const QByteArray& signature, const QList<QByteArray>& parameterNames)
+{
+ // If the parameter name list is specified, then concatenate them.
+ if (!parameterNames.isEmpty()) {
+ QByteArray names;
+ bool first = true;
+ foreach (QByteArray name, parameterNames) {
+ if (first)
+ first = false;
+ else
+ names += (char)',';
+ names += name;
+ }
+ return names;
+ }
+
+ // Count commas in the signature, excluding those inside template arguments.
+ int index = signature.indexOf('(');
+ if (index < 0)
+ return QByteArray();
+ ++index;
+ if (index >= signature.size())
+ return QByteArray();
+ if (signature[index] == ')')
+ return QByteArray();
+ int count = 1;
+ int brackets = 0;
+ while (index < signature.size() && signature[index] != ',') {
+ char ch = signature[index++];
+ if (ch == '<')
+ ++brackets;
+ else if (ch == '>')
+ --brackets;
+ else if (ch == ',' && brackets <= 0)
+ ++count;
+ }
+ return QByteArray(count - 1, ',');
+}
+
+// Build a QMetaObject in "buf" based on the information in "d".
+// If "buf" is null, then return the number of bytes needed to
+// build the QMetaObject.
+static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf)
+{
+ int size = 0;
+ int dataIndex;
+ int enumIndex;
+ int index;
+ bool hasNotifySignals = false;
+
+ // Create the main QMetaObject structure at the start of the buffer.
+ QMetaObject *meta = reinterpret_cast<QMetaObject *>(buf);
+ size += sizeof(QMetaObject);
+ ALIGN(size, int);
+ if (buf) {
+ meta->d.superdata = d->superClass;
+ meta->d.extradata = 0;
+ }
+
+ // Populate the QMetaObjectPrivate structure.
+ QMetaObjectPrivate *pmeta
+ = reinterpret_cast<QMetaObjectPrivate *>(buf + size);
+ dataIndex = 12; // Number of fields in the QMetaObjectPrivate.
+ for (index = 0; index < d->properties.size(); ++index) {
+ if (d->properties[index].notifySignal != -1) {
+ hasNotifySignals = true;
+ break;
+ }
+ }
+ if (buf) {
+ pmeta->revision = 2;
+ pmeta->className = 0; // Class name is always the first string.
+
+ pmeta->classInfoCount = d->classInfoNames.size();
+ pmeta->classInfoData = dataIndex;
+ dataIndex += 2 * d->classInfoNames.size();
+
+ pmeta->methodCount = d->methods.size();
+ pmeta->methodData = dataIndex;
+ dataIndex += 5 * d->methods.size();
+
+ pmeta->propertyCount = d->properties.size();
+ pmeta->propertyData = dataIndex;
+ dataIndex += 3 * d->properties.size();
+ if (hasNotifySignals)
+ dataIndex += d->properties.size();
+
+ pmeta->enumeratorCount = d->enumerators.size();
+ pmeta->enumeratorData = dataIndex;
+ dataIndex += 4 * d->enumerators.size();
+
+ pmeta->constructorCount = d->constructors.size();
+ pmeta->constructorData = dataIndex;
+ dataIndex += 5 * d->constructors.size();
+ } else {
+ dataIndex += 2 * d->classInfoNames.size();
+ dataIndex += 5 * d->methods.size();
+ dataIndex += 3 * d->properties.size();
+ if (hasNotifySignals)
+ dataIndex += d->properties.size();
+ dataIndex += 4 * d->enumerators.size();
+ dataIndex += 5 * d->constructors.size();
+ }
+
+ // Allocate space for the enumerator key names and values.
+ enumIndex = dataIndex;
+ for (index = 0; index < d->enumerators.size(); ++index) {
+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
+ dataIndex += 2 * enumerator->keys.size();
+ }
+
+ // Zero terminator at the end of the data offset table.
+ ++dataIndex;
+
+ // Find the start of the data and string tables.
+ int *data = reinterpret_cast<int *>(pmeta);
+ size += dataIndex * sizeof(int);
+ char *str = reinterpret_cast<char *>(buf + size);
+ if (buf) {
+ meta->d.stringdata = str;
+ meta->d.data = reinterpret_cast<uint *>(data);
+ }
+
+ // Reset the current data position to just past the QMetaObjectPrivate.
+ dataIndex = 12;
+
+ // Add the class name to the string table.
+ int offset = 0;
+ buildString(buf, str, &offset, d->className, -1);
+
+ // Add a common empty string, which is used to indicate "void"
+ // method returns, empty tag strings, etc.
+ int empty = buildString(buf, str, &offset, QByteArray(), -1);
+
+ // Output the class infos,
+ for (index = 0; index < d->classInfoNames.size(); ++index) {
+ int name = buildString(buf, str, &offset, d->classInfoNames[index], empty);
+ int value = buildString(buf, str, &offset, d->classInfoValues[index], empty);
+ if (buf) {
+ data[dataIndex] = name;
+ data[dataIndex + 1] = value;
+ }
+ dataIndex += 2;
+ }
+
+ // Output the methods in the class.
+ for (index = 0; index < d->methods.size(); ++index) {
+ QMetaMethodBuilderPrivate *method = &(d->methods[index]);
+ int sig = buildString(buf, str, &offset, method->signature, empty);
+ int params;
+ QByteArray names = buildParameterNames
+ (method->signature, method->parameterNames);
+ params = buildString(buf, str, &offset, names, empty);
+ int ret = buildString(buf, str, &offset, method->returnType, empty);
+ int tag = buildString(buf, str, &offset, method->tag, empty);
+ int attrs = method->attributes;
+ if (buf) {
+ data[dataIndex] = sig;
+ data[dataIndex + 1] = params;
+ data[dataIndex + 2] = ret;
+ data[dataIndex + 3] = tag;
+ data[dataIndex + 4] = attrs;
+ }
+ dataIndex += 5;
+ }
+
+ // Output the properties in the class.
+ for (index = 0; index < d->properties.size(); ++index) {
+ QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
+ int name = buildString(buf, str, &offset, prop->name, empty);
+ int type = buildString(buf, str, &offset, prop->type, empty);
+ int flags = prop->flags;
+ if (buf) {
+ data[dataIndex] = name;
+ data[dataIndex + 1] = type;
+ data[dataIndex + 2] = flags;
+ }
+ dataIndex += 3;
+ }
+ if (hasNotifySignals) {
+ for (index = 0; index < d->properties.size(); ++index) {
+ QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
+ if (buf) {
+ if (prop->notifySignal != -1)
+ data[dataIndex] = prop->notifySignal;
+ else
+ data[dataIndex] = 0;
+ }
+ ++dataIndex;
+ }
+ }
+
+ // Output the enumerators in the class.
+ for (index = 0; index < d->enumerators.size(); ++index) {
+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
+ int name = buildString(buf, str, &offset, enumerator->name, empty);
+ int isFlag = (int)(enumerator->isFlag);
+ int count = enumerator->keys.size();
+ int enumOffset = enumIndex;
+ if (buf) {
+ data[dataIndex] = name;
+ data[dataIndex + 1] = isFlag;
+ data[dataIndex + 2] = count;
+ data[dataIndex + 3] = enumOffset;
+ }
+ for (int key = 0; key < count; ++key) {
+ int keyIndex = buildString(buf, str, &offset, enumerator->keys[key], empty);
+ if (buf) {
+ data[enumOffset++] = keyIndex;
+ data[enumOffset++] = enumerator->values[key];
+ }
+ }
+ dataIndex += 4;
+ enumIndex += 2 * count;
+ }
+
+ // Output the constructors in the class.
+ for (index = 0; index < d->constructors.size(); ++index) {
+ QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
+ int sig = buildString(buf, str, &offset, method->signature, empty);
+ int params;
+ QByteArray names = buildParameterNames
+ (method->signature, method->parameterNames);
+ params = buildString(buf, str, &offset, names, empty);
+ int ret = buildString(buf, str, &offset, method->returnType, empty);
+ int tag = buildString(buf, str, &offset, method->tag, empty);
+ int attrs = method->attributes;
+ if (buf) {
+ data[dataIndex] = sig;
+ data[dataIndex + 1] = params;
+ data[dataIndex + 2] = ret;
+ data[dataIndex + 3] = tag;
+ data[dataIndex + 4] = attrs;
+ }
+ dataIndex += 5;
+ }
+
+ // One more empty string to act as a terminator.
+ buildString(buf, str, &offset, QByteArray(), -1);
+ size += offset;
+
+ // Output the zero terminator in the data array.
+ if (buf)
+ data[enumIndex] = 0;
+
+ // Create the extradata block if we need one.
+ if (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction) {
+ ALIGN(size, QMetaObject **);
+ ALIGN(size, QMetaObjectBuilder::StaticMetacallFunction);
+ QMetaObjectExtraData *extra =
+ reinterpret_cast<QMetaObjectExtraData *>(buf + size);
+ size += sizeof(QMetaObjectExtraData);
+ ALIGN(size, QMetaObject *);
+ const QMetaObject **objects =
+ reinterpret_cast<const QMetaObject **>(buf + size);
+ if (buf) {
+ if (d->relatedMetaObjects.size() > 0) {
+ extra->objects = objects;
+ for (index = 0; index < d->relatedMetaObjects.size(); ++index)
+ objects[index] = d->relatedMetaObjects[index];
+ objects[index] = 0;
+ } else {
+ extra->objects = 0;
+ }
+ extra->static_metacall = d->staticMetacallFunction;
+ meta->d.extradata = reinterpret_cast<void *>(extra);
+ }
+ if (d->relatedMetaObjects.size() > 0)
+ size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
+ }
+
+ // Align the final size and return it.
+ ALIGN(size, void *);
+ return size;
+}
+
+/*!
+ Converts this meta object builder into a concrete QMetaObject.
+ The return value should be deallocated using qFree() once it
+ is no longer needed.
+
+ The returned meta object is a snapshot of the state of the
+ QMetaObjectBuilder. Any further modifications to the QMetaObjectBuilder
+ will not be reflected in previous meta objects returned by
+ this method.
+*/
+QMetaObject *QMetaObjectBuilder::toMetaObject() const
+{
+ int size = buildMetaObject(d, 0);
+ char *buf = reinterpret_cast<char *>(qMalloc(size));
+ buildMetaObject(d, buf);
+ return reinterpret_cast<QMetaObject *>(buf);
+}
+
+/*!
+ \typedef QMetaObjectBuilder::StaticMetacallFunction
+
+ Typedef for static metacall functions. The three parameters are
+ the call type value, the constructor index, and the
+ array of parameters.
+*/
+
+/*!
+ Returns the static metacall function to use to construct objects
+ of this class. The default value is null.
+
+ \sa setStaticMetacallFunction()
+*/
+QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction() const
+{
+ return d->staticMetacallFunction;
+}
+
+/*!
+ Sets the static metacall function to use to construct objects
+ of this class to \a value. The default value is null.
+
+ \sa staticMetacallFunction()
+*/
+void QMetaObjectBuilder::setStaticMetacallFunction
+ (QMetaObjectBuilder::StaticMetacallFunction value)
+{
+ d->staticMetacallFunction = value;
+}
+
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ Serializes the contents of the meta object builder onto \a stream.
+
+ \sa deserialize()
+*/
+void QMetaObjectBuilder::serialize(QDataStream& stream) const
+{
+ int index;
+
+ // Write the class and super class names.
+ stream << d->className;
+ if (d->superClass)
+ stream << QByteArray(d->superClass->className());
+ else
+ stream << QByteArray();
+
+ // Write the counts for each type of class member.
+ stream << d->classInfoNames.size();
+ stream << d->methods.size();
+ stream << d->properties.size();
+ stream << d->enumerators.size();
+ stream << d->constructors.size();
+ stream << d->relatedMetaObjects.size();
+
+ // Write the items of class information.
+ for (index = 0; index < d->classInfoNames.size(); ++index) {
+ stream << d->classInfoNames[index];
+ stream << d->classInfoValues[index];
+ }
+
+ // Write the methods.
+ for (index = 0; index < d->methods.size(); ++index) {
+ const QMetaMethodBuilderPrivate *method = &(d->methods[index]);
+ stream << method->signature;
+ stream << method->returnType;
+ stream << method->parameterNames;
+ stream << method->tag;
+ stream << method->attributes;
+ }
+
+ // Write the properties.
+ for (index = 0; index < d->properties.size(); ++index) {
+ const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
+ stream << property->name;
+ stream << property->type;
+ stream << property->flags;
+ stream << property->notifySignal;
+ }
+
+ // Write the enumerators.
+ for (index = 0; index < d->enumerators.size(); ++index) {
+ const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
+ stream << enumerator->name;
+ stream << enumerator->isFlag;
+ stream << enumerator->keys;
+ stream << enumerator->values;
+ }
+
+ // Write the constructors.
+ for (index = 0; index < d->constructors.size(); ++index) {
+ const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
+ stream << method->signature;
+ stream << method->returnType;
+ stream << method->parameterNames;
+ stream << method->tag;
+ stream << method->attributes;
+ }
+
+ // Write the related meta objects.
+ for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
+ const QMetaObject *meta = d->relatedMetaObjects[index];
+ stream << QByteArray(meta->className());
+ }
+
+ // Add an extra empty QByteArray for additional data in future versions.
+ // This should help maintain backwards compatibility, allowing older
+ // versions to read newer data.
+ stream << QByteArray();
+}
+
+// Resolve a class name using the name reference map.
+static const QMetaObject *resolveClassName
+ (const QMap<QByteArray, const QMetaObject *>& references,
+ const QByteArray& name)
+{
+ if (name == QByteArray("QObject"))
+ return &QObject::staticMetaObject;
+ else
+ return references.value(name, 0);
+}
+
+/*!
+ Deserializes a meta object builder from \a stream into
+ this meta object builder.
+
+ The \a references parameter specifies a mapping from class names
+ to QMetaObject instances for resolving the super class name and
+ related meta objects in the object that is deserialized.
+ The meta object for QObject is implicitly added to \a references
+ and does not need to be supplied.
+
+ The QDataStream::status() value on \a stream will be set to
+ QDataStream::ReadCorruptData if the input data is corrupt.
+ The status will be set to QDataStream::ReadPastEnd if the
+ input was exhausted before the full meta object was read.
+
+ \sa serialize()
+*/
+void QMetaObjectBuilder::deserialize
+ (QDataStream& stream,
+ const QMap<QByteArray, const QMetaObject *>& references)
+{
+ QByteArray name;
+ const QMetaObject *cl;
+ int index;
+
+ // Clear all members in the builder to their default states.
+ d->className.clear();
+ d->superClass = &QObject::staticMetaObject;
+ d->classInfoNames.clear();
+ d->classInfoValues.clear();
+ d->methods.clear();
+ d->properties.clear();
+ d->enumerators.clear();
+ d->constructors.clear();
+ d->relatedMetaObjects.clear();
+ d->staticMetacallFunction = 0;
+
+ // Read the class and super class names.
+ stream >> d->className;
+ stream >> name;
+ if (name.isEmpty()) {
+ d->superClass = 0;
+ } else if ((cl = resolveClassName(references, name)) != 0) {
+ d->superClass = cl;
+ } else {
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+
+ // Read the counts for each type of class member.
+ int classInfoCount, methodCount, propertyCount;
+ int enumeratorCount, constructorCount, relatedMetaObjectCount;
+ stream >> classInfoCount;
+ stream >> methodCount;
+ stream >> propertyCount;
+ stream >> enumeratorCount;
+ stream >> constructorCount;
+ stream >> relatedMetaObjectCount;
+ if (classInfoCount < 0 || methodCount < 0 ||
+ propertyCount < 0 || enumeratorCount < 0 ||
+ constructorCount < 0 || relatedMetaObjectCount < 0) {
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+
+ // Read the items of class information.
+ for (index = 0; index < classInfoCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ QByteArray value;
+ stream >> name;
+ stream >> value;
+ addClassInfo(name, value);
+ }
+
+ // Read the member methods.
+ for (index = 0; index < methodCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ stream >> name;
+ addMethod(name);
+ QMetaMethodBuilderPrivate *method = &(d->methods[index]);
+ stream >> method->returnType;
+ stream >> method->parameterNames;
+ stream >> method->tag;
+ stream >> method->attributes;
+ if (method->methodType() == QMetaMethod::Constructor) {
+ // Cannot add a constructor in this set of methods.
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ }
+
+ // Read the properties.
+ for (index = 0; index < propertyCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ QByteArray type;
+ stream >> name;
+ stream >> type;
+ addProperty(name, type);
+ QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
+ stream >> property->flags;
+ stream >> property->notifySignal;
+ if (property->notifySignal < -1 ||
+ property->notifySignal >= d->methods.size()) {
+ // Notify signal method index is out of range.
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ if (property->notifySignal >= 0 &&
+ d->methods[property->notifySignal].methodType() != QMetaMethod::Signal) {
+ // Notify signal method index does not refer to a signal.
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ }
+
+ // Read the enumerators.
+ for (index = 0; index < enumeratorCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ stream >> name;
+ addEnumerator(name);
+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
+ stream >> enumerator->isFlag;
+ stream >> enumerator->keys;
+ stream >> enumerator->values;
+ if (enumerator->keys.size() != enumerator->values.size()) {
+ // Mismatch between number of keys and number of values.
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ }
+
+ // Read the constructor methods.
+ for (index = 0; index < constructorCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ stream >> name;
+ addConstructor(name);
+ QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
+ stream >> method->returnType;
+ stream >> method->parameterNames;
+ stream >> method->tag;
+ stream >> method->attributes;
+ if (method->methodType() != QMetaMethod::Constructor) {
+ // The type must be Constructor.
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ }
+
+ // Read the related meta objects.
+ for (index = 0; index < relatedMetaObjectCount; ++index) {
+ if (stream.status() != QDataStream::Ok)
+ return;
+ stream >> name;
+ cl = resolveClassName(references, name);
+ if (!cl) {
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return;
+ }
+ addRelatedMetaObject(cl);
+ }
+
+ // Read the extra data block, which is reserved for future use.
+ stream >> name;
+}
+
+#endif // !QT_NO_DATASTREAM
+
+/*!
+ \class QMetaMethodBuilder
+ \brief The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder.
+*/
+
+QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
+{
+ // Positive indices indicate methods, negative indices indicate constructors.
+ if (_mobj && _index >= 0 && _index < _mobj->d->methods.size())
+ return &(_mobj->d->methods[_index]);
+ else if (_mobj && -_index >= 1 && -_index <= _mobj->d->constructors.size())
+ return &(_mobj->d->constructors[(-_index) - 1]);
+ else
+ return 0;
+}
+
+/*!
+ \fn QMetaMethodBuilder::QMetaMethodBuilder()
+ \internal
+*/
+
+/*!
+ Returns the index of this method within its QMetaObjectBuilder.
+*/
+int QMetaMethodBuilder::index() const
+{
+ if (_index >= 0)
+ return _index; // Method, signal, or slot
+ else
+ return (-_index) - 1; // Constructor
+}
+
+/*!
+ Returns the type of this method (signal, slot, method, or constructor).
+*/
+QMetaMethod::MethodType QMetaMethodBuilder::methodType() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->methodType();
+ else
+ return QMetaMethod::Method;
+}
+
+/*!
+ Returns the signature of this method.
+
+ \sa parameterNames(), returnType()
+*/
+QByteArray QMetaMethodBuilder::signature() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->signature;
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns the return type for this method; empty if the method's
+ return type is \c{void}.
+
+ \sa setReturnType(), signature()
+*/
+QByteArray QMetaMethodBuilder::returnType() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->returnType;
+ else
+ return QByteArray();
+}
+
+/*!
+ Sets the return type for this method to \a value. If \a value
+ is empty, then the method's return type is \c{void}. The \a value
+ will be normalized before it is added to the method.
+
+ \sa returnType(), signature()
+*/
+void QMetaMethodBuilder::setReturnType(const QByteArray& value)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ d->returnType = QMetaObject::normalizedType(value);
+}
+
+/*!
+ Returns the list of parameter names for this method.
+
+ \sa setParameterNames()
+*/
+QList<QByteArray> QMetaMethodBuilder::parameterNames() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->parameterNames;
+ else
+ return QList<QByteArray>();
+}
+
+/*!
+ Sets the list of parameter names for this method to \a value.
+
+ \sa parameterNames()
+*/
+void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ d->parameterNames = value;
+}
+
+/*!
+ Returns the tag associated with this method.
+
+ \sa setTag()
+*/
+QByteArray QMetaMethodBuilder::tag() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->tag;
+ else
+ return QByteArray();
+}
+
+/*!
+ Sets the tag associated with this method to \a value.
+
+ \sa setTag()
+*/
+void QMetaMethodBuilder::setTag(const QByteArray& value)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ d->tag = value;
+}
+
+/*!
+ Returns the access specification of this method (private, protected,
+ or public). The default value is QMetaMethod::Public for methods,
+ slots, and constructors. The default value is QMetaMethod::Protected
+ for signals.
+
+ \sa setAccess()
+*/
+QMetaMethod::Access QMetaMethodBuilder::access() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->access();
+ else
+ return QMetaMethod::Public;
+}
+
+/*!
+ Sets the access specification of this method (private, protected,
+ or public) to \a value. If the method is a signal, this function
+ will be ignored.
+
+ \sa access()
+*/
+void QMetaMethodBuilder::setAccess(QMetaMethod::Access value)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d && d->methodType() != QMetaMethod::Signal)
+ d->setAccess(value);
+}
+
+/*!
+ Returns the additional attributes for this method.
+
+ \sa setAttributes()
+*/
+int QMetaMethodBuilder::attributes() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return (d->attributes >> 4);
+ else
+ return 0;
+}
+
+/*!
+ Sets the additional attributes for this method to \a value.
+
+ \sa attributes()
+*/
+void QMetaMethodBuilder::setAttributes(int value)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ d->attributes = ((d->attributes & 0x0f) | (value << 4));
+}
+
+/*!
+ \class QMetaPropertyBuilder
+ \brief The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builder.
+*/
+
+QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
+{
+ if (_mobj && _index >= 0 && _index < _mobj->d->properties.size())
+ return &(_mobj->d->properties[_index]);
+ else
+ return 0;
+}
+
+/*!
+ \fn QMetaPropertyBuilder::QMetaPropertyBuilder()
+ \internal
+*/
+
+/*!
+ \fn int QMetaPropertyBuilder::index() const
+
+ Returns the index of this property within its QMetaObjectBuilder.
+*/
+
+/*!
+ Returns the name associated with this property.
+
+ \sa type()
+*/
+QByteArray QMetaPropertyBuilder::name() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->name;
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns the type associated with this property.
+
+ \sa name()
+*/
+QByteArray QMetaPropertyBuilder::type() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->type;
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns true if this property has a notify signal; false otherwise.
+
+ \sa notifySignal(), setNotifySignal(), removeNotifySignal()
+*/
+bool QMetaPropertyBuilder::hasNotifySignal() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Notify);
+ else
+ return false;
+}
+
+/*!
+ Returns the notify signal associated with this property.
+
+ \sa hasNotifySignal(), setNotifySignal(), removeNotifySignal()
+*/
+QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d && d->notifySignal >= 0)
+ return QMetaMethodBuilder(_mobj, d->notifySignal);
+ else
+ return QMetaMethodBuilder();
+}
+
+/*!
+ Sets the notify signal associated with this property to \a value.
+
+ \sa hasNotifySignal(), notifySignal(), removeNotifySignal()
+*/
+void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d) {
+ if (value._mobj) {
+ d->notifySignal = value._index;
+ d->setFlag(Notify, true);
+ } else {
+ d->notifySignal = -1;
+ d->setFlag(Notify, false);
+ }
+ }
+}
+
+/*!
+ Removes the notify signal from this property.
+
+ \sa hasNotifySignal(), notifySignal(), setNotifySignal()
+*/
+void QMetaPropertyBuilder::removeNotifySignal()
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d) {
+ d->notifySignal = -1;
+ d->setFlag(Notify, false);
+ }
+}
+
+/*!
+ Returns true if this property is readable; otherwise returns false.
+ The default value is true.
+
+ \sa setReadable(), isWritable()
+*/
+bool QMetaPropertyBuilder::isReadable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Readable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if this property is writable; otherwise returns false.
+ The default value is true.
+
+ \sa setWritable(), isReadable()
+*/
+bool QMetaPropertyBuilder::isWritable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Writable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if this property can be reset to a default value; otherwise
+ returns false. The default value is false.
+
+ \sa setResettable()
+*/
+bool QMetaPropertyBuilder::isResettable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Resettable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if this property is designable; otherwise returns false.
+ This default value is false.
+
+ \sa setDesignable(), isScriptable(), isStored()
+*/
+bool QMetaPropertyBuilder::isDesignable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Designable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is scriptable; otherwise returns false.
+ This default value is false.
+
+ \sa setScriptable(), isDesignable(), isStored()
+*/
+bool QMetaPropertyBuilder::isScriptable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Scriptable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is stored; otherwise returns false.
+ This default value is false.
+
+ \sa setStored(), isDesignable(), isScriptable()
+*/
+bool QMetaPropertyBuilder::isStored() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Stored);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is editable; otherwise returns false.
+ This default value is false.
+
+ \sa setEditable(), isDesignable(), isScriptable(), isStored()
+*/
+bool QMetaPropertyBuilder::isEditable() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(Editable);
+ else
+ return false;
+}
+
+/*!
+ Returns true if this property is designated as the \c USER
+ property, i.e., the one that the user can edit or that is
+ significant in some other way. Otherwise it returns
+ false. This default value is false.
+
+ \sa setUser(), isDesignable(), isScriptable()
+*/
+bool QMetaPropertyBuilder::isUser() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(User);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property has a C++ setter function that
+ follows Qt's standard "name" / "setName" pattern. Designer and uic
+ query hasStdCppSet() in order to avoid expensive
+ QObject::setProperty() calls. All properties in Qt [should] follow
+ this pattern. The default value is false.
+
+ \sa setStdCppSet()
+*/
+bool QMetaPropertyBuilder::hasStdCppSet() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(StdCppSet);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is an enumerator or flag type;
+ otherwise returns false. This default value is false.
+
+ \sa setEnumOrFlag()
+*/
+bool QMetaPropertyBuilder::isEnumOrFlag() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->flag(EnumOrFlag);
+ else
+ return false;
+}
+
+/*!
+ Sets this property to readable if \a value is true.
+
+ \sa isReadable(), setWritable()
+*/
+void QMetaPropertyBuilder::setReadable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Readable, value);
+}
+
+/*!
+ Sets this property to writable if \a value is true.
+
+ \sa isWritable(), setReadable()
+*/
+void QMetaPropertyBuilder::setWritable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Writable, value);
+}
+
+/*!
+ Sets this property to resettable if \a value is true.
+
+ \sa isResettable()
+*/
+void QMetaPropertyBuilder::setResettable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Resettable, value);
+}
+
+/*!
+ Sets this property to designable if \a value is true.
+
+ \sa isDesignable(), setScriptable(), setStored()
+*/
+void QMetaPropertyBuilder::setDesignable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Designable, value);
+}
+
+/*!
+ Sets this property to scriptable if \a value is true.
+
+ \sa isScriptable(), setDesignable(), setStored()
+*/
+void QMetaPropertyBuilder::setScriptable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Scriptable, value);
+}
+
+/*!
+ Sets this property to storable if \a value is true.
+
+ \sa isStored(), setDesignable(), setScriptable()
+*/
+void QMetaPropertyBuilder::setStored(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Stored, value);
+}
+
+/*!
+ Sets this property to editable if \a value is true.
+
+ \sa isEditable(), setDesignable(), setScriptable(), setStored()
+*/
+void QMetaPropertyBuilder::setEditable(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(Editable, value);
+}
+
+/*!
+ Sets the \c USER flag on this property to \a value.
+
+ \sa isUser(), setDesignable(), setScriptable()
+*/
+void QMetaPropertyBuilder::setUser(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(User, value);
+}
+
+/*!
+ Sets the C++ setter flag on this property to \a value, which is
+ true if the property has a C++ setter function that follows Qt's
+ standard "name" / "setName" pattern.
+
+ \sa hasStdCppSet()
+*/
+void QMetaPropertyBuilder::setStdCppSet(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(StdCppSet, value);
+}
+
+/*!
+ Sets this property to be of an enumerator or flag type if
+ \a value is true.
+
+ \sa isEnumOrFlag()
+*/
+void QMetaPropertyBuilder::setEnumOrFlag(bool value)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ d->setFlag(EnumOrFlag, value);
+}
+
+/*!
+ \class QMetaEnumBuilder
+ \brief The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder.
+*/
+
+QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
+{
+ if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size())
+ return &(_mobj->d->enumerators[_index]);
+ else
+ return 0;
+}
+
+/*!
+ \fn QMetaEnumBuilder::QMetaEnumBuilder()
+ \internal
+*/
+
+/*!
+ \fn int QMetaEnumBuilder::index() const
+
+ Returns the index of this enumerator within its QMetaObjectBuilder.
+*/
+
+/*!
+ Returns the name of the enumerator (without the scope).
+*/
+QByteArray QMetaEnumBuilder::name() const
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d)
+ return d->name;
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns true if this enumerator is used as a flag; otherwise returns
+ false.
+
+ \sa setIsFlag()
+*/
+bool QMetaEnumBuilder::isFlag() const
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d)
+ return d->isFlag;
+ else
+ return false;
+}
+
+/*!
+ Sets this enumerator to be used as a flag if \a value is true.
+
+ \sa isFlag()
+*/
+void QMetaEnumBuilder::setIsFlag(bool value)
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d)
+ d->isFlag = value;
+}
+
+/*!
+ Returns the number of keys.
+
+ \sa key(), addKey()
+*/
+int QMetaEnumBuilder::keyCount() const
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d)
+ return d->keys.size();
+ else
+ return 0;
+}
+
+/*!
+ Returns the key with the given \a index, or an empty QByteArray
+ if no such key exists.
+
+ \sa keyCount(), addKey(), value()
+*/
+QByteArray QMetaEnumBuilder::key(int index) const
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d && index >= 0 && index < d->keys.size())
+ return d->keys[index];
+ else
+ return QByteArray();
+}
+
+/*!
+ Returns the value with the given \a index; or returns -1 if there
+ is no such value.
+
+ \sa keyCount(), addKey(), key()
+*/
+int QMetaEnumBuilder::value(int index) const
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d && index >= 0 && index < d->keys.size())
+ return d->values[index];
+ else
+ return -1;
+}
+
+/*!
+ Adds a new key called \a name to this enumerator, associated
+ with \a value. Returns the index of the new key.
+
+ \sa keyCount(), key(), value(), removeKey()
+*/
+int QMetaEnumBuilder::addKey(const QByteArray& name, int value)
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d) {
+ int index = d->keys.size();
+ d->keys += name;
+ d->values += value;
+ return index;
+ } else {
+ return -1;
+ }
+}
+
+/*!
+ Removes the key at \a index from this enumerator.
+
+ \sa addKey()
+*/
+void QMetaEnumBuilder::removeKey(int index)
+{
+ QMetaEnumBuilderPrivate *d = d_func();
+ if (d && index >= 0 && index < d->keys.size()) {
+ d->keys.removeAt(index);
+ d->values.removeAt(index);
+ }
+}
diff --git a/tests/auto/dynamicobject/qmetaobjectbuilder.h b/tests/auto/dynamicobject/qmetaobjectbuilder.h
new file mode 100644
index 0000000..d820860
--- /dev/null
+++ b/tests/auto/dynamicobject/qmetaobjectbuilder.h
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** This file is part of the $PACKAGE_NAME$.
+**
+** Copyright (C) $THISYEAR$ $COMPANY_NAME$.
+**
+** $QT_EXTENDED_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMETAOBJECTBUILDER_H
+#define QMETAOBJECTBUILDER_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qdatastream.h>
+#include <QtCore/qmap.h>
+
+class QMetaObjectBuilderPrivate;
+class QMetaMethodBuilder;
+class QMetaMethodBuilderPrivate;
+class QMetaPropertyBuilder;
+class QMetaPropertyBuilderPrivate;
+class QMetaEnumBuilder;
+class QMetaEnumBuilderPrivate;
+
+class QMetaObjectBuilder
+{
+public:
+ enum AddMember
+ {
+ ClassName = 0x00000001,
+ SuperClass = 0x00000002,
+ Methods = 0x00000004,
+ Signals = 0x00000008,
+ Slots = 0x00000010,
+ Constructors = 0x00000020,
+ Properties = 0x00000040,
+ Enumerators = 0x00000080,
+ ClassInfos = 0x00000100,
+ RelatedMetaObjects = 0x00000200,
+ StaticMetacall = 0x00000400,
+ PublicMethods = 0x00000800,
+ ProtectedMethods = 0x00001000,
+ PrivateMethods = 0x00002000,
+ AllMembers = 0x7FFFFFFF,
+ AllPrimaryMembers = 0x7FFFFBFC
+ };
+ Q_DECLARE_FLAGS(AddMembers, AddMember)
+
+ QMetaObjectBuilder();
+ explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
+ virtual ~QMetaObjectBuilder();
+
+ QByteArray className() const;
+ void setClassName(const QByteArray& name);
+
+ const QMetaObject *superClass() const;
+ void setSuperClass(const QMetaObject *meta);
+
+ int methodCount() const;
+ int constructorCount() const;
+ int propertyCount() const;
+ int enumeratorCount() const;
+ int classInfoCount() const;
+ int relatedMetaObjectCount() const;
+
+ QMetaMethodBuilder addMethod(const QByteArray& signature);
+ QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
+ QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
+
+ QMetaMethodBuilder addSlot(const QByteArray& signature);
+ QMetaMethodBuilder addSignal(const QByteArray& signature);
+
+ QMetaMethodBuilder addConstructor(const QByteArray& signature);
+ QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
+
+ QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
+ QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
+
+ QMetaEnumBuilder addEnumerator(const QByteArray& name);
+ QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
+
+ int addClassInfo(const QByteArray& name, const QByteArray& value);
+
+ int addRelatedMetaObject(const QMetaObject *meta);
+
+ void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
+
+ QMetaMethodBuilder method(int index) const;
+ QMetaMethodBuilder constructor(int index) const;
+ QMetaPropertyBuilder property(int index) const;
+ QMetaEnumBuilder enumerator(int index) const;
+ const QMetaObject *relatedMetaObject(int index) const;
+
+ QByteArray classInfoName(int index) const;
+ QByteArray classInfoValue(int index) const;
+
+ void removeMethod(int index);
+ void removeConstructor(int index);
+ void removeProperty(int index);
+ void removeEnumerator(int index);
+ void removeClassInfo(int index);
+ void removeRelatedMetaObject(int index);
+
+ int indexOfMethod(const QByteArray& signature);
+ int indexOfSignal(const QByteArray& signature);
+ int indexOfSlot(const QByteArray& signature);
+ int indexOfConstructor(const QByteArray& signature);
+ int indexOfProperty(const QByteArray& name);
+ int indexOfEnumerator(const QByteArray& name);
+ int indexOfClassInfo(const QByteArray& name);
+
+ typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
+
+ QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
+ void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
+
+ QMetaObject *toMetaObject() const;
+
+#ifndef QT_NO_DATASTREAM
+ void serialize(QDataStream& stream) const;
+ void deserialize
+ (QDataStream& stream,
+ const QMap<QByteArray, const QMetaObject *>& references);
+#endif
+
+private:
+ Q_DISABLE_COPY(QMetaObjectBuilder);
+
+ QMetaObjectBuilderPrivate *d;
+
+ friend class QMetaMethodBuilder;
+ friend class QMetaPropertyBuilder;
+ friend class QMetaEnumBuilder;
+};
+
+class QMetaMethodBuilder
+{
+public:
+ QMetaMethodBuilder() : _mobj(0), _index(0) {}
+
+ int index() const;
+
+ QMetaMethod::MethodType methodType() const;
+ QByteArray signature() const;
+
+ QByteArray returnType() const;
+ void setReturnType(const QByteArray& value);
+
+ QList<QByteArray> parameterNames() const;
+ void setParameterNames(const QList<QByteArray>& value);
+
+ QByteArray tag() const;
+ void setTag(const QByteArray& value);
+
+ QMetaMethod::Access access() const;
+ void setAccess(QMetaMethod::Access value);
+
+ int attributes() const;
+ void setAttributes(int value);
+
+private:
+ const QMetaObjectBuilder *_mobj;
+ int _index;
+
+ friend class QMetaObjectBuilder;
+ friend class QMetaPropertyBuilder;
+
+ QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
+ : _mobj(mobj), _index(index) {}
+
+ QMetaMethodBuilderPrivate *d_func() const;
+};
+
+class QMetaPropertyBuilder
+{
+public:
+ QMetaPropertyBuilder() : _mobj(0), _index(0) {}
+
+ int index() const { return _index; }
+
+ QByteArray name() const;
+ QByteArray type() const;
+
+ bool hasNotifySignal() const;
+ QMetaMethodBuilder notifySignal() const;
+ void setNotifySignal(const QMetaMethodBuilder& value);
+ void removeNotifySignal();
+
+ bool isReadable() const;
+ bool isWritable() const;
+ bool isResettable() const;
+ bool isDesignable() const;
+ bool isScriptable() const;
+ bool isStored() const;
+ bool isEditable() const;
+ bool isUser() const;
+ bool hasStdCppSet() const;
+ bool isEnumOrFlag() const;
+
+ void setReadable(bool value);
+ void setWritable(bool value);
+ void setResettable(bool value);
+ void setDesignable(bool value);
+ void setScriptable(bool value);
+ void setStored(bool value);
+ void setEditable(bool value);
+ void setUser(bool value);
+ void setStdCppSet(bool value);
+ void setEnumOrFlag(bool value);
+
+private:
+ const QMetaObjectBuilder *_mobj;
+ int _index;
+
+ friend class QMetaObjectBuilder;
+
+ QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
+ : _mobj(mobj), _index(index) {}
+
+ QMetaPropertyBuilderPrivate *d_func() const;
+};
+
+class QMetaEnumBuilder
+{
+public:
+ QMetaEnumBuilder() : _mobj(0), _index(0) {}
+
+ int index() const { return _index; }
+
+ QByteArray name() const;
+
+ bool isFlag() const;
+ void setIsFlag(bool value);
+
+ int keyCount() const;
+ QByteArray key(int index) const;
+ int value(int index) const;
+
+ int addKey(const QByteArray& name, int value);
+ void removeKey(int index);
+
+private:
+ const QMetaObjectBuilder *_mobj;
+ int _index;
+
+ friend class QMetaObjectBuilder;
+
+ QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
+ : _mobj(mobj), _index(index) {}
+
+ QMetaEnumBuilderPrivate *d_func() const;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
+
+#endif
diff --git a/tests/auto/dynamicobject/tst_qobject.cpp b/tests/auto/dynamicobject/tst_qobject.cpp
new file mode 100644
index 0000000..18805f7
--- /dev/null
+++ b/tests/auto/dynamicobject/tst_qobject.cpp
@@ -0,0 +1,325 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#define QT3_SUPPORT
+#include <QtTest/QtTest>
+
+
+#include <qcoreapplication.h>
+
+#include <qmetaobject.h>
+
+#include "qobject.h"
+#include "private/qobject_p.h"
+#include "qmetaobjectbuilder.h"
+#include "qdynamicmetaobject.h"
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QObject();
+ virtual ~tst_QObject();
+
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void addSignal();
+ void addSlot();
+ void addProperty();
+ void dynamicProperty();
+};
+
+//===========================================================================
+
+class MyDynamicMetaObject : public QDynamicMetaObject
+{
+public:
+ MyDynamicMetaObject(const QMetaObject *base);
+
+ int createProperty(const QObject *object, const char *, const char *);
+
+ virtual void callSlot(QObject *object, int id, const QList<QVariant> &args);
+
+ virtual void writeProperty(QObject *, int id, const QVariant &value) {
+ props[property(id).name()] = value;
+ }
+
+ virtual QVariant readProperty(QObject *, int id) const {
+ return props[property(id).name()];
+ }
+
+ QString calledSlot;
+ QString string;
+
+private:
+ QMap<QString,QVariant> props;
+};
+
+MyDynamicMetaObject::MyDynamicMetaObject(const QMetaObject *_base)
+ : QDynamicMetaObject(_base)
+{
+}
+
+void MyDynamicMetaObject::callSlot(QObject *object, int id, const QList<QVariant> &args)
+{
+ calledSlot = method(id).signature();
+ qDebug() << "Handled slot" << id << calledSlot << args;
+ if (calledSlot == "string(QString)") {
+ string = args[0].toString();
+ }
+}
+
+int MyDynamicMetaObject::createProperty(const QObject *, const char *name, const char *type)
+{
+ qDebug() << "createProperty" << name;
+ if (name == QString("dynamicProp")) {
+ addProperty(name, type);
+ int id = indexOfProperty(name);
+ return id;
+ }
+
+ return -1;
+}
+
+//===========================================================================
+
+class MyDynamicObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyDynamicObject();
+
+ void addSignal(const char *sigName) {
+ dynamicMeta->addSignal(sigName);
+ }
+
+ void addSignal(const char *sigName, const QList<QByteArray> &parameterNames) {
+ dynamicMeta->addSignal(sigName, parameterNames);
+ }
+
+ void emitSignal(const char *sigName) {
+ int idx = dynamicMeta->indexOfSignal(sigName);
+ if (idx >= 0)
+ dynamicMeta->activate(this, idx, 0);
+ }
+
+ void emitSignal(const char *sigName, QGenericArgument val0
+ , QGenericArgument val1=QGenericArgument(0)
+ , QGenericArgument val2=QGenericArgument(0)
+ , QGenericArgument val3=QGenericArgument(0)
+ , QGenericArgument val4=QGenericArgument(0)
+ , QGenericArgument val5=QGenericArgument(0)
+ , QGenericArgument val6=QGenericArgument(0)
+ , QGenericArgument val7=QGenericArgument(0))
+ {
+ int idx = dynamicMeta->indexOfSignal(sigName);
+ if (idx >= 0) {
+ QGenericReturnArgument rv;
+ dynamicMeta->method(idx).invoke(this, Qt::DirectConnection, rv,
+ val0, val1, val2, val3, val4, val5, val6, val7);
+ }
+ }
+
+ void addSlot(const char *slotName) {
+ dynamicMeta->addSlot(slotName);
+ }
+
+ void addSlot(const char *slotName, const QList<QByteArray> &parameterNames) {
+ dynamicMeta->addSlot(slotName, parameterNames);
+ }
+
+ void addProperty(const char *name, const char *type, const char *notifier) {
+ dynamicMeta->addProperty(name, type, notifier);
+ }
+
+ QString calledSlot() const { return dynamicMeta->calledSlot; }
+
+ void emitNormalSignal() { emit normalSignal(); }
+
+ MyDynamicMetaObject *dynamicMeta;
+
+public slots:
+ void normalSlot() {}
+
+signals:
+ void normalSignal();
+
+};
+
+MyDynamicObject::MyDynamicObject()
+ : QObject()
+{
+ dynamicMeta = new MyDynamicMetaObject(&staticMetaObject);
+ setDynamicMetaObject(dynamicMeta);
+}
+
+//===========================================================================
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+public:
+ TestObject() : slot1Called(false), slot2Called(false) {}
+
+ void emitSignal() { emit triggered(); }
+ void setText(const QString &str) { emit textChanged(str); }
+
+ bool slot1Called;
+ bool slot2Called;
+ QString string;
+
+public slots:
+ void slot1() {
+ slot1Called = true;
+ qDebug() << "Called slot1()";
+ }
+
+ void slot2() {
+ slot2Called = true;
+ qDebug() << "Called slot2()";
+ }
+
+ void slotString(QString str) {
+ string = str;
+ qDebug() << "Called slotString()" << str;
+ }
+
+signals:
+ void triggered();
+ void textChanged(QString);
+};
+
+
+tst_QObject::tst_QObject()
+{
+
+}
+
+tst_QObject::~tst_QObject()
+{
+
+}
+
+void tst_QObject::initTestCase()
+{
+}
+
+void tst_QObject::cleanupTestCase()
+{
+}
+
+void tst_QObject::init()
+{
+}
+
+void tst_QObject::cleanup()
+{
+}
+
+void tst_QObject::addSignal()
+{
+ MyDynamicObject myObj;
+ myObj.addSignal("testSignal()");
+
+ TestObject testObj;
+
+ connect(&myObj, SIGNAL(testSignal()), &testObj, SLOT(slot1()));
+ connect(&myObj, SIGNAL(normalSignal()), &testObj, SLOT(slot2()));
+
+ myObj.emitSignal("testSignal()");
+
+ QVERIFY(testObj.slot1Called);
+ QVERIFY(!testObj.slot2Called);
+
+ testObj.slot1Called = false;
+
+ myObj.emitNormalSignal();
+
+ QVERIFY(!testObj.slot1Called);
+ QVERIFY(testObj.slot2Called);
+
+ // With parameter
+ myObj.addSignal("stringSignal(QString)");
+ connect(&myObj, SIGNAL(stringSignal(QString)), &testObj, SLOT(slotString(QString)));
+
+ QString param("Hello");
+ myObj.emitSignal("stringSignal(QString)", Q_ARG(QString, param));
+
+ QCOMPARE(testObj.string, QString("Hello"));
+}
+
+void tst_QObject::addSlot()
+{
+ MyDynamicObject myObj;
+ myObj.addSlot("testSlot1()");
+ myObj.addSignal("testSignal()");
+ myObj.addSlot("testSlot()");
+
+ TestObject testObj;
+
+ connect(&testObj, SIGNAL(triggered()), &myObj, SLOT(testSlot()));
+ connect(&testObj, SIGNAL(triggered()), &myObj, SIGNAL(testSignal())); // signal chaining
+ connect(&myObj, SIGNAL(testSignal()), &testObj, SLOT(slot1()));
+
+ testObj.emitSignal();
+
+ QCOMPARE(myObj.calledSlot(), QString("testSlot()"));
+ QVERIFY(testObj.slot1Called);
+
+ // Verify parameter type and name
+ myObj.addSlot("string(QString)", QList<QByteArray>() << "name");
+ int idx = myObj.metaObject()->indexOfSlot("string(QString)");
+ QVERIFY(idx > 0);
+ QMetaMethod method = myObj.metaObject()->method(idx);
+ QVERIFY(method.parameterTypes()[0] == "QString");
+ QVERIFY(method.parameterNames()[0] == "name");
+
+ connect(&testObj, SIGNAL(textChanged(QString)), &myObj, SLOT(string(QString)));
+ testObj.setText("Hello");
+ QCOMPARE(myObj.dynamicMeta->string, QString("Hello"));
+}
+
+void tst_QObject::addProperty()
+{
+ MyDynamicObject myObj;
+ myObj.addSignal("propChanged()");
+ myObj.addProperty("myProp", QVariant::typeToName(QVariant::String), "propChanged()");
+
+ myObj.setProperty("myProp", QString("hello"));
+ qDebug() << "property value" << myObj.property("myProp").toString();
+ QCOMPARE(myObj.property("myProp").toString(), QString("hello"));
+
+ TestObject testObj;
+ connect(&myObj, SIGNAL(propChanged()), &testObj, SLOT(slot1()));
+ myObj.setProperty("myProp", QString("there"));
+
+ QCOMPARE(myObj.property("myProp").toString(), QString("there"));
+ QVERIFY(testObj.slot1Called);
+}
+
+void tst_QObject::dynamicProperty()
+{
+ MyDynamicObject myObj;
+
+ myObj.setProperty("dynamicProp", QString("hello"));
+ qDebug() << "property value" << myObj.property("dynamicProp").toString();
+ QCOMPARE(myObj.property("dynamicProp").toString(), QString("hello"));
+}
+
+QTEST_MAIN(tst_QObject)
+#include "tst_qobject.moc"
diff --git a/tests/auto/qanimationgroup/qanimationgroup.pro b/tests/auto/qanimationgroup/qanimationgroup.pro
new file mode 100644
index 0000000..97d33dd
--- /dev/null
+++ b/tests/auto/qanimationgroup/qanimationgroup.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qanimationgroup.cpp
+
+
diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
new file mode 100644
index 0000000..ff5c3b4
--- /dev/null
+++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
@@ -0,0 +1,347 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qanimationgroup.h>
+#include <QtCore/qsequentialanimationgroup.h>
+#include <QtCore/qparallelanimationgroup.h>
+
+//TESTED_CLASS=QAnimationGroup
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(QAbstractAnimation::State)
+
+class tst_QAnimationGroup : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAnimationGroup();
+ virtual ~tst_QAnimationGroup();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void construction();
+ void emptyGroup();
+ void setCurrentTime();
+ void statesAndSignals();
+ void setParentAutoAdd();
+ void beginNestedGroup();
+};
+
+tst_QAnimationGroup::tst_QAnimationGroup()
+{
+}
+
+tst_QAnimationGroup::~tst_QAnimationGroup()
+{
+}
+
+void tst_QAnimationGroup::init()
+{
+ qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
+}
+
+void tst_QAnimationGroup::cleanup()
+{
+}
+
+void tst_QAnimationGroup::construction()
+{
+ QSequentialAnimationGroup animationgroup;
+}
+
+class AnimationObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ AnimationObject(int startValue = 0)
+ : v(startValue)
+ { }
+
+ int value() const { return v; }
+ void setValue(int value) { v = value; }
+
+ int v;
+};
+
+class TestAnimation : public QVariantAnimation
+{
+ Q_OBJECT
+public:
+ virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
+ virtual void updateState(QAbstractAnimation::State oldState,
+ QAbstractAnimation::State newState)
+ {
+ Q_UNUSED(oldState)
+ Q_UNUSED(newState)
+ };
+};
+
+class UncontrolledAnimation : public QPropertyAnimation
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0)
+ : QPropertyAnimation(target, propertyName, parent), id(0)
+ {
+ setDuration(250);
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+void tst_QAnimationGroup::emptyGroup()
+{
+ QSequentialAnimationGroup group;
+ QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ group.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+
+ QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimation::pause: Cannot pause a stopped animation");
+ group.pause();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+
+ group.start();
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+
+ group.stop();
+
+ QCOMPARE(groupStateChangedSpy.count(), 4);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QAnimationGroup::setCurrentTime()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject s_o3;
+ AnimationObject p_o1;
+ AnimationObject p_o2;
+ AnimationObject p_o3;
+ AnimationObject t_o1;
+ AnimationObject t_o2;
+
+ // sequence operating on same object/property
+ QSequentialAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ a2_s_o1->setIterationCount(3);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroup *sequence2 = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value");
+ QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value");
+ sequence2->addAnimation(a1_s_o2);
+ sequence2->addAnimation(a1_s_o3);
+
+ // parallel operating on different object/properties
+ QAnimationGroup *parallel = new QParallelAnimationGroup();
+ QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
+ QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
+ QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
+ a1_p_o2->setIterationCount(3);
+ parallel->addAnimation(a1_p_o1);
+ parallel->addAnimation(a1_p_o2);
+ parallel->addAnimation(a1_p_o3);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation(&t_o1, "value");
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
+ loopsForever->setIterationCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroup group;
+ group.addAnimation(sequence);
+ group.addAnimation(sequence2);
+ group.addAnimation(parallel);
+ group.addAnimation(notTimeDriven);
+ group.addAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 1);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a1_p_o1->currentTime(), 1);
+ QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 1);
+ QCOMPARE(notTimeDriven->currentTime(), 1);
+ QCOMPARE(loopsForever->currentTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(sequence->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+ QCOMPARE(a1_p_o1->currentTime(), 250);
+ QCOMPARE(a1_p_o2->currentTime(), 0);
+ QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 250);
+ QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(loopsForever->currentIteration(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentTime(), 251);
+ QCOMPARE(sequence->currentTime(), 251);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 251);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 1);
+ QCOMPARE(a1_p_o1->currentTime(), 250);
+ QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 251);
+ QCOMPARE(loopsForever->currentTime(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+}
+
+void tst_QAnimationGroup::statesAndSignals()
+{
+}
+
+void tst_QAnimationGroup::setParentAutoAdd()
+{
+ QParallelAnimationGroup group;
+ QVariantAnimation *animation = new QPropertyAnimation(&group);
+ QCOMPARE(animation->group(), &group);
+}
+
+void tst_QAnimationGroup::beginNestedGroup()
+{
+ QAnimationGroup *subGroup;
+ QAnimationGroup *parent = new QParallelAnimationGroup();
+
+ for (int i = 0; i < 10; ++i) {
+ if (i & 1)
+ subGroup = new QParallelAnimationGroup(parent);
+ else
+ subGroup = new QSequentialAnimationGroup(parent);
+
+ QCOMPARE(parent->animationCount(), 1);
+ QAnimationGroup *child = static_cast<QAnimationGroup *>(parent->animationAt(0));
+
+ QCOMPARE(child->parent(), static_cast<QObject *>(parent));
+ if (i & 1)
+ QVERIFY(qobject_cast<QParallelAnimationGroup *> (child));
+ else
+ QVERIFY(qobject_cast<QSequentialAnimationGroup *> (child));
+
+ parent = child;
+ }
+}
+
+QTEST_MAIN(tst_QAnimationGroup)
+#include "tst_qanimationgroup.moc"
diff --git a/tests/auto/qanimationstate/qanimationstate.pro b/tests/auto/qanimationstate/qanimationstate.pro
new file mode 100644
index 0000000..8862c27
--- /dev/null
+++ b/tests/auto/qanimationstate/qanimationstate.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core
+SOURCES += tst_qanimationstate.cpp
+
+
diff --git a/tests/auto/qanimationstate/tst_qanimationstate.cpp b/tests/auto/qanimationstate/tst_qanimationstate.cpp
new file mode 100644
index 0000000..085db24
--- /dev/null
+++ b/tests/auto/qanimationstate/tst_qanimationstate.cpp
@@ -0,0 +1,625 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qstate.h>
+#include <QtCore/qstatemachine.h>
+#include <QtCore/qanimationstate.h>
+
+//TESTED_CLASS=QAnimationState
+//TESTED_FILES=
+
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)
+
+
+class tst_QAnimationState : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAnimationState();
+ virtual ~tst_QAnimationState();
+
+private slots:
+ void init();
+ void cleanup();
+ void construction();
+ void noAnimation();
+ void simpleAnimation();
+ void twoAnimations();
+ void reuseAnimation();
+ void nestedTargetState();
+ void parallelTargetState();
+ void playTwice();
+ void twoAnimatedTransitions();
+ void globalRestoreProperty();
+ void specificRestoreProperty();
+ void someAnimationsNotSpecified();
+ void someActionsNotAnimated();
+ void specificTargetValueOfAnimation();
+ void persistentTargetValueOfAnimation();
+};
+
+tst_QAnimationState::tst_QAnimationState()
+{
+}
+
+tst_QAnimationState::~tst_QAnimationState()
+{
+}
+
+void tst_QAnimationState::init()
+{
+}
+
+void tst_QAnimationState::cleanup()
+{
+}
+
+void tst_QAnimationState::construction()
+{
+ QAnimationState as;
+}
+
+class EventTransition : public QTransition
+{
+public:
+ EventTransition(QEvent::Type type, QAbstractState *target)
+ : QTransition(), m_type(type) {
+ setTargetState(target);
+ }
+protected:
+ virtual bool eventTest(QEvent *e) const {
+ return (e->type() == m_type);
+ }
+private:
+ QEvent::Type m_type;
+};
+
+void tst_QAnimationState::noAnimation()
+{
+ QStateMachine machine;
+
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ s2->setProperty("entered", false);
+ s2->setPropertyOnEntry(s2, "entered", true);
+
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s1));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(s2->property("entered").toBool(), true);
+ QVERIFY(machine.configuration().contains(s2));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QVERIFY(machine.configuration().contains(s1));
+
+ s2->setProperty("entered", false);
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(s2->property("entered").toBool(), true);
+ QVERIFY(machine.configuration().contains(s2));
+}
+
+class ValueCheckerState: public QState
+{
+public:
+ ValueCheckerState(QState *parent)
+ : QState(parent)
+ {
+ }
+
+ void addPropertyToCheck(const QObject *object, const char *propertyName)
+ {
+ m_objects.append(object);
+ m_propertyNames.append(propertyName);
+ valueOnEntry.append(QVariant());
+ }
+
+ QVariantList valueOnEntry;
+
+protected:
+ virtual void onEntry()
+ {
+ for (int i=0; i<m_objects.size(); ++i)
+ valueOnEntry[i] = m_objects.at(i)->property(m_propertyNames.at(i));
+
+ QState::onEntry();
+ }
+
+ QList<const QObject *> m_objects;
+ QList<QByteArray> m_propertyNames;
+
+};
+
+void tst_QAnimationState::simpleAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "fooBar");
+ s2->setPropertyOnEntry(object, "fooBar", 2.0);
+
+ QPropertyAnimation *animation = new QPropertyAnimation(object, "fooBar", s2);
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2), animation);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+}
+
+void tst_QAnimationState::twoAnimations()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+ s2->setPropertyOnEntry(object, "bar", 10.0);
+
+ QPropertyAnimation *animationFoo = new QPropertyAnimation(object, "foo", s2);
+ QPropertyAnimation *animationBar = new QPropertyAnimation(object, "bar", s2);
+ animationBar->setDuration(900);
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(animationFoo);
+ as->addAnimation(animationBar);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 10.0);
+}
+
+void tst_QAnimationState::parallelTargetState()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(QState::ParallelGroup, machine.rootState());
+
+ ValueCheckerState *c1 = new ValueCheckerState(s2);
+ c1->setPropertyOnEntry(object, "foo", 2.0);
+ c1->addPropertyToCheck(object, "foo");
+ c1->addPropertyToCheck(object, "bar");
+
+ QState *c2 = new QState(s2);
+ c2->setPropertyOnEntry(object, "bar", 10.0);
+
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(c1->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(c1->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(c1->valueOnEntry.at(1).toDouble(), 10.0);
+}
+
+
+void tst_QAnimationState::twoAnimatedTransitions()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->setPropertyOnEntry(object, "foo", 5.0);
+ ValueCheckerState *s3 = new ValueCheckerState(machine.rootState());
+ s3->setPropertyOnEntry(object, "foo", 2.0);
+ s3->addPropertyToCheck(object, "foo");
+
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2),
+ new QPropertyAnimation(object, "foo", s2));
+ s2->addAnimatedTransition(new EventTransition(QEvent::User, s3),
+ new QPropertyAnimation(object, "foo", s2));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s3->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s3->valueOnEntry.at(0).toDouble(), 2.0);
+}
+
+void tst_QAnimationState::playTwice()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->setPropertyOnEntry(object, "foo", 5.0);
+ QState *s3 = new QState(machine.rootState());
+ s3->setPropertyOnEntry(object, "foo", 2.0);
+
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2),
+ new QPropertyAnimation(object, "foo", s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+ s3->addTransition(s1);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QVERIFY(machine.configuration().contains(s1));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+
+ s2->valueOnEntry[0] = QVariant();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(object->property("foo").toDouble(), 5.0);
+}
+
+void tst_QAnimationState::nestedTargetState()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ QState *s2Child = new QState(s2);
+ s2Child->setPropertyOnEntry(object, "bar", 10.0);
+ s2->setInitialState(s2Child);
+
+ QState *s2Child2 = new QState(s2);
+ s2Child2->setPropertyOnEntry(object, "bar", 11.0);
+ s2Child->addTransition(s2Child2); // should *not* be considered by QAnimationState as part of target
+
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 10.0);
+ QCOMPARE(object->property("bar").toDouble(), 11.0);
+}
+
+void tst_QAnimationState::reuseAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->setPropertyOnEntry(object, "foo", 5.0);
+ ValueCheckerState *s3 = new ValueCheckerState(machine.rootState());
+ s3->setPropertyOnEntry(object, "foo", 2.0);
+ s3->addPropertyToCheck(object, "foo");
+
+ QPropertyAnimation *anim = new QPropertyAnimation(object, "foo", s2);
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2), anim);
+ s2->addAnimatedTransition(new EventTransition(QEvent::User, s3), anim);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s3->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s3->valueOnEntry.at(0).toDouble(), 2.0);
+}
+
+void tst_QAnimationState::globalRestoreProperty()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ ValueCheckerState *s3 = new ValueCheckerState(machine.rootState());
+ s3->addPropertyToCheck(object, "foo");
+ s3->addPropertyToCheck(object, "bar");
+ s3->setPropertyOnEntry(object, "bar", 5.0);
+
+ ValueCheckerState *s4 = new ValueCheckerState(machine.rootState());
+ s4->addPropertyToCheck(object, "foo");
+ s4->addPropertyToCheck(object, "bar");
+
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ as = s2->addAnimatedTransition(new EventTransition(QEvent::User, s3));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ as = s3->addAnimatedTransition(new EventTransition(QEvent::User, s4));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 3.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s3->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s3->valueOnEntry.at(0).toDouble(), 1.0);
+ QCOMPARE(s3->valueOnEntry.at(1).toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s4->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s4->valueOnEntry.at(0).toDouble(), 1.0);
+ QCOMPARE(s4->valueOnEntry.at(1).toDouble(), 3.0);
+
+}
+
+void tst_QAnimationState::specificRestoreProperty()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->setRestorePolicy(QState::RestoreProperties);
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ ValueCheckerState *s3 = new ValueCheckerState(machine.rootState());
+ s3->setRestorePolicy(QState::RestoreProperties);
+ s3->addPropertyToCheck(object, "foo");
+ s3->addPropertyToCheck(object, "bar");
+ s3->setPropertyOnEntry(object, "bar", 5.0);
+
+ ValueCheckerState *s4 = new ValueCheckerState(machine.rootState());
+ s4->setRestorePolicy(QState::RestoreProperties);
+ s4->addPropertyToCheck(object, "foo");
+ s4->addPropertyToCheck(object, "bar");
+
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+
+ as = s2->addAnimatedTransition(new EventTransition(QEvent::User, s3));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ as = s3->addAnimatedTransition(new EventTransition(QEvent::User, s4));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 3.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s3->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s3->valueOnEntry.at(0).toDouble(), 1.0);
+ QCOMPARE(s3->valueOnEntry.at(1).toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s4->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s4->valueOnEntry.at(0).toDouble(), 1.0);
+ QCOMPARE(s4->valueOnEntry.at(1).toDouble(), 3.0);
+}
+
+void tst_QAnimationState::someAnimationsNotSpecified()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ QAnimationState *as = s1->addAnimatedTransition(new EventTransition(QEvent::User, s2));
+ as->addAnimation(new QPropertyAnimation(object, "foo", as));
+ as->addAnimation(new QPropertyAnimation(object, "bar", as));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 3.0);
+}
+
+void tst_QAnimationState::someActionsNotAnimated()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->addPropertyToCheck(object, "bar");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+ s2->setPropertyOnEntry(object, "bar", 5.0);
+
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2),
+ new QPropertyAnimation(object, "foo", s1));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(s2->valueOnEntry.at(1).toDouble(), 3.0);
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(object->property("bar").toDouble(), 5.0);
+}
+
+void tst_QAnimationState::specificTargetValueOfAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
+ anim->setEndValue(10.0);
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2), anim);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 10.0);
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QAnimationState::persistentTargetValueOfAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ ValueCheckerState *s2 = new ValueCheckerState(machine.rootState());
+ s2->addPropertyToCheck(object, "foo");
+ s2->setPropertyOnEntry(object, "foo", 2.0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
+ s1->addAnimatedTransition(new EventTransition(QEvent::User, s2), anim);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QTRY_COMPARE(s2->valueOnEntry.at(0).isValid(), true);
+ QCOMPARE(s2->valueOnEntry.at(0).toDouble(), 2.0);
+ QCOMPARE(anim->endValue().isValid(), false);
+}
+
+
+QTEST_MAIN(tst_QAnimationState)
+#include "tst_qanimationstate.moc"
diff --git a/tests/auto/qeasingcurve/qeasingcurve.pro b/tests/auto/qeasingcurve/qeasingcurve.pro
new file mode 100644
index 0000000..2b66081
--- /dev/null
+++ b/tests/auto/qeasingcurve/qeasingcurve.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT = core
+SOURCES += tst_qeasingcurve.cpp
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
new file mode 100644
index 0000000..9e3ffcc
--- /dev/null
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -0,0 +1,488 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#if QT_VERSION < 0x040200
+QTEST_NOOP_MAIN
+#else
+
+#include <qeasingcurve.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QEasingCurve : public QObject {
+ Q_OBJECT
+
+public:
+ tst_QEasingCurve();
+ virtual ~tst_QEasingCurve();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void type();
+ void propertyDefaults();
+ void valueForProgress_data();
+ void valueForProgress();
+ void setCustomType();
+ void operators();
+
+protected:
+};
+
+tst_QEasingCurve::tst_QEasingCurve()
+{
+}
+
+tst_QEasingCurve::~tst_QEasingCurve()
+{
+}
+
+void tst_QEasingCurve::init()
+{
+}
+
+void tst_QEasingCurve::cleanup()
+{
+}
+#include <qdebug.h>
+
+void tst_QEasingCurve::type()
+{
+ {
+ QEasingCurve curve(QEasingCurve::Linear);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+
+ curve.setPeriod(5);
+ curve.setAmplitude(3);
+ QCOMPARE(curve.period(), 5.0);
+ QCOMPARE(curve.amplitude(), 3.0);
+
+ curve.setType(QEasingCurve::InElastic);
+ QCOMPARE(curve.period(), 5.0);
+ QCOMPARE(curve.amplitude(), 3.0);
+ }
+
+ {
+ QEasingCurve curve(QEasingCurve::InElastic);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+ curve.setAmplitude(2);
+ QCOMPARE(curve.type(), QEasingCurve::InElastic);
+ curve.setType(QEasingCurve::Linear);
+ }
+
+ {
+ // check bounaries
+ QEasingCurve curve(QEasingCurve::InCubic);
+ QTest::ignoreMessage(QtWarningMsg, "QEasingCurve: Invalid curve type 9999");
+ curve.setType((QEasingCurve::Type)9999);
+ QCOMPARE(curve.type(), QEasingCurve::InCubic);
+ QTest::ignoreMessage(QtWarningMsg, "QEasingCurve: Invalid curve type -9999");
+ curve.setType((QEasingCurve::Type)-9999);
+ QCOMPARE(curve.type(), QEasingCurve::InCubic);
+ QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1")
+ .arg(QEasingCurve::NCurveTypes).toLatin1().constData());
+ curve.setType(QEasingCurve::NCurveTypes);
+ QCOMPARE(curve.type(), QEasingCurve::InCubic);
+ QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1")
+ .arg(QEasingCurve::Custom).toLatin1().constData());
+ curve.setType(QEasingCurve::Custom);
+ QCOMPARE(curve.type(), QEasingCurve::InCubic);
+ QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QEasingCurve: Invalid curve type %1")
+ .arg(-1).toLatin1().constData());
+ curve.setType((QEasingCurve::Type)-1);
+ QCOMPARE(curve.type(), QEasingCurve::InCubic);
+ curve.setType(QEasingCurve::Linear);
+ QCOMPARE(curve.type(), QEasingCurve::Linear);
+ curve.setType(QEasingCurve::CosineCurve);
+ QCOMPARE(curve.type(), QEasingCurve::CosineCurve);
+ }
+}
+
+void tst_QEasingCurve::propertyDefaults()
+{
+ {
+ // checks if the defaults are correct, but also demonstrates a weakness with the API.
+ QEasingCurve curve(QEasingCurve::InElastic);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+ QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ curve.setType(QEasingCurve::InBounce);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+ QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ curve.setType(QEasingCurve::Linear);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+ QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ curve.setType(QEasingCurve::InElastic);
+ QCOMPARE(curve.period(), 0.3);
+ QCOMPARE(curve.amplitude(), 1.0);
+ QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ curve.setPeriod(0.4);
+ curve.setAmplitude(0.6);
+ curve.setOvershoot(1.0);
+ curve.setType(QEasingCurve::Linear);
+ QCOMPARE(curve.period(), 0.4);
+ QCOMPARE(curve.amplitude(), 0.6);
+ QCOMPARE(curve.overshoot(), 1.0);
+ curve.setType(QEasingCurve::InElastic);
+ QCOMPARE(curve.period(), 0.4);
+ QCOMPARE(curve.amplitude(), 0.6);
+ QCOMPARE(curve.overshoot(), 1.0);
+ }
+}
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+void tst_QEasingCurve::valueForProgress_data()
+{
+ QTest::addColumn<int>("type");
+ QTest::addColumn<IntList>("at");
+ QTest::addColumn<IntList>("expected");
+ // automatically generated.
+ // note that values are scaled from range [0,1] to range [0, 100] in order to store them as
+ // integer values and avoid fp inaccuracies
+
+ QTest::newRow("Linear") << int(QEasingCurve::Linear)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100);
+
+ QTest::newRow("InQuad") << int(QEasingCurve::InQuad)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 4 << 16 << 36 << 64 << 100);
+
+ QTest::newRow("OutQuad") << int(QEasingCurve::OutQuad)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 36 << 64 << 84 << 96 << 100);
+
+ QTest::newRow("InOutQuad") << int(QEasingCurve::InOutQuad)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 8 << 32 << 68 << 92 << 100);
+
+ QTest::newRow("OutInQuad") << int(QEasingCurve::OutInQuad)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 32 << 48 << 52 << 68 << 100);
+
+ QTest::newRow("InCubic") << int(QEasingCurve::InCubic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 6 << 21 << 51 << 100);
+
+ QTest::newRow("OutCubic") << int(QEasingCurve::OutCubic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 48 << 78 << 93 << 99 << 100);
+
+ QTest::newRow("InOutCubic") << int(QEasingCurve::InOutCubic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 3 << 25 << 74 << 96 << 100);
+
+ QTest::newRow("OutInCubic") << int(QEasingCurve::OutInCubic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 39 << 49 << 50 << 60 << 100);
+
+ QTest::newRow("InQuart") << int(QEasingCurve::InQuart)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 2 << 12 << 40 << 100);
+
+ QTest::newRow("OutQuart") << int(QEasingCurve::OutQuart)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 59 << 87 << 97 << 99 << 100);
+
+ QTest::newRow("InOutQuart") << int(QEasingCurve::InOutQuart)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 1 << 20 << 79 << 98 << 100);
+
+ QTest::newRow("OutInQuart") << int(QEasingCurve::OutInQuart)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 43 << 49 << 50 << 56 << 100);
+
+ QTest::newRow("InQuint") << int(QEasingCurve::InQuint)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 1 << 7 << 32 << 100);
+
+ QTest::newRow("OutQuint") << int(QEasingCurve::OutQuint)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 67 << 92 << 98 << 99 << 100);
+
+ QTest::newRow("InOutQuint") << int(QEasingCurve::InOutQuint)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 16 << 83 << 99 << 100);
+
+ QTest::newRow("OutInQuint") << int(QEasingCurve::OutInQuint)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 46 << 49 << 50 << 53 << 100);
+
+ QTest::newRow("InSine") << int(QEasingCurve::InSine)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 4 << 19 << 41 << 69 << 100);
+
+ QTest::newRow("OutSine") << int(QEasingCurve::OutSine)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 30 << 58 << 80 << 95 << 100);
+
+ QTest::newRow("InOutSine") << int(QEasingCurve::InOutSine)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 9 << 34 << 65 << 90 << 100);
+
+ QTest::newRow("OutInSine") << int(QEasingCurve::OutInSine)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 29 << 47 << 52 << 70 << 100);
+
+ QTest::newRow("InExpo") << int(QEasingCurve::InExpo)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 1 << 6 << 24 << 100);
+
+ QTest::newRow("OutExpo") << int(QEasingCurve::OutExpo)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 75 << 93 << 98 << 99 << 100);
+
+ QTest::newRow("InOutExpo") << int(QEasingCurve::InOutExpo)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 12 << 87 << 99 << 100);
+
+ QTest::newRow("OutInExpo") << int(QEasingCurve::OutInExpo)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 46 << 49 << 50 << 53 << 100);
+
+ QTest::newRow("InCirc") << int(QEasingCurve::InCirc)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 2 << 8 << 19 << 40 << 100);
+
+ QTest::newRow("OutCirc") << int(QEasingCurve::OutCirc)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 59 << 80 << 91 << 97 << 100);
+
+ QTest::newRow("InOutCirc") << int(QEasingCurve::InOutCirc)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 4 << 20 << 80 << 95 << 100);
+
+ QTest::newRow("OutInCirc") << int(QEasingCurve::OutInCirc)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 40 << 48 << 51 << 60 << 100);
+
+ QTest::newRow("InElastic") << int(QEasingCurve::InElastic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << 1 << -3 << -12 << 100);
+
+ QTest::newRow("OutElastic") << int(QEasingCurve::OutElastic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 112 << 103 << 98 << 100 << 100);
+
+ QTest::newRow("InOutElastic") << int(QEasingCurve::InOutElastic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 0 << -6 << 106 << 99 << 100);
+
+ QTest::newRow("OutInElastic") << int(QEasingCurve::OutInElastic)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 56 << 49 << 49 << 53 << 100);
+
+ QTest::newRow("InBack") << int(QEasingCurve::InBack)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << -4 << -9 << -2 << 29 << 100);
+
+ QTest::newRow("OutBack") << int(QEasingCurve::OutBack)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 70 << 102 << 109 << 104 << 100);
+
+ QTest::newRow("InOutBack") << int(QEasingCurve::InOutBack)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << -9 << 8 << 91 << 109 << 100);
+
+ QTest::newRow("OutInBack") << int(QEasingCurve::OutInBack)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 51 << 52 << 47 << 48 << 100);
+
+ QTest::newRow("InBounce") << int(QEasingCurve::InBounce)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 6 << 22 << 8 << 69 << 100);
+
+ QTest::newRow("OutBounce") << int(QEasingCurve::OutBounce)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 30 << 91 << 77 << 93 << 100);
+
+ QTest::newRow("InOutBounce") << int(QEasingCurve::InOutBounce)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 11 << 34 << 65 << 88 << 100);
+
+ QTest::newRow("OutInBounce") << int(QEasingCurve::OutInBounce)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 41 << 43 << 56 << 58 << 100);
+
+ QTest::newRow("InCurve") << int(QEasingCurve::InCurve)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 10 << 37 << 60 << 80 << 100);
+
+ QTest::newRow("OutCurve") << int(QEasingCurve::OutCurve)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 20 << 39 << 62 << 89 << 100);
+
+ QTest::newRow("SineCurve") << int(QEasingCurve::SineCurve)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 0 << 34 << 90 << 90 << 34 << 0);
+
+ QTest::newRow("CosineCurve") << int(QEasingCurve::CosineCurve)
+ << (IntList() << 0 << 20 << 40 << 60 << 80 << 100)
+ << (IntList() << 50 << 97 << 79 << 20 << 2 << 49);
+
+
+}
+
+
+void tst_QEasingCurve::valueForProgress()
+{
+#if 0
+ // used to generate data tables...
+ QFile out;
+ out.open(stdout, QIODevice::WriteOnly);
+ for (int c = QEasingCurve::Linear; c < QEasingCurve::NCurveTypes - 1; ++c) {
+ QEasingCurve curve((QEasingCurve::Type)c);
+ QMetaObject mo = QEasingCurve::staticMetaObject;
+ QString strCurve = QLatin1String(mo.enumerator(mo.indexOfEnumerator("Type")).key(c));
+ QString strInputs;
+ QString strOutputs;
+
+ for (int t = 0; t <= 100; t+= 20) {
+ qreal ease = curve.valueForProgress(t/qreal(100));
+ strInputs += QString::fromAscii(" << %1").arg(t);
+ strOutputs += QString::fromAscii(" << %1").arg(int(100*ease));
+
+ }
+ QString str = QString::fromAscii(" QTest::newRow(\"%1\") << int(QEasingCurve::%2)\n"
+ "\t\t << (IntList() %3)\n"
+ "\t\t << (IntList() %4);\n\n")
+ .arg(strCurve)
+ .arg(strCurve)
+ .arg(strInputs)
+ .arg(strOutputs);
+ out.write(str.toLatin1().constData());
+ }
+ out.close();
+ exit(1);
+#else
+ QFETCH(int, type);
+ QFETCH(IntList, at);
+ QFETCH(IntList, expected);
+
+ QEasingCurve curve((QEasingCurve::Type)type);
+ for (int i = 0; i < at.count(); ++i) {
+ qreal ease = curve.valueForProgress(at.at(i)/qreal(100));
+ int ex = expected.at(i);
+ QCOMPARE(int(100*ease), ex);
+ }
+#endif
+}
+
+static qreal discreteEase(qreal progress)
+{
+ return qFloor(progress * 10) / qreal(10.0);
+}
+
+void tst_QEasingCurve::setCustomType()
+{
+ QEasingCurve curve;
+ curve.setCustomType(&discreteEase);
+ QCOMPARE(curve.type(), QEasingCurve::Custom);
+ QCOMPARE(curve.valueForProgress(0.0), 0.0);
+ QCOMPARE(curve.valueForProgress(0.05), 0.0);
+ QCOMPARE(curve.valueForProgress(0.10), 0.1);
+ QCOMPARE(curve.valueForProgress(0.15), 0.1);
+ QCOMPARE(curve.valueForProgress(0.20), 0.2);
+ QCOMPARE(curve.valueForProgress(0.25), 0.2);
+ QCOMPARE(curve.valueForProgress(0.30), 0.3);
+ QCOMPARE(curve.valueForProgress(0.35), 0.3);
+ QCOMPARE(curve.valueForProgress(0.999999), 0.9);
+
+ curve.setType(QEasingCurve::Linear);
+ QCOMPARE(curve.type(), QEasingCurve::Linear);
+ QCOMPARE(curve.valueForProgress(0.0), 0.0);
+ QCOMPARE(curve.valueForProgress(0.1), 0.1);
+ QCOMPARE(curve.valueForProgress(0.5), 0.5);
+ QCOMPARE(curve.valueForProgress(0.99), 0.99);
+}
+
+void tst_QEasingCurve::operators()
+{
+ // operator=
+ QEasingCurve curve;
+ QEasingCurve curve2;
+ curve.setCustomType(&discreteEase);
+ curve2 = curve;
+ QCOMPARE(curve2.type(), QEasingCurve::Custom);
+ QCOMPARE(curve2.valueForProgress(0.0), 0.0);
+ QCOMPARE(curve2.valueForProgress(0.05), 0.0);
+ QCOMPARE(curve2.valueForProgress(0.15), 0.1);
+ QCOMPARE(curve2.valueForProgress(0.25), 0.2);
+ QCOMPARE(curve2.valueForProgress(0.35), 0.3);
+ QCOMPARE(curve2.valueForProgress(0.999999), 0.9);
+
+ // operator==
+ curve.setType(QEasingCurve::InBack);
+ curve2 = curve;
+ curve2.setOvershoot(qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), curve2.overshoot());
+ QVERIFY(curve2 == curve);
+
+ curve.setOvershoot(3.0);
+ QVERIFY(curve2 != curve);
+ curve2.setOvershoot(3.0);
+ QVERIFY(curve2 == curve);
+
+ curve2.setType(QEasingCurve::Linear);
+ QCOMPARE(curve.overshoot(), curve2.overshoot());
+ QVERIFY(curve2 != curve);
+ curve2.setType(QEasingCurve::InBack);
+ QCOMPARE(curve.overshoot(), curve2.overshoot());
+ QVERIFY(curve2 == curve);
+}
+
+
+QTEST_MAIN(tst_QEasingCurve)
+#include "tst_qeasingcurve.moc"
+
+#endif //QT_VERSION
diff --git a/tests/auto/qparallelanimationgroup/qparallelanimationgroup.pro b/tests/auto/qparallelanimationgroup/qparallelanimationgroup.pro
new file mode 100644
index 0000000..f2cacd3
--- /dev/null
+++ b/tests/auto/qparallelanimationgroup/qparallelanimationgroup.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qparallelanimationgroup.cpp
+
+
diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
new file mode 100644
index 0000000..c7f33b7
--- /dev/null
+++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -0,0 +1,834 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qparallelanimationgroup.h>
+
+//TESTED_CLASS=QParallelAnimationGroup
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(QAbstractAnimation::State)
+
+class tst_QParallelAnimationGroup : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QParallelAnimationGroup();
+ virtual ~tst_QParallelAnimationGroup();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void clearGroup();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void iterationCount_data();
+ void iterationCount();
+ void autoAdd();
+};
+
+tst_QParallelAnimationGroup::tst_QParallelAnimationGroup()
+{
+}
+
+tst_QParallelAnimationGroup::~tst_QParallelAnimationGroup()
+{
+}
+
+void tst_QParallelAnimationGroup::init()
+{
+ qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
+}
+
+void tst_QParallelAnimationGroup::cleanup()
+{
+}
+
+void tst_QParallelAnimationGroup::construction()
+{
+ QParallelAnimationGroup animationgroup;
+}
+
+class AnimationObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ AnimationObject(int startValue = 0)
+ : v(startValue)
+ { }
+
+ int value() const { return v; }
+ void setValue(int value) { v = value; }
+
+ int v;
+};
+
+class TestAnimation : public QVariantAnimation
+{
+ Q_OBJECT
+public:
+ virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
+ virtual void updateState(QAbstractAnimation::State oldState,
+ QAbstractAnimation::State newState)
+ {
+ Q_UNUSED(oldState)
+ Q_UNUSED(newState)
+ };
+};
+
+class TestAnimation2 : public QVariantAnimation
+{
+ Q_OBJECT
+public:
+ TestAnimation2(QAbstractAnimation *animation) : QVariantAnimation(animation) {}
+ TestAnimation2(int duration, QAbstractAnimation *animation) : QVariantAnimation(animation), m_duration(duration) {}
+
+ virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
+ virtual void updateState(QAbstractAnimation::State oldState,
+ QAbstractAnimation::State newState)
+ {
+ Q_UNUSED(oldState)
+ Q_UNUSED(newState)
+ };
+
+ virtual int duration() const {
+ return m_duration;
+ }
+private:
+ int m_duration;
+};
+
+class UncontrolledAnimation : public QPropertyAnimation
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0)
+ : QPropertyAnimation(target, propertyName, parent), id(0)
+ {
+ setDuration(250);
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+void tst_QParallelAnimationGroup::setCurrentTime()
+{
+ AnimationObject p_o1;
+ AnimationObject p_o2;
+ AnimationObject p_o3;
+ AnimationObject t_o1;
+ AnimationObject t_o2;
+
+ // parallel operating on different object/properties
+ QAnimationGroup *parallel = new QParallelAnimationGroup();
+ QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
+ QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
+ QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
+ a1_p_o2->setIterationCount(3);
+ parallel->addAnimation(a1_p_o1);
+ parallel->addAnimation(a1_p_o2);
+ parallel->addAnimation(a1_p_o3);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation(&t_o1, "value");
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
+ loopsForever->setIterationCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroup group;
+ group.addAnimation(parallel);
+ group.addAnimation(notTimeDriven);
+ group.addAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(a1_p_o1->currentTime(), 1);
+ QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 1);
+ QCOMPARE(notTimeDriven->currentTime(), 1);
+ QCOMPARE(loopsForever->currentTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(a1_p_o1->currentTime(), 250);
+ QCOMPARE(a1_p_o2->currentTime(), 0);
+ QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 250);
+ QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(loopsForever->currentIteration(), 1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentTime(), 251);
+ QCOMPARE(a1_p_o1->currentTime(), 250);
+ QCOMPARE(a1_p_o2->currentTime(), 1);
+ QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o3->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 251);
+ QCOMPARE(loopsForever->currentTime(), 1);
+}
+
+void tst_QParallelAnimationGroup::clearGroup()
+{
+ QParallelAnimationGroup group;
+
+ for (int i = 0; i < 10; ++i) {
+ new QParallelAnimationGroup(&group);
+ }
+
+ QCOMPARE(group.animationCount(), 10);
+
+ int count = group.animationCount();
+ QPointer<QAbstractAnimation> *children = new QPointer<QAbstractAnimation>[count];
+ for (int i = 0; i < count; ++i) {
+ QVERIFY(group.animationAt(i) != 0);
+ children[i] = group.animationAt(i);
+ }
+
+ group.clearAnimations();
+ QCOMPARE(group.animationCount(), 0);
+ QCOMPARE(group.currentTime(), 0);
+ for (int i = 0; i < count; ++i)
+ QCOMPARE(children[i], QPointer<QAbstractAnimation>());
+
+ delete[] children;
+}
+
+void tst_QParallelAnimationGroup::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QParallelAnimationGroup group;
+
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation anim1(&o, "ole");
+ anim1.setEndValue(43);
+ anim1.setDuration(100);
+ QVERIFY(!anim1.currentValue().isValid());
+ QCOMPARE(anim1.currentValue().toInt(), 0);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QVERIFY(anim2.currentValue().isValid());
+ QCOMPARE(anim2.currentValue().toInt(), 0);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroup::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QParallelAnimationGroup group;
+
+ TestAnimation anim;
+ anim.setStartValue(0);
+ anim.setEndValue(100);
+ anim.setDuration(200);
+
+ QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroup group;
+
+ QVariantAnimation *anim1 = new TestAnimation;
+ anim1->setStartValue(0);
+ anim1->setEndValue(100);
+ anim1->setDuration(200);
+ group.addAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1->state(), QAnimationGroup::Running);
+
+ QTest::qWait(50);
+ QVERIFY(group.currentTime() > 0);
+
+ delete anim1;
+ QVERIFY(group.animationCount() == 0);
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.currentTime(), 0); //that's the invariant
+}
+
+void tst_QParallelAnimationGroup::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(200);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+}
+
+void tst_QParallelAnimationGroup::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(200);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QParallelAnimationGroup::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(200);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).at(1)),
+ QAnimationGroup::Paused);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy1.count(), 3);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QAnimationGroup::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).at(1)),
+ QAnimationGroup::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QAnimationGroup::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QAnimationGroup::Running);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Running);
+}
+
+void tst_QParallelAnimationGroup::zeroDurationAnimation()
+{
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(0);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(100);
+
+ QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy1(&anim1, SIGNAL(finished()));
+
+ QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy2(&anim2, SIGNAL(finished()));
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(finishedSpy1.count(), 1);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(finishedSpy2.count(), 0);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QAnimationGroup::Running);
+
+
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Running);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+
+
+ group.stop();
+ group.setIterationCount(4);
+ stateChangedSpy1.clear();
+ stateChangedSpy2.clear();
+
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ group.setCurrentTime(150);
+ QCOMPARE(stateChangedSpy1.count(), 4);
+ QCOMPARE(stateChangedSpy2.count(), 3);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 6);
+ QCOMPARE(stateChangedSpy2.count(), 5);
+
+}
+
+void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
+{
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(0);
+
+ AnimationObject o1;
+ UncontrolledAnimation notTimeDriven(&o1, "value");
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever;
+ loopsForever.setStartValue(0);
+ loopsForever.setEndValue(100);
+ loopsForever.setDuration(100);
+ loopsForever.setIterationCount(-1);
+
+ QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&notTimeDriven);
+ group.addAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Stopped);
+}
+
+struct AnimState {
+ AnimState(int time = -1) : time(time), state(-1) {}
+ AnimState(int time, int state) : time(time), state(state) {}
+ int time;
+ int state;
+};
+
+#define Running QAbstractAnimation::Running
+#define Stopped QAbstractAnimation::Stopped
+
+Q_DECLARE_METATYPE(AnimState)
+void tst_QParallelAnimationGroup::iterationCount_data()
+{
+ QTest::addColumn<bool>("directionBackward");
+ QTest::addColumn<int>("setIterationCount");
+ QTest::addColumn<int>("initialGroupTime");
+ QTest::addColumn<int>("currentGroupTime");
+ QTest::addColumn<AnimState>("expected1");
+ QTest::addColumn<AnimState>("expected2");
+ QTest::addColumn<AnimState>("expected3");
+
+ // D U R A T I O N
+ // 100 60*2 0
+ // direction = Forward
+ QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped);
+
+ QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+
+ // direction = Forward, rewind
+ QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped);
+
+ // direction = Backward
+ QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+
+ // rewind, direction = Backward
+ QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+ // infinite looping
+ QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ // infinite looping, direction = Backward (will only loop once)
+ QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+
+}
+
+void tst_QParallelAnimationGroup::iterationCount()
+{
+ QFETCH(bool, directionBackward);
+ QFETCH(int, setIterationCount);
+ QFETCH(int, initialGroupTime);
+ QFETCH(int, currentGroupTime);
+ QFETCH(AnimState, expected1);
+ QFETCH(AnimState, expected2);
+ QFETCH(AnimState, expected3);
+
+ QParallelAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(100);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(60); //total 120
+ anim2.setIterationCount(2);
+
+ TestAnimation anim3;
+ anim3.setStartValue(0);
+ anim3.setEndValue(100);
+ anim3.setDuration(0);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+ group.addAnimation(&anim3);
+
+ group.setIterationCount(setIterationCount);
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+ if (directionBackward)
+ group.setDirection(QAbstractAnimation::Backward);
+
+ group.start();
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+
+ anim1.setCurrentTime(42); // 42 is "untouched"
+ anim2.setCurrentTime(42);
+
+ group.setCurrentTime(currentGroupTime);
+
+ QCOMPARE(anim1.currentTime(), expected1.time);
+ QCOMPARE(anim2.currentTime(), expected2.time);
+ QCOMPARE(anim3.currentTime(), expected3.time);
+
+ if (expected1.state >=0)
+ QCOMPARE(int(anim1.state()), expected1.state);
+ if (expected2.state >=0)
+ QCOMPARE(int(anim2.state()), expected2.state);
+ if (expected3.state >=0)
+ QCOMPARE(int(anim3.state()), expected3.state);
+
+}
+
+void tst_QParallelAnimationGroup::autoAdd()
+{
+ QParallelAnimationGroup group;
+ QCOMPARE(group.duration(), 0);
+ TestAnimation2 *test = new TestAnimation2(250, &group); // 0, duration = 250;
+ QCOMPARE(test->group(), &group);
+ QCOMPARE(test->duration(), 250);
+ QCOMPARE(group.duration(), 250);
+
+ test = new TestAnimation2(750, &group); // 1
+ QCOMPARE(test->group(), &group);
+ QCOMPARE(group.duration(), 750);
+ test = new TestAnimation2(500, &group); // 2
+ QCOMPARE(test->group(), &group);
+ QCOMPARE(group.duration(), 750);
+
+ delete group.animationAt(1); // remove the one with duration = 750
+ QCOMPARE(group.duration(), 500);
+
+ delete group.animationAt(1); // remove the one with duration = 500
+ QCOMPARE(group.duration(), 250);
+
+ test = static_cast<TestAnimation2*>(group.animationAt(0));
+ test->setParent(0); // remove the last one (with duration = 250)
+ QCOMPARE(test->group(), static_cast<QAnimationGroup*>(0));
+ QCOMPARE(group.duration(), 0);
+}
+
+QTEST_MAIN(tst_QParallelAnimationGroup)
+#include "tst_qparallelanimationgroup.moc"
diff --git a/tests/auto/qpropertyanimation/qpropertyanimation.pro b/tests/auto/qpropertyanimation/qpropertyanimation.pro
new file mode 100644
index 0000000..6d6ddbf
--- /dev/null
+++ b/tests/auto/qpropertyanimation/qpropertyanimation.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qpropertyanimation.cpp
+
+
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
new file mode 100644
index 0000000..f61df49
--- /dev/null
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -0,0 +1,831 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qpropertyanimation.h>
+#include <QtGui/qitemanimation.h>
+#include <QtGui/qwidget.h>
+
+//TESTED_CLASS=QPropertyAnimation
+//TESTED_FILES=
+
+class UncontrolledAnimation : public QPropertyAnimation
+{
+ Q_OBJECT
+public:
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void updateCurrentTime(int msecs)
+ {
+ QPropertyAnimation::updateCurrentTime(msecs);
+ if (msecs >= QPropertyAnimation::duration())
+ stop();
+ }
+};
+
+class tst_QPropertyAnimation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QPropertyAnimation();
+ virtual ~tst_QPropertyAnimation();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void construction();
+ void setCurrentTime_data();
+ void setCurrentTime();
+ void statesAndSignals_data();
+ void statesAndSignals();
+ void deletion1();
+ void deletion2();
+ void deletion3();
+ void duration0();
+ void noStartValue();
+ void startWhenAnotherIsRunning();
+ void easingcurve_data();
+ void easingcurve();
+ void startWithoutStartValue();
+ void playForwardBackward();
+ void interpolated();
+ void setStartEndValues();
+ void zeroDurationStart();
+ void operationsInStates_data();
+ void operationsInStates();
+};
+
+tst_QPropertyAnimation::tst_QPropertyAnimation()
+{
+}
+
+tst_QPropertyAnimation::~tst_QPropertyAnimation()
+{
+}
+
+void tst_QPropertyAnimation::init()
+{
+ qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
+ qRegisterMetaType<QAbstractAnimation::DeletionPolicy>("QAbstractAnimation::DeletionPolicy");
+}
+
+void tst_QPropertyAnimation::cleanup()
+{
+}
+
+class AnimationObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(qreal realValue READ realValue WRITE setRealValue)
+public:
+ AnimationObject(int startValue = 0)
+ : v(startValue)
+ { }
+
+ int value() const { return v; }
+ void setValue(int value) { v = value; }
+
+ qreal realValue() const { return rv; }
+ void setRealValue(qreal value) { rv = value; }
+
+ int v;
+ qreal rv;
+};
+
+
+void tst_QPropertyAnimation::construction()
+{
+ QPropertyAnimation panimation;
+}
+
+void tst_QPropertyAnimation::setCurrentTime_data()
+{
+ QTest::addColumn<int>("duration");
+ QTest::addColumn<int>("iterationCount");
+ QTest::addColumn<int>("currentTime");
+ QTest::addColumn<int>("testCurrentTime");
+ QTest::addColumn<int>("testCurrentLoop");
+
+ QTest::newRow("-1") << -1 << 1 << 0 << 0 << 0;
+ QTest::newRow("0") << 0 << 1 << 0 << 0 << 0;
+ QTest::newRow("1") << 0 << 1 << 1 << 0 << 0;
+ QTest::newRow("2") << 0 << 2 << 1 << 0 << 0;
+ QTest::newRow("3") << 1 << 1 << 0 << 0 << 0;
+ QTest::newRow("4") << 1 << 1 << 1 << 1 << 0;
+ QTest::newRow("5") << 1 << 2 << 1 << 0 << 1;
+ QTest::newRow("6") << 1 << 2 << 2 << 1 << 1;
+ QTest::newRow("7") << 1 << 2 << 3 << 1 << 1;
+ QTest::newRow("8") << 1 << 3 << 2 << 0 << 2;
+ QTest::newRow("9") << 1 << 3 << 3 << 1 << 2;
+ QTest::newRow("a") << 10 << 1 << 0 << 0 << 0;
+ QTest::newRow("b") << 10 << 1 << 1 << 1 << 0;
+ QTest::newRow("c") << 10 << 1 << 10 << 10 << 0;
+ QTest::newRow("d") << 10 << 2 << 10 << 0 << 1;
+ QTest::newRow("e") << 10 << 2 << 11 << 1 << 1;
+ QTest::newRow("f") << 10 << 2 << 20 << 10 << 1;
+ QTest::newRow("g") << 10 << 2 << 21 << 10 << 1;
+ QTest::newRow("negloop 0") << 10 << -1 << 0 << 0 << 0;
+ QTest::newRow("negloop 1") << 10 << -1 << 10 << 0 << 1;
+ QTest::newRow("negloop 2") << 10 << -1 << 15 << 5 << 1;
+ QTest::newRow("negloop 3") << 10 << -1 << 20 << 0 << 2;
+ QTest::newRow("negloop 4") << 10 << -1 << 30 << 0 << 3;
+}
+
+void tst_QPropertyAnimation::setCurrentTime()
+{
+ QFETCH(int, duration);
+ QFETCH(int, iterationCount);
+ QFETCH(int, currentTime);
+ QFETCH(int, testCurrentTime);
+ QFETCH(int, testCurrentLoop);
+
+ QPropertyAnimation animation;
+ if (duration < 0)
+ QTest::ignoreMessage(QtWarningMsg, "QVariantAnimation::setDuration: cannot set a negative duration");
+ animation.setDuration(duration);
+ animation.setIterationCount(iterationCount);
+ animation.setCurrentTime(currentTime);
+
+ QCOMPARE(animation.currentTime(), testCurrentTime);
+ QCOMPARE(animation.currentIteration(), testCurrentLoop);
+}
+
+void tst_QPropertyAnimation::statesAndSignals_data()
+{
+ QTest::addColumn<bool>("uncontrolled");
+ QTest::newRow("normal animation") << false;
+ QTest::newRow("animation with undefined duration") << true;
+}
+
+void tst_QPropertyAnimation::statesAndSignals()
+{
+ QFETCH(bool, uncontrolled);
+ QPropertyAnimation *anim = uncontrolled ? new UncontrolledAnimation : new QPropertyAnimation;
+ anim->setDuration(100);
+
+ QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy currentLoopSpy(anim, SIGNAL(currentIterationChanged(int)));
+
+ anim->setCurrentTime(1);
+ anim->setCurrentTime(100);
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.count(), 0);
+ QCOMPARE(currentLoopSpy.count(), 0);
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+
+ anim->setIterationCount(3);
+ anim->setCurrentTime(101);
+
+ if (uncontrolled)
+ QSKIP("Uncontrolled animations don't handle looping", SkipSingle);
+
+ QCOMPARE(currentLoopSpy.count(), 1);
+ QCOMPARE(anim->currentIteration(), 1);
+
+ anim->setCurrentTime(0);
+ QCOMPARE(currentLoopSpy.count(), 2);
+ QCOMPARE(anim->currentIteration(), 0);
+
+ anim->start();
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(runningSpy.count(), 1); //anim must have started
+ QCOMPARE(anim->currentIteration(), 0);
+ runningSpy.clear();
+
+ anim->stop();
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(runningSpy.count(), 1); //anim must have stopped
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(anim->currentTime(), 0);
+ QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(currentLoopSpy.count(), 2);
+ runningSpy.clear();
+
+ anim->start();
+ QTest::qWait(1000);
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(runningSpy.count(), 2); //started and stopped again
+ runningSpy.clear();
+ QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(anim->currentTime(), 100);
+ QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(currentLoopSpy.count(), 4);
+
+ anim->start(); // auto-rewinds
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(anim->currentTime(), 0);
+ QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(currentLoopSpy.count(), 5);
+ QCOMPARE(runningSpy.count(), 1); // anim has started
+ QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(anim->currentIteration(), 0);
+ runningSpy.clear();
+
+ QTest::qWait(1000);
+
+ QCOMPARE(currentLoopSpy.count(), 7);
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(runningSpy.count(), 1); // anim has stopped
+ QCOMPARE(finishedSpy.count(), 2);
+ QCOMPARE(anim->currentTime(), 100);
+
+ delete anim;
+}
+
+void tst_QPropertyAnimation::deletion1()
+{
+ QObject *object = new QWidget;
+ QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object,"minimumWidth");
+
+ //test that the animation is deleted correctly depending of the deletion flag passed in start()
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ anim->setStartValue(10);
+ anim->setEndValue(20);
+ anim->setDuration(200);
+ anim->start();
+ QCOMPARE(runningSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QVERIFY(anim);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QTest::qWait(100);
+ QVERIFY(anim);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QTest::qWait(150);
+ QVERIFY(anim); //The animation should not have been deleted
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(runningSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 1);
+
+ anim->start(QVariantAnimation::DeleteWhenStopped);
+ QVERIFY(anim);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QTest::qWait(100);
+ QVERIFY(anim);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QTest::qWait(150);
+ QVERIFY(!anim); //The animation must have been deleted
+ QCOMPARE(runningSpy.count(), 4);
+ QCOMPARE(finishedSpy.count(), 2);
+ delete object;
+}
+
+void tst_QPropertyAnimation::deletion2()
+{
+ //test that the animation get deleted if the object is deleted
+ QObject *object = new QWidget;
+ QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object,"minimumWidth");
+ anim->setStartValue(10);
+ anim->setEndValue(20);
+ anim->setDuration(200);
+
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+
+ anim->setStartValue(10);
+ anim->setEndValue(20);
+ anim->setDuration(200);
+ anim->start();
+
+ QTest::qWait(50);
+ QVERIFY(anim);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+
+ QCOMPARE(runningSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ //we can't call deletaLater directly because the delete would only happen in the next iteration of _this_ event loop
+ QTimer::singleShot(0, object, SLOT(deleteLater()));
+ QTest::qWait(50);
+
+ QVERIFY(anim->targetObject() == 0);
+}
+
+void tst_QPropertyAnimation::deletion3()
+{
+ //test that the stopped signal is emit when the animation is destroyed
+ QObject *object = new QWidget;
+ QPropertyAnimation *anim = new QPropertyAnimation(object,"minimumWidth");
+ anim->setStartValue(10);
+ anim->setEndValue(20);
+ anim->setDuration(200);
+
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ anim->start();
+
+ QTest::qWait(50);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(runningSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+ delete anim;
+ QCOMPARE(runningSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 0);
+}
+
+void tst_QPropertyAnimation::duration0()
+{
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation animation(&o, "ole");
+ animation.setEndValue(43);
+ QVERIFY(!animation.currentValue().isValid());
+ QCOMPARE(animation.currentValue().toInt(), 0);
+ QCOMPARE(o.property("ole").toInt(), 42);
+ animation.setDuration(0);
+ animation.start();
+ QCOMPARE(animation.state(), QAnimationGroup::Stopped);
+ QCOMPARE(animation.currentTime(), 0);
+ QCOMPARE(o.property("ole").toInt(), 43);
+}
+
+class StartValueTester : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int ole READ ole WRITE setOle)
+public:
+ StartValueTester() : o(0) { }
+ int ole() const { return o; }
+ void setOle(int v) { o = v; values << v; }
+
+ int o;
+ QList<int> values;
+};
+
+void tst_QPropertyAnimation::noStartValue()
+{
+ StartValueTester o;
+ o.setProperty("ole", 42);
+ o.values.clear();
+
+ QPropertyAnimation a(&o, "ole");
+ a.setEndValue(420);
+ a.setDuration(250);
+ a.start();
+
+ QTest::qWait(300);
+
+ QCOMPARE(o.values.first(), 42);
+ QCOMPARE(o.values.last(), 420);
+}
+
+void tst_QPropertyAnimation::startWhenAnotherIsRunning()
+{
+ StartValueTester o;
+ o.setProperty("ole", 42);
+ o.values.clear();
+
+ {
+ //normal case: the animation finishes and is deleted
+ QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ anim->start(QVariantAnimation::DeleteWhenStopped);
+ QTest::qWait(anim->duration() + 50);
+ QCOMPARE(runningSpy.count(), 2); //started and then stopped
+ QVERIFY(!anim);
+ }
+
+ {
+ QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ anim->start(QVariantAnimation::DeleteWhenStopped);
+ QTest::qWait(anim->duration()/2);
+ QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole");
+ QCOMPARE(runningSpy.count(), 1);
+ QCOMPARE(anim->state(), QVariantAnimation::Running);
+
+ //anim2 will interrupt anim1
+ QMetaObject::invokeMethod(anim2, "start", Qt::QueuedConnection, Q_ARG(QAbstractAnimation::DeletionPolicy, QVariantAnimation::DeleteWhenStopped));
+ QTest::qWait(50);
+ QVERIFY(!anim); //anim should have been deleted
+ QVERIFY(anim2);
+ QTest::qWait(anim2->duration());
+ QVERIFY(!anim2); //anim2 is finished: it should have been deleted by now
+ QVERIFY(!anim);
+ }
+
+}
+
+// copy from easing.cpp in case that function changes definition
+static qreal easeInOutBack(qreal t)
+{
+ qreal s = 1.70158;
+ qreal t_adj = 2.0f * (qreal)t;
+ if (t_adj < 1) {
+ s *= 1.525f;
+ return 1.0/2*(t_adj*t_adj*((s+1)*t_adj - s));
+ } else {
+ t_adj -= 2;
+ s *= 1.525f;
+ return 1.0/2*(t_adj*t_adj*((s+1)*t_adj + s) + 2);
+ }
+}
+
+void tst_QPropertyAnimation::easingcurve_data()
+{
+ QTest::addColumn<int>("currentTime");
+ QTest::addColumn<int>("expectedvalue");
+
+ QTest::newRow("interpolation1") << 0 << 0;
+ QTest::newRow("interpolation2") << 1000 << 1000;
+ QTest::newRow("extrapolationbelow") << 250 << -99;
+ QTest::newRow("extrapolationabove") << 750 << 1099;
+}
+
+void tst_QPropertyAnimation::easingcurve()
+{
+ QFETCH(int, currentTime);
+ QFETCH(int, expectedvalue);
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation pAnimation(&o, "ole");
+ pAnimation.setStartValue(0);
+ pAnimation.setEndValue(1000);
+ pAnimation.setDuration(1000);
+
+ // this easingcurve assumes that we extrapolate before startValue and after endValue
+ QEasingCurve easingCurve;
+ easingCurve.setCustomType(easeInOutBack);
+ pAnimation.setEasingCurve(easingCurve);
+ pAnimation.start();
+ pAnimation.pause();
+ pAnimation.setCurrentTime(currentTime);
+ QCOMPARE(o.property("ole").toInt(), expectedvalue);
+}
+
+void tst_QPropertyAnimation::startWithoutStartValue()
+{
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation anim(&o, "ole");
+ anim.setEndValue(100);
+
+ anim.start();
+
+ QTest::qWait(100);
+ int current = anim.currentValue().toInt();
+ //it is somewhere in the animation
+ QVERIFY(current > 42);
+ QVERIFY(current < 100);
+
+ QTest::qWait(200);
+ QCOMPARE(anim.state(), QVariantAnimation::Stopped);
+
+ anim.setEndValue(110);
+ anim.start();
+ current = anim.currentValue().toInt();
+ QCOMPARE(current, 42); // the initial default start value
+
+ QTest::qWait(100);
+ current = anim.currentValue().toInt();
+ //it is somewhere in the animation
+ QVERIFY(current > 42);
+ QVERIFY(current < 110);
+}
+
+void tst_QPropertyAnimation::playForwardBackward()
+{
+ QObject o;
+ o.setProperty("ole", 0);
+ QCOMPARE(o.property("ole").toInt(), 0);
+
+ QPropertyAnimation anim(&o, "ole");
+ anim.setEndValue(100);
+ anim.start();
+ QTest::qWait(anim.duration() + 50);
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(anim.currentTime(), anim.duration());
+
+ //the animation is at the end
+ anim.setDirection(QVariantAnimation::Backward);
+ anim.start();
+ QCOMPARE(anim.state(), QAbstractAnimation::Running);
+ QTest::qWait(anim.duration() + 50);
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(anim.currentTime(), 0);
+
+ //the direction is backward
+ //restarting should jump to the end
+ anim.start();
+ QCOMPARE(anim.state(), QAbstractAnimation::Running);
+ QCOMPARE(anim.currentTime(), anim.duration());
+ QTest::qWait(anim.duration() + 50);
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(anim.currentTime(), 0);
+}
+
+struct Number
+{
+ Number() {}
+ Number(int n)
+ : n(n) {}
+
+ Number(const Number &other)
+ : n(other.n){}
+
+ Number &operator=(const Number &other) {
+ n = other.n;
+ return *this;
+ }
+ bool operator==(const Number &other) const {
+ return n == other.n;
+ }
+
+ int n;
+};
+
+Q_DECLARE_METATYPE(Number)
+Q_DECLARE_METATYPE(QAbstractAnimation::State)
+
+QVariant numberInterpolator(const Number &f, const Number &t, qreal progress)
+{
+ return qVariantFromValue<Number>(Number(f.n + (t.n - f.n)*progress));
+}
+
+QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progress)
+{
+ return QPointF(f.x() + (t.x() - f.x())*progress, f.y());
+}
+
+void tst_QPropertyAnimation::interpolated()
+{
+ QObject o;
+ o.setProperty("number", qVariantFromValue<Number>(Number(42)));
+ QCOMPARE(qVariantValue<Number>(o.property("number")), Number(42));
+ {
+ qRegisterAnimationInterpolator<Number>(numberInterpolator);
+ QPropertyAnimation anim(&o, "number");
+ anim.setStartValue(qVariantFromValue<Number>(Number(0)));
+ anim.setEndValue(qVariantFromValue<Number>(Number(100)));
+ anim.setDuration(1000);
+ anim.start();
+ anim.pause();
+ anim.setCurrentTime(100);
+ Number t(qVariantValue<Number>(o.property("number")));
+ QCOMPARE(t, Number(10));
+ anim.setCurrentTime(500);
+ QCOMPARE(qVariantValue<Number>(o.property("number")), Number(50));
+ }
+ {
+ qRegisterAnimationInterpolator<QPointF>(xaxisQPointInterpolator);
+ QPropertyAnimation anim(&o, "point");
+ anim.setStartValue(QPointF(0,0));
+ anim.setEndValue(QPointF(100, 100));
+ anim.setDuration(1000);
+ anim.start();
+ anim.pause();
+ anim.setCurrentTime(100);
+ QCOMPARE(o.property("point").toPointF(), QPointF(10, 0));
+ anim.setCurrentTime(500);
+ QCOMPARE(o.property("point").toPointF(), QPointF(50, 0));
+ }
+ {
+ // unregister it and see if we get back the default behaviour
+ qRegisterAnimationInterpolator<QPointF>(0);
+ QPropertyAnimation anim(&o, "point");
+ anim.setStartValue(QPointF(0,0));
+ anim.setEndValue(QPointF(100, 100));
+ anim.setDuration(1000);
+ anim.start();
+ anim.pause();
+ anim.setCurrentTime(100);
+ QCOMPARE(o.property("point").toPointF(), QPointF(10, 10));
+ anim.setCurrentTime(500);
+ QCOMPARE(o.property("point").toPointF(), QPointF(50, 50));
+ }
+
+ {
+ // Interpolate a qreal property with a int interpolator
+ AnimationObject o1;
+ o1.setRealValue(42.42);
+ QPropertyAnimation anim(&o1, "realValue");
+ anim.setStartValue(0);
+ anim.setEndValue(100);
+ anim.start();
+ QCOMPARE(o1.realValue(), qreal(0));
+ anim.setCurrentTime(250);
+ QCOMPARE(o1.realValue(), qreal(100));
+ }
+}
+
+void tst_QPropertyAnimation::setStartEndValues()
+{
+ //this tests the start value, end value and default start value
+ QObject o;
+ o.setProperty("ole", 42);
+ QPropertyAnimation anim(&o, "ole");
+ QVariantAnimation::KeyValues values;
+ QCOMPARE(anim.keyValues(), values);
+
+ //let's add a start value
+ anim.setStartValue(0);
+ values << QVariantAnimation::KeyValue(0, 0);
+ QCOMPARE(anim.keyValues(), values);
+
+ anim.setEndValue(10);
+ values << QVariantAnimation::KeyValue(1, 10);
+ QCOMPARE(anim.keyValues(), values);
+
+ //now we can play with objects
+ QCOMPARE(o.property("ole").toInt(), 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+ anim.start();
+ QVERIFY(anim.startValue().isValid());
+ QCOMPARE(o.property("ole"), anim.startValue());
+
+ //now we remove the explicit start value and test the implicit one
+ anim.stop();
+ o.setProperty("ole", 42);
+ values.remove(0);
+ anim.setStartValue(QVariant()); //reset the start value
+ QCOMPARE(anim.keyValues(), values);
+ QVERIFY(!anim.startValue().isValid());
+ anim.start();
+ QCOMPARE(o.property("ole").toInt(), 42);
+ anim.setCurrentTime(anim.duration()/2);
+ QCOMPARE(o.property("ole").toInt(), 26); //just in the middle of the animation
+ anim.setCurrentTime(anim.duration());
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped); //it should have stopped
+ QVERIFY(anim.endValue().isValid());
+ QCOMPARE(o.property("ole"), anim.endValue()); //end of the animations
+
+ //now we set back the startValue
+ anim.setStartValue(5);
+ QVERIFY(anim.startValue().isValid());
+ anim.start();
+ QCOMPARE(o.property("ole").toInt(), 5);
+}
+
+void tst_QPropertyAnimation::zeroDurationStart()
+{
+ QPropertyAnimation anim;
+ QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ anim.setDuration(0);
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ anim.start();
+ //the animation stops immediately
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(spy.count(), 2);
+
+ //let's check the first state change
+ const QVariantList firstChange = spy.first();
+ //old state
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Stopped);
+ //new state
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Running);
+
+ //let's check the first state change
+ const QVariantList secondChange = spy.last();
+ //old state
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Running);
+ //new state
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Stopped);
+}
+
+#define Pause 1
+#define Start 2
+#define Resume 3
+#define Stop 4
+
+void tst_QPropertyAnimation::operationsInStates_data()
+{
+ QTest::addColumn<QAbstractAnimation::State>("originState");
+ QTest::addColumn<int>("operation");
+ QTest::addColumn<QString>("expectedWarning");
+ QTest::addColumn<QAbstractAnimation::State>("expectedState");
+
+ QString pauseWarn(QLatin1String("QAbstractAnimation::pause: Cannot pause a stopped animation"));
+ QString resumeWarn(QLatin1String("QAbstractAnimation::resume: Cannot resume an animation that is not paused"));
+
+ QTest::newRow("S-pause") << QAbstractAnimation::Stopped << Pause << pauseWarn << QAbstractAnimation::Stopped;
+ QTest::newRow("S-start") << QAbstractAnimation::Stopped << Start << QString() << QAbstractAnimation::Running;
+ QTest::newRow("S-resume") << QAbstractAnimation::Stopped << Resume << resumeWarn << QAbstractAnimation::Stopped;
+ QTest::newRow("S-stop") << QAbstractAnimation::Stopped << Stop << QString() << QAbstractAnimation::Stopped;
+
+ QTest::newRow("P-pause") << QAbstractAnimation::Paused << Pause << QString() << QAbstractAnimation::Paused;
+ QTest::newRow("P-start") << QAbstractAnimation::Paused << Start << QString() << QAbstractAnimation::Running;
+ QTest::newRow("P-resume") << QAbstractAnimation::Paused << Resume << QString() << QAbstractAnimation::Running;
+ QTest::newRow("P-stop") << QAbstractAnimation::Paused << Stop << QString() << QAbstractAnimation::Stopped;
+
+ QTest::newRow("R-pause") << QAbstractAnimation::Running << Pause << QString() << QAbstractAnimation::Paused;
+ QTest::newRow("R-start") << QAbstractAnimation::Running << Start << QString() << QAbstractAnimation::Running;
+ QTest::newRow("R-resume") << QAbstractAnimation::Running << Resume << resumeWarn << QAbstractAnimation::Running;
+ QTest::newRow("R-stop") << QAbstractAnimation::Running << Stop << QString() << QAbstractAnimation::Stopped;
+}
+
+void tst_QPropertyAnimation::operationsInStates()
+{
+/**
+ * | pause() |start() |resume() |stop()
+ * ----------+------------+-----------+-----------+-------------------+
+ * Stopped | Stopped |Running |Stopped |Stopped |
+ * _| qWarning | |qWarning |- |
+ * Paused | Paused |Running |Running |Stopped |
+ * _| - | | | |
+ * Running | Paused |Running |Running |Stopped |
+ * | |restart |qWarning | |
+ * ----------+------------+-----------+-----------+-------------------+
+**/
+
+ QFETCH(QAbstractAnimation::State, originState);
+ QFETCH(int, operation);
+ QFETCH(QString, expectedWarning);
+ QFETCH(QAbstractAnimation::State, expectedState);
+
+ QObject o;
+ o.setProperty("ole", 42);
+ QPropertyAnimation anim(&o, "ole");
+ QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ anim.stop();
+ switch (originState) {
+ case QAbstractAnimation::Stopped:
+ break;
+ case QAbstractAnimation::Paused:
+ anim.start();
+ anim.pause();
+ break;
+ case QAbstractAnimation::Running:
+ anim.start();
+ break;
+ }
+ if (!expectedWarning.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning));
+ }
+ QCOMPARE(anim.state(), originState);
+ switch (operation) {
+ case Pause:
+ anim.pause();
+ break;
+ case Start:
+ anim.start();
+ break;
+ case Resume:
+ anim.resume();
+ break;
+ case Stop:
+ anim.stop();
+ break;
+ }
+
+ QCOMPARE(anim.state(), expectedState);
+}
+#undef Pause
+#undef Start
+#undef Resume
+#undef Stop
+
+QTEST_MAIN(tst_QPropertyAnimation)
+#include "tst_qpropertyanimation.moc"
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
index 9b9dd16..1025d2a 100644
--- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
+++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
@@ -107,6 +107,7 @@ class MyQObject : public QObject
Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
+ Q_PROPERTY(Policy enumProperty READ enumProperty WRITE setEnumProperty)
Q_ENUMS(Policy Strategy)
Q_FLAGS(Ability)
@@ -144,6 +145,7 @@ public:
m_hiddenValue(456.0),
m_writeOnlyValue(789),
m_readOnlyValue(987),
+ m_enumValue(BarPolicy),
m_qtFunctionInvoked(-1)
{ }
@@ -205,6 +207,11 @@ public:
void setPropWithCustomType(const CustomType &c)
{ m_customType = c; }
+ Policy enumProperty() const
+ { return m_enumValue; }
+ void setEnumProperty(Policy policy)
+ { m_enumValue = policy; }
+
int qtFunctionInvoked() const
{ return m_qtFunctionInvoked; }
@@ -255,8 +262,8 @@ public:
{ m_qtFunctionInvoked = 36; m_actuals << policy; }
Q_INVOKABLE Policy myInvokableReturningEnum()
{ m_qtFunctionInvoked = 37; return BazPolicy; }
- Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum()
- { m_qtFunctionInvoked = 38; return BazPolicy; }
+ Q_INVOKABLE MyQObject::Strategy myInvokableReturningQualifiedEnum()
+ { m_qtFunctionInvoked = 38; return BazStrategy; }
Q_INVOKABLE QVector<int> myInvokableReturningVectorOfInt()
{ m_qtFunctionInvoked = 11; return QVector<int>(); }
Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector<int> &)
@@ -410,6 +417,7 @@ protected:
int m_readOnlyValue;
QKeySequence m_shortcut;
CustomType m_customType;
+ Policy m_enumValue;
int m_qtFunctionInvoked;
QVariantList m_actuals;
QByteArray m_connectedSignal;
@@ -417,6 +425,7 @@ protected:
};
Q_DECLARE_METATYPE(MyQObject*)
+Q_DECLARE_METATYPE(MyQObject::Policy)
class MyOtherQObject : public MyQObject
{
@@ -530,6 +539,24 @@ static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
return ctx->callee().property("value");
}
+static QScriptValue policyToScriptValue(QScriptEngine *engine, const MyQObject::Policy &policy)
+{
+ return qScriptValueFromValue(engine, policy);
+}
+
+static void policyFromScriptValue(const QScriptValue &value, MyQObject::Policy &policy)
+{
+ QString str = value.toString();
+ if (str == QLatin1String("red"))
+ policy = MyQObject::FooPolicy;
+ else if (str == QLatin1String("green"))
+ policy = MyQObject::BarPolicy;
+ else if (str == QLatin1String("blue"))
+ policy = MyQObject::BazPolicy;
+ else
+ policy = (MyQObject::Policy)-1;
+}
+
void tst_QScriptExtQObject::getSetStaticProperty()
{
QCOMPARE(m_engine->evaluate("myObject.noSuchProperty").isUndefined(), true);
@@ -751,6 +778,31 @@ void tst_QScriptExtQObject::getSetStaticProperty()
QScriptValue::ReadOnly);
}
+ // enum property
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::BarPolicy);
+ {
+ QScriptValue val = m_engine->evaluate("myObject.enumProperty");
+ QVERIFY(val.isNumber());
+ QCOMPARE(val.toInt32(), (int)MyQObject::BarPolicy);
+ }
+ m_engine->evaluate("myObject.enumProperty = 2");
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::BazPolicy);
+ m_engine->evaluate("myObject.enumProperty = 'BarPolicy'");
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::BarPolicy);
+ m_engine->evaluate("myObject.enumProperty = 'ScoobyDoo'");
+ // ### ouch! Shouldn't QMetaProperty::write() rather not change the value...?
+ QCOMPARE(m_myObject->enumProperty(), (MyQObject::Policy)-1);
+ // enum property with custom conversion
+ qScriptRegisterMetaType<MyQObject::Policy>(m_engine, policyToScriptValue, policyFromScriptValue);
+ m_engine->evaluate("myObject.enumProperty = 'red'");
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::FooPolicy);
+ m_engine->evaluate("myObject.enumProperty = 'green'");
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::BarPolicy);
+ m_engine->evaluate("myObject.enumProperty = 'blue'");
+ QCOMPARE(m_myObject->enumProperty(), MyQObject::BazPolicy);
+ m_engine->evaluate("myObject.enumProperty = 'nada'");
+ QCOMPARE(m_myObject->enumProperty(), (MyQObject::Policy)-1);
+
// auto-dereferencing of pointers
{
QBrush b = QColor(0xCA, 0xFE, 0xBA, 0xBE);
@@ -1879,6 +1931,16 @@ void tst_QScriptExtQObject::classEnums()
QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(m_engine->evaluate("myObject.myInvokableWithEnumArg('BarPolicy')").isUndefined(), true);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 10);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BarPolicy));
+
+ m_myObject->resetQtFunctionInvoked();
+ QVERIFY(m_engine->evaluate("myObject.myInvokableWithEnumArg('NoSuchPolicy')").isError());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+
+ m_myObject->resetQtFunctionInvoked();
QCOMPARE(m_engine->evaluate("myObject.myInvokableWithQualifiedEnumArg(MyQObject.BazPolicy)").isUndefined(), true);
QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
diff --git a/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro b/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro
new file mode 100644
index 0000000..ad861c3
--- /dev/null
+++ b/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qsequentialanimationgroup.cpp
+
+
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
new file mode 100644
index 0000000..18b57b2
--- /dev/null
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -0,0 +1,1649 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+
+#include <QtCore/qanimationgroup.h>
+#include <QtCore/qsequentialanimationgroup.h>
+
+//TESTED_CLASS=QSequentialAnimationGroup
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(QAbstractAnimation::State)
+Q_DECLARE_METATYPE(QAbstractAnimation*)
+
+class tst_QSequentialAnimationGroup : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QSequentialAnimationGroup();
+ virtual ~tst_QSequentialAnimationGroup();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void setCurrentTimeWithUncontrolledAnimation();
+ void seekingForwards();
+ void seekingBackwards();
+ void pauseAndResume();
+ void restart();
+ void looping();
+ void startDelay();
+ void clearGroup();
+ void groupWithZeroDurationAnimations();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void finishWithUncontrolledAnimation();
+ void addRemoveAnimation();
+ void currentAnimation();
+ void currentAnimationWithZeroDuration();
+ void insertAnimation();
+ void clearAnimations();
+};
+
+tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup()
+{
+}
+
+tst_QSequentialAnimationGroup::~tst_QSequentialAnimationGroup()
+{
+}
+
+void tst_QSequentialAnimationGroup::init()
+{
+ qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
+ qRegisterMetaType<QAbstractAnimation*>("QAbstractAnimation*");
+}
+
+void tst_QSequentialAnimationGroup::cleanup()
+{
+}
+
+void tst_QSequentialAnimationGroup::construction()
+{
+ QSequentialAnimationGroup animationgroup;
+}
+
+class AnimationObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ AnimationObject(int startValue = 0)
+ : v(startValue)
+ { }
+
+ int value() const { return v; }
+ void setValue(int value) { v = value; }
+
+ int v;
+};
+
+class TestAnimation : public QVariantAnimation
+{
+ Q_OBJECT
+public:
+ virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
+ virtual void updateState(QAbstractAnimation::State oldState,
+ QAbstractAnimation::State newState)
+ {
+ Q_UNUSED(oldState)
+ Q_UNUSED(newState)
+ };
+};
+
+class UncontrolledAnimation : public QPropertyAnimation
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0)
+ : QPropertyAnimation(target, propertyName, parent)
+ {
+ setDuration(250);
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void updateCurrentTime(int msecs)
+ {
+ QPropertyAnimation::updateCurrentTime(msecs);
+ if (msecs >= QPropertyAnimation::duration())
+ stop();
+ }
+};
+
+void tst_QSequentialAnimationGroup::setCurrentTime()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject s_o3;
+
+ // sequence operating on same object/property
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ a2_s_o1->setIterationCount(3);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroup *sequence2 = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value");
+ QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value");
+ sequence2->addAnimation(a1_s_o2);
+ sequence2->addAnimation(a1_s_o3);
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+ group.addAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(sequence->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentTime(), 251);
+ QCOMPARE(sequence->currentTime(), 251);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 750
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentTime(), 750);
+ QCOMPARE(sequence->currentTime(), 750);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1000
+ group.setCurrentTime(1000);
+ QCOMPARE(group.currentTime(), 1000);
+ QCOMPARE(sequence->currentTime(), 1000);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1010
+ group.setCurrentTime(1010);
+ QCOMPARE(group.currentTime(), 1010);
+ QCOMPARE(sequence->currentTime(), 1010);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 10);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1250
+ group.setCurrentTime(1250);
+ QCOMPARE(group.currentTime(), 1250);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentTime(), 1500);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentTime(), 1750);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 500);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 250);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentTime(), 1750);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 500);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 250);
+}
+
+void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject t_o1;
+ AnimationObject t_o2;
+
+ // sequence operating on different object/properties
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value");
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a1_s_o2);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation(&t_o1, "value");
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
+ loopsForever->setIterationCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+ group.addAnimation(notTimeDriven);
+ group.addAnimation(loopsForever);
+ group.start();
+ group.pause(); // this allows the group to listen for the finish signal of its children
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(notTimeDriven->currentTime(), 0);
+ QCOMPARE(loopsForever->currentTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(sequence->currentTime(), 250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(notTimeDriven->currentTime(), 0);
+ QCOMPARE(loopsForever->currentTime(), 0);
+
+ // Current time = 500
+ group.setCurrentTime(500);
+ QCOMPARE(group.currentTime(), 500);
+ QCOMPARE(sequence->currentTime(), 500);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 0);
+ QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), notTimeDriven);
+
+ // Current time = 505
+ group.setCurrentTime(505);
+ QCOMPARE(group.currentTime(), 505);
+ QCOMPARE(sequence->currentTime(), 500);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 5);
+ QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), notTimeDriven);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Paused);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
+
+ // Current time = 750 (end of notTimeDriven animation)
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentTime(), 750);
+ QCOMPARE(sequence->currentTime(), 500);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 250);
+ QCOMPARE(loopsForever->currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Paused);
+
+ // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
+ group.setCurrentTime(800);
+ QCOMPARE(group.currentTime(), 800);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->currentTime(), 500);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(notTimeDriven->currentTime(), 250);
+ QCOMPARE(loopsForever->currentTime(), 50);
+
+ loopsForever->stop(); // this should stop the group
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::seekingForwards()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject s_o3;
+
+ // sequence operating on same object/property
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ a2_s_o1->setIterationCount(3);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroup *sequence2 = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value");
+ QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value");
+ sequence2->addAnimation(a1_s_o2);
+ sequence2->addAnimation(a1_s_o3);
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+ group.addAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentTime(), 1500);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 250);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ // this will restart the group
+ group.start();
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentTime(), 1750);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 500);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 250);
+}
+
+void tst_QSequentialAnimationGroup::seekingBackwards()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject s_o3;
+
+ // sequence operating on same object/property
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ a2_s_o1->setIterationCount(3);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroup *sequence2 = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o2 = new QPropertyAnimation(&s_o2, "value");
+ QVariantAnimation *a1_s_o3 = new QPropertyAnimation(&s_o3, "value");
+ sequence2->addAnimation(a1_s_o2);
+ sequence2->addAnimation(a1_s_o3);
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+ group.addAnimation(sequence2);
+
+ group.start();
+
+ // Current time = 1600
+ group.setCurrentTime(1600);
+ QCOMPARE(group.currentTime(), 1600);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 350);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 100);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Running);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroup::Running);
+
+ // Seeking backwards, current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentTime(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence2->currentTime(), 0);
+ QCOMPARE(a1_s_o2->currentTime(), 0);
+ QCOMPARE(a1_s_o3->currentTime(), 0);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(sequence->state(), QAnimationGroup::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Running);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentTime(), 1750);
+ QCOMPARE(sequence->currentTime(), 1250);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+ QCOMPARE(sequence2->currentTime(), 500);
+ QCOMPARE(a1_s_o2->currentTime(), 250);
+ QCOMPARE(a1_s_o3->currentTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
+}
+
+typedef QList<QAbstractAnimation::State> StateList;
+
+static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates)
+{
+ bool equals = true;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i >= spy.count() || i >= expectedStates.count()) {
+ equals = false;
+ break;
+ }
+ QList<QVariant> args = spy.at(i);
+ QAbstractAnimation::State st = expectedStates.at(i);
+ QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
+ if (equals && actual != st) {
+ equals = false;
+ break;
+ }
+ }
+ if (!equals) {
+ const char *stateStrings[] = {"Stopped", "Paused", "Running"};
+ QString e,a;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i < expectedStates.count()) {
+ int exp = int(expectedStates.at(i));
+ if (!e.isEmpty())
+ e += QLatin1String(", ");
+ e += QLatin1String(stateStrings[exp]);
+ }
+ if (i < spy.count()) {
+ QList<QVariant> args = spy.at(i);
+ QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
+ if (!a.isEmpty())
+ a += QLatin1String(", ");
+ if (int(actual) >= 0 && int(actual) <= 2) {
+ a += QLatin1String(stateStrings[int(actual)]);
+ } else {
+ a += QLatin1String("NaN");
+ }
+ }
+
+ }
+ qDebug("\n"
+ "expected (count == %d): %s\n"
+ "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a));
+ }
+ return equals;
+}
+
+void tst_QSequentialAnimationGroup::pauseAndResume()
+{
+ AnimationObject s_o1;
+
+ // sequence operating on same object/property
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ a2_s_o1->setIterationCount(2);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+ sequence->setIterationCount(2);
+
+ QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1751
+ group.setCurrentTime(1751);
+ QCOMPARE(group.currentTime(), 1751);
+ QCOMPARE(sequence->currentTime(), 751);
+ QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 1);
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
+
+ QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
+
+ QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running
+ << QAbstractAnimation::Stopped)));
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Paused);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).at(1)),
+ QAnimationGroup::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Paused);
+
+ group.resume();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(sequence->state(), QAnimationGroup::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroup::Running);
+
+ QVERIFY(group.currentTime() >= 1751);
+ QVERIFY(sequence->currentTime() >= 751);
+ QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QVERIFY(a3_s_o1->currentTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).at(1)),
+ QAnimationGroup::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
+
+ QVERIFY(group.currentTime() >= 1751);
+ QVERIFY(sequence->currentTime() >= 751);
+ QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QVERIFY(a3_s_o1->currentTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).at(1)),
+ QAnimationGroup::Paused);
+
+ group.stop();
+
+ QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).at(1)),
+ QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::restart()
+{
+ AnimationObject s_o1;
+
+ // sequence operating on same object/property
+ QAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimation*)));
+ QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QVariantAnimation *anims[3];
+ QSignalSpy *animsStateChanged[3];
+
+ for (int i = 0; i < 3; i++) {
+ anims[i] = new QPropertyAnimation(&s_o1, "value");
+ anims[i]->setDuration(100);
+ animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ }
+
+ anims[1]->setIterationCount(2);
+ sequence->addAnimation(anims[0]);
+ sequence->addAnimation(anims[1]);
+ sequence->addAnimation(anims[2]);
+ sequence->setIterationCount(2);
+
+ QSequentialAnimationGroup group;
+ group.addAnimation(sequence);
+
+ group.start();
+
+ QTest::qWait(500);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+
+ QTest::qWait(300);
+ QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
+
+ for (int i = 0; i < 3; i++) {
+ QCOMPARE(animsStateChanged[i]->count(), 4);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).at(1)),
+ QAnimationGroup::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).at(1)),
+ QAnimationGroup::Stopped);
+ }
+
+ QCOMPARE(seqStateChangedSpy.count(), 2);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
+ for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
+ QCOMPARE(anims[i%3], qVariantValue<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
+
+ group.start();
+
+ QCOMPARE(animsStateChanged[0]->count(), 5);
+ QCOMPARE(animsStateChanged[1]->count(), 4);
+ QCOMPARE(animsStateChanged[2]->count(), 4);
+ QCOMPARE(seqStateChangedSpy.count(), 3);
+}
+
+void tst_QSequentialAnimationGroup::looping()
+{
+ AnimationObject s_o1;
+ AnimationObject s_o2;
+ AnimationObject s_o3;
+
+ // sequence operating on same object/property
+ QSequentialAnimationGroup *sequence = new QSequentialAnimationGroup();
+ QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
+ QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
+
+ QSignalSpy a1Spy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy a2Spy(a2_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ a2_s_o1->setIterationCount(2);
+ sequence->addAnimation(a1_s_o1);
+ sequence->addAnimation(a2_s_o1);
+ sequence->addAnimation(a3_s_o1);
+ sequence->setIterationCount(2);
+
+ QSequentialAnimationGroup group;
+ QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ group.addAnimation(sequence);
+ group.setIterationCount(2);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentTime(), 1750);
+ QCOMPARE(sequence->currentTime(), 750);
+ QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(a1_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 1);
+ // this animation is at the beginning because it is the current one inside sequence
+ QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 0);
+ QCOMPARE(sequence->currentAnimation(), a3_s_o1);
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
+
+ QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running
+ << QAbstractAnimation::Stopped)));
+
+ QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused)));
+
+ QCOMPARE(seqSpy.count(), 2); // Running,Paused
+ QCOMPARE(groupSpy.count(), 2); // Running,Paused
+
+ // Looping, current time = duration + 1
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(group.currentTime(), 1);
+ QCOMPARE(group.currentIteration(), 1);
+ QCOMPARE(sequence->currentTime(), 1);
+ QCOMPARE(sequence->currentIteration(), 0);
+ QCOMPARE(a1_s_o1->currentTime(), 1);
+ QCOMPARE(a2_s_o1->currentTime(), 250);
+ QCOMPARE(a2_s_o1->currentIteration(), 1);
+ // this animation is at the end because it was run on the previous loop
+ QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroup::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroup::Stopped);
+
+ QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
+ QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused
+ << QAbstractAnimation::Stopped)));
+ QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused)));
+ QCOMPARE(groupSpy.count(), 2);
+}
+
+void tst_QSequentialAnimationGroup::startDelay()
+{
+ QSequentialAnimationGroup group;
+ group.addPause(250);
+ group.addPause(125);
+ QCOMPARE(group.totalDuration(), 375);
+
+ QEventLoop loop;
+ QObject::connect(&group, SIGNAL(finished()), &loop, SLOT(quit()));
+
+ QTime time;
+ time.start();
+ group.start();
+ loop.exec();
+
+ QVERIFY(time.elapsed() >= 375);
+ QVERIFY(time.elapsed() < 1000);
+}
+
+void tst_QSequentialAnimationGroup::clearGroup()
+{
+ QSequentialAnimationGroup group;
+
+ for (int i = 0; i < 10; ++i) {
+ QSequentialAnimationGroup *subGroup = new QSequentialAnimationGroup(&group);
+ group.addPause(100);
+ subGroup->addPause(10);
+ }
+
+ QCOMPARE(group.animationCount(), 20);
+
+ int count = group.animationCount();
+ QPointer<QAbstractAnimation> *children = new QPointer<QAbstractAnimation>[count];
+ for (int i = 0; i < count; ++i) {
+ QVERIFY(group.animationAt(i) != 0);
+ children[i] = group.animationAt(i);
+ }
+
+ group.clearAnimations();
+ QCOMPARE(group.animationCount(), 0);
+ QCOMPARE(group.currentTime(), 0);
+ for (int i = 0; i < count; ++i)
+ QCOMPARE(children[i], QPointer<QAbstractAnimation>());
+
+ delete[] children;
+}
+
+void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations()
+{
+ QObject o;
+ QObject o2;
+
+ o.setProperty("myProperty", 42);
+ o.setProperty("myOtherProperty", 13);
+ o2.setProperty("myProperty", 42);
+ o2.setProperty("myOtherProperty", 13);
+
+ QSequentialAnimationGroup group;
+
+ QVariantAnimation *a1 = new QPropertyAnimation(&o, "myProperty");
+ a1->setDuration(0);
+ a1->setEndValue(43);
+ group.addAnimation(a1);
+
+ //this should just run fine and change nothing
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), a1);
+
+ QVariantAnimation *a2 = new QPropertyAnimation(&o2, "myOtherProperty");
+ a2->setDuration(500);
+ a2->setEndValue(31);
+ group.addAnimation(a2);
+
+ QVariantAnimation *a3 = new QPropertyAnimation(&o, "myProperty");
+ a3->setDuration(0);
+ a3->setEndValue(44);
+ group.addAnimation(a3);
+
+ QVariantAnimation *a4 = new QPropertyAnimation(&o, "myOtherProperty");
+ a4->setDuration(250);
+ a4->setEndValue(75);
+ group.addAnimation(a4);
+
+ QVariantAnimation *a5 = new QPropertyAnimation(&o2, "myProperty");
+ a5->setDuration(0);
+ a5->setEndValue(12);
+ group.addAnimation(a5);
+
+ QCOMPARE(o.property("myProperty").toInt(), 42);
+ QCOMPARE(o.property("myOtherProperty").toInt(), 13);
+ QCOMPARE(o2.property("myProperty").toInt(), 42);
+ QCOMPARE(o2.property("myOtherProperty").toInt(), 13);
+
+
+ group.start();
+
+ QCOMPARE(o.property("myProperty").toInt(), 43);
+ QCOMPARE(o.property("myOtherProperty").toInt(), 13);
+ QCOMPARE(o2.property("myProperty").toInt(), 42);
+ QCOMPARE(o2.property("myOtherProperty").toInt(), 13);
+
+ QTest::qWait(50);
+
+ int o2val = o2.property("myOtherProperty").toInt();
+ QVERIFY(o2val > 13);
+ QVERIFY(o2val < 31);
+ QCOMPARE(o.property("myProperty").toInt(), 43);
+ QCOMPARE(o.property("myOtherProperty").toInt(), 13);
+
+ QTest::qWait(500);
+
+ QCOMPARE(o.property("myProperty").toInt(), 44);
+ QCOMPARE(o2.property("myProperty").toInt(), 42);
+ QCOMPARE(o2.property("myOtherProperty").toInt(), 31);
+ QCOMPARE(a1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroup::Running);
+ QCOMPARE(a5->state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QTest::qWait(500);
+
+ QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(o.property("myProperty").toInt(), 44);
+ QCOMPARE(o.property("myOtherProperty").toInt(), 75);
+ QCOMPARE(o2.property("myProperty").toInt(), 12);
+ QCOMPARE(o2.property("myOtherProperty").toInt(), 31);
+ QCOMPARE(a1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroup::Stopped);
+ QCOMPARE(a5->state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QSequentialAnimationGroup group;
+
+ QObject o;
+ o.setProperty("ole", 42);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ QPropertyAnimation anim1(&o, "ole");
+ anim1.setEndValue(43);
+ anim1.setDuration(100);
+ QVERIFY(!anim1.currentValue().isValid());
+ QCOMPARE(anim1.currentValue().toInt(), 0);
+ QCOMPARE(o.property("ole").toInt(), 42);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QVERIFY(anim2.currentValue().isValid());
+ QCOMPARE(anim2.currentValue().toInt(), 0);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroup::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QSequentialAnimationGroup group;
+
+ TestAnimation anim;
+ anim.setStartValue(0);
+ anim.setEndValue(100);
+ anim.setDuration(200);
+
+ QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroup group;
+
+ QVariantAnimation *anim1 = new TestAnimation;
+ anim1->setStartValue(0);
+ anim1->setEndValue(100);
+ anim1->setDuration(200);
+ group.addAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1->state(), QAnimationGroup::Running);
+
+ QTest::qWait(50);
+ QVERIFY(group.currentTime() > 0);
+
+ delete anim1;
+ QCOMPARE(group.animationCount(), 0);
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.currentTime(), 0); //that's the invariant
+}
+
+void tst_QSequentialAnimationGroup::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(200);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+}
+
+void tst_QSequentialAnimationGroup::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QSequentialAnimationGroup group;
+
+ TestAnimation anim1;
+ anim1.setStartValue(0);
+ anim1.setEndValue(100);
+ anim1.setDuration(200);
+
+ TestAnimation anim2;
+ anim2.setStartValue(0);
+ anim2.setEndValue(100);
+ anim2.setDuration(200);
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(&anim1);
+ group.addAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Running);
+ QCOMPARE(anim2.state(), QAnimationGroup::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QSequentialAnimationGroup group;
+
+ TestAnimation *anim1 = new TestAnimation();
+ anim1->setStartValue(0);
+ anim1->setEndValue(100);
+ anim1->setDuration(200);
+
+ TestAnimation *anim2 = new TestAnimation();
+ anim2->setStartValue(0);
+ anim2->setEndValue(100);
+ anim2->setDuration(200);
+
+ QSignalSpy stateChangedSpy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroup::Stopped);
+
+ group.addAnimation(anim1);
+ group.addAnimation(anim2);
+
+ anim1->start();
+ anim2->start();
+ anim2->pause();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimation::Running)));
+
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroup::Running);
+ QCOMPARE(anim2->state(), QAnimationGroup::Paused);
+
+ group.start();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Stopped
+ << QAbstractAnimation::Running)));
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimation::Running
+ << QAbstractAnimation::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1->state(), QAnimationGroup::Running);
+ QCOMPARE(anim2->state(), QAnimationGroup::Paused);
+
+ QTest::qWait(300);
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroup::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QAnimationGroup::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QAnimationGroup::Running);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::zeroDurationAnimation()
+{
+ QSequentialAnimationGroup group;
+
+ TestAnimation *anim1 = new TestAnimation();
+ anim1->setStartValue(0);
+ anim1->setEndValue(100);
+ anim1->setDuration(0);
+
+ TestAnimation *anim2 = new TestAnimation();
+ anim2->setStartValue(0);
+ anim2->setEndValue(100);
+ anim2->setDuration(100);
+
+ AnimationObject o1;
+ QPropertyAnimation *anim3 = new QPropertyAnimation(&o1, "value");
+ anim3->setEndValue(100);
+ anim3->setDuration(0);
+
+ QSignalSpy stateChangedSpy(anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ group.addAnimation(anim1);
+ group.addAnimation(anim2);
+ group.addAnimation(anim3);
+ group.setIterationCount(2);
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QAnimationGroup::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QAnimationGroup::Stopped);
+
+ QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroup::Running);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+
+ //now let's try to seek to the next loop
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroup::Running);
+ QCOMPARE(anim3->state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(o1.value(), 100); //anim3 should have been run
+}
+
+void tst_QSequentialAnimationGroup::stopUncontrolledAnimations()
+{
+ QSequentialAnimationGroup group;
+
+ AnimationObject o1;
+ UncontrolledAnimation notTimeDriven(&o1, "value");
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever;
+ loopsForever.setStartValue(0);
+ loopsForever.setEndValue(100);
+ loopsForever.setDuration(100);
+ loopsForever.setIterationCount(-1);
+
+ group.addAnimation(&notTimeDriven);
+ group.addAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroup::Stopped);
+}
+
+void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
+{
+ AnimationObject o1;
+
+ //1st case:
+ //first we test a group with one uncontrolled animation
+ QSequentialAnimationGroup group;
+ UncontrolledAnimation notTimeDriven(&o1, "value", &group);
+ QSignalSpy spy(&group, SIGNAL(finished()));
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
+ QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(notTimeDriven.currentTime(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ const int actualDuration = notTimeDriven.currentTime();
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.currentTime(), actualDuration);
+ QCOMPARE(spy.count(), 1);
+
+ //2nd case:
+ // lets make sure the seeking will work again
+ spy.clear();
+ QPropertyAnimation anim(&group);
+ QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+
+ group.setCurrentTime(300);
+ QCOMPARE(group.state(), QAnimationGroup::Stopped);
+ QCOMPARE(notTimeDriven.currentTime(), actualDuration);
+ QCOMPARE(group.currentAnimation(), &anim);
+
+ //3rd case:
+ //now let's add a perfectly defined animation at the end
+ QCOMPARE(animStateChangedSpy.count(), 0);
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
+ QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(notTimeDriven.currentTime(), 0);
+
+ QCOMPARE(animStateChangedSpy.count(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim.state(), QAnimationGroup::Running);
+ QCOMPARE(group.currentAnimation(), &anim);
+ QCOMPARE(animStateChangedSpy.count(), 1);
+ QTest::qWait(300); //wait for the end of anim
+
+ QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim.currentTime(), anim.duration());
+
+ //we should simply be at the end
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(animStateChangedSpy.count(), 2);
+ QCOMPARE(group.currentTime(), notTimeDriven.currentTime() + anim.currentTime());
+}
+
+void tst_QSequentialAnimationGroup::addRemoveAnimation()
+{
+ //this test is specific to the sequential animation group
+ QSequentialAnimationGroup group;
+
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.currentTime(), 0);
+ QVariantAnimation *anim1 = new QPropertyAnimation;
+ group.addAnimation(anim1);
+ QCOMPARE(group.duration(), 250);
+ QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's append an animation
+ QVariantAnimation *anim2 = new QPropertyAnimation;
+ group.addAnimation(anim2);
+ QCOMPARE(group.duration(), 500);
+ QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's prepend an animation
+ QVariantAnimation *anim0 = new QPropertyAnimation;
+ group.insertAnimationAt(0, anim0);
+ QCOMPARE(group.duration(), 750);
+ QCOMPARE(group.currentTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
+
+ group.setCurrentTime(300); //anim0 | anim1 | anim2
+ QCOMPARE(group.currentTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentTime(), 50);
+
+ group.removeAnimation(anim0); //anim1 | anim2
+ QCOMPARE(group.currentTime(), 50);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentTime(), 50);
+
+ group.setCurrentTime(0);
+ group.insertAnimationAt(0, anim0); //anim0 | anim1 | anim2
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentTime(), 50);
+
+ group.removeAnimation(anim1); //anim0 | anim2
+ QCOMPARE(group.currentTime(), 250);
+ QCOMPARE(group.currentAnimation(), anim2);
+ QCOMPARE(anim0->currentTime(), 250);
+}
+
+void tst_QSequentialAnimationGroup::currentAnimation()
+{
+ QSequentialAnimationGroup group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ QPropertyAnimation anim;
+ anim.setDuration(0);
+ group.addAnimation(&anim);
+ QCOMPARE(group.currentAnimation(), &anim);
+}
+
+void tst_QSequentialAnimationGroup::currentAnimationWithZeroDuration()
+{
+ QSequentialAnimationGroup group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ QPropertyAnimation zero1;
+ zero1.setDuration(0);
+ QPropertyAnimation zero2;
+ zero2.setDuration(0);
+
+ QPropertyAnimation anim;
+
+ QPropertyAnimation zero3;
+ zero3.setDuration(0);
+ QPropertyAnimation zero4;
+ zero4.setDuration(0);
+
+
+ group.addAnimation(&zero1);
+ group.addAnimation(&zero2);
+ group.addAnimation(&anim);
+ group.addAnimation(&zero3);
+ group.addAnimation(&zero4);
+
+ QCOMPARE(group.currentAnimation(), &zero1);
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), &anim);
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), &zero4);
+
+ group.setDirection(QAbstractAnimation::Backward);
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), &zero1);
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), &anim);
+}
+
+void tst_QSequentialAnimationGroup::insertAnimation()
+{
+ QSequentialAnimationGroup group;
+ group.setIterationCount(2);
+ QPropertyAnimation *anim = new QPropertyAnimation(&group);
+ QCOMPARE(group.duration(), anim->duration());
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentIteration(), 1);
+
+ //this will crash if the sequential group calls duration on the created animation
+ new QPropertyAnimation(&group);
+}
+
+
+class SequentialAnimationGroup : public QSequentialAnimationGroup
+{
+ Q_OBJECT
+public slots:
+ void clearAnimations()
+ {
+ QSequentialAnimationGroup::clearAnimations();
+ }
+
+ void refill()
+ {
+ stop();
+ clearAnimations();
+ new QPropertyAnimation(this);
+ start();
+ }
+
+};
+
+
+void tst_QSequentialAnimationGroup::clearAnimations()
+{
+ SequentialAnimationGroup group;
+ QPointer<QAbstractAnimation> anim1 = new QPropertyAnimation(&group);
+ group.connect(anim1, SIGNAL(finished()), SLOT(clearAnimations()));
+ new QPropertyAnimation(&group);
+ QCOMPARE(group.animationCount(), 2);
+
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QCOMPARE(group.animationCount(), 0);
+ QCOMPARE(group.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(group.currentTime(), 0);
+
+ anim1 = new QPropertyAnimation(&group);
+ group.connect(anim1, SIGNAL(finished()), SLOT(refill()));
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QVERIFY(anim1 == 0); //anim1 should have been deleted
+ QCOMPARE(group.state(), QAbstractAnimation::Running);
+}
+
+QTEST_MAIN(tst_QSequentialAnimationGroup)
+#include "tst_qsequentialanimationgroup.moc"
diff --git a/tests/auto/qstate/qstate.pro b/tests/auto/qstate/qstate.pro
new file mode 100644
index 0000000..9131fa8
--- /dev/null
+++ b/tests/auto/qstate/qstate.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core
+SOURCES += tst_qstate.cpp
+
+
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
new file mode 100644
index 0000000..c4a0050
--- /dev/null
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include "qstate.h"
+#include "qstatemachine.h"
+#include "qtransition.h"
+#include "qsignaltransition.h"
+#include "qstateaction.h"
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QState : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QState();
+ virtual ~tst_QState();
+
+private slots:
+#if 0
+ void test();
+#endif
+ void setPropertyOnEntry();
+ void setPropertyOnEntryTwice();
+ void setPropertyOnExit();
+ void setPropertyOnExitTwice();
+ void historyInitialState();
+ void addEntryAction();
+};
+
+tst_QState::tst_QState()
+{
+}
+
+tst_QState::~tst_QState()
+{
+}
+
+#if 0
+void tst_QState::test()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+
+ QCOMPARE(s1->machine(), &machine);
+ QCOMPARE(s1->parentState(), machine.rootState());
+ QCOMPARE(s1->initialState(), (QState*)0);
+ QVERIFY(s1->childStates().isEmpty());
+ QVERIFY(s1->transitions().isEmpty());
+
+ QCOMPARE(s1->isFinal(), false);
+ s1->setFinal(true);
+ QCOMPARE(s1->isFinal(), true);
+ s1->setFinal(false);
+ QCOMPARE(s1->isFinal(), false);
+
+ QCOMPARE(s1->isParallel(), false);
+ s1->setParallel(true);
+ QCOMPARE(s1->isParallel(), true);
+ s1->setParallel(false);
+ QCOMPARE(s1->isParallel(), false);
+
+ QCOMPARE(s1->isAtomic(), true);
+ QCOMPARE(s1->isCompound(), false);
+ QCOMPARE(s1->isComplex(), false);
+
+ QState *s11 = new QState(s1);
+ QCOMPARE(s11->parentState(), s1);
+ QCOMPARE(s11->isAtomic(), true);
+ QCOMPARE(s11->isCompound(), false);
+ QCOMPARE(s11->isComplex(), false);
+ QCOMPARE(s11->machine(), s1->machine());
+ QVERIFY(s11->isDescendantOf(s1));
+
+ QCOMPARE(s1->initialState(), (QState*)0);
+ QCOMPARE(s1->childStates().size(), 1);
+ QCOMPARE(s1->childStates().at(0), s11);
+
+ QCOMPARE(s1->isAtomic(), false);
+ QCOMPARE(s1->isCompound(), true);
+ QCOMPARE(s1->isComplex(), true);
+
+ s1->setParallel(true);
+ QCOMPARE(s1->isAtomic(), false);
+ QCOMPARE(s1->isCompound(), false);
+ QCOMPARE(s1->isComplex(), true);
+
+ QState *s12 = new QState(s1);
+ QCOMPARE(s12->parentState(), s1);
+ QCOMPARE(s12->isAtomic(), true);
+ QCOMPARE(s12->isCompound(), false);
+ QCOMPARE(s12->isComplex(), false);
+ QCOMPARE(s12->machine(), s1->machine());
+ QVERIFY(s12->isDescendantOf(s1));
+ QVERIFY(!s12->isDescendantOf(s11));
+
+ QCOMPARE(s1->initialState(), (QState*)0);
+ QCOMPARE(s1->childStates().size(), 2);
+ QCOMPARE(s1->childStates().at(0), s11);
+ QCOMPARE(s1->childStates().at(1), s12);
+
+ QCOMPARE(s1->isAtomic(), false);
+ QCOMPARE(s1->isCompound(), false);
+ QCOMPARE(s1->isComplex(), true);
+
+ s1->setParallel(false);
+ QCOMPARE(s1->isAtomic(), false);
+ QCOMPARE(s1->isCompound(), true);
+ QCOMPARE(s1->isComplex(), true);
+
+ s1->setInitialState(s11);
+ QCOMPARE(s1->initialState(), s11);
+
+ s1->setInitialState(0);
+ QCOMPARE(s1->initialState(), (QState*)0);
+
+ s1->setInitialState(s12);
+ QCOMPARE(s1->initialState(), s12);
+
+ QState *s13 = new QState();
+ s1->setInitialState(s13);
+ QCOMPARE(s13->parentState(), s1);
+ QCOMPARE(s1->childStates().size(), 3);
+ QCOMPARE(s1->childStates().at(0), s11);
+ QCOMPARE(s1->childStates().at(1), s12);
+ QCOMPARE(s1->childStates().at(2), s13);
+ QVERIFY(s13->isDescendantOf(s1));
+
+ QVERIFY(s12->childStates().isEmpty());
+
+ QState *s121 = new QState(s12);
+ QCOMPARE(s121->parentState(), s12);
+ QCOMPARE(s121->isAtomic(), true);
+ QCOMPARE(s121->isCompound(), false);
+ QCOMPARE(s121->isComplex(), false);
+ QCOMPARE(s121->machine(), s12->machine());
+ QVERIFY(s121->isDescendantOf(s12));
+ QVERIFY(s121->isDescendantOf(s1));
+ QVERIFY(!s121->isDescendantOf(s11));
+
+ QCOMPARE(s12->childStates().size(), 1);
+ QCOMPARE(s12->childStates().at(0), (QState*)s121);
+
+ QCOMPARE(s1->childStates().size(), 3);
+ QCOMPARE(s1->childStates().at(0), s11);
+ QCOMPARE(s1->childStates().at(1), s12);
+ QCOMPARE(s1->childStates().at(2), s13);
+
+ s11->addTransition(s12);
+ QCOMPARE(s11->transitions().size(), 1);
+ QCOMPARE(s11->transitions().at(0)->sourceState(), s11);
+ QCOMPARE(s11->transitions().at(0)->targetStates().size(), 1);
+ QCOMPARE(s11->transitions().at(0)->targetStates().at(0), s12);
+ QCOMPARE(s11->transitions().at(0)->eventType(), QEvent::None);
+
+ QState *s14 = new QState();
+ s12->addTransition(QList<QState*>() << s13 << s14);
+ QCOMPARE(s12->transitions().size(), 1);
+ QCOMPARE(s12->transitions().at(0)->sourceState(), s12);
+ QCOMPARE(s12->transitions().at(0)->targetStates().size(), 2);
+ QCOMPARE(s12->transitions().at(0)->targetStates().at(0), s13);
+ QCOMPARE(s12->transitions().at(0)->targetStates().at(1), s14);
+ QCOMPARE(s12->transitions().at(0)->eventType(), QEvent::None);
+
+ s13->addTransition(this, SIGNAL(destroyed()), s14);
+ QCOMPARE(s13->transitions().size(), 1);
+ QCOMPARE(s13->transitions().at(0)->sourceState(), s13);
+ QCOMPARE(s13->transitions().at(0)->targetStates().size(), 1);
+ QCOMPARE(s13->transitions().at(0)->targetStates().at(0), s14);
+ QCOMPARE(s13->transitions().at(0)->eventType(), QEvent::Signal);
+ QVERIFY(qobject_cast<QSignalTransition*>(s13->transitions().at(0)) != 0);
+
+ delete s13->transitions().at(0);
+ QCOMPARE(s13->transitions().size(), 0);
+
+ s12->addTransition(this, SIGNAL(destroyed()), s11);
+ QCOMPARE(s12->transitions().size(), 2);
+}
+#endif
+
+void tst_QState::addEntryAction()
+{
+ QStateMachine sm;
+ QState *s0 = new QState(sm.rootState());
+ s0->addEntryAction(new QStateSetPropertyAction(this, "objectName", "commandTest"));
+ sm.setInitialState(s0);
+
+ sm.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(this->objectName(), QString::fromLatin1("commandTest"));
+}
+
+void tst_QState::setPropertyOnEntry()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 10);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnEntry(object, "fooBar", 20);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 20);
+}
+
+void tst_QState::setPropertyOnEntryTwice()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 10);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnEntry(object, "fooBar", 20);
+ s1->setPropertyOnEntry(object, "fooBar", 30);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 30);
+}
+
+void tst_QState::setPropertyOnExit()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 10);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnExit(object, "fooBar", 20);
+
+ QState *s2 = new QState(machine.rootState());
+ s1->addTransition(new QTransition(QEvent::User), s2);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 10);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 20);
+}
+
+void tst_QState::setPropertyOnExitTwice()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 10);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnExit(object, "fooBar", 20);
+ s1->setPropertyOnExit(object, "fooBar", 30);
+
+ QState *s2 = new QState(machine.rootState());
+ s1->addTransition(new QTransition(QEvent::User), s2);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 10);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("fooBar").toInt(), 30);
+}
+
+void tst_QState::historyInitialState()
+{
+ QStateMachine machine;
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ QHistoryState *h1 = s2->addHistoryState();
+
+ s2->setInitialState(h1);
+
+ QState *s3 = new QState(s2);
+ h1->setDefaultState(s3);
+
+ QState *s4 = new QState(s2);
+
+ s1->addTransition(new QTransition(QEvent::User), s2);
+ s2->addTransition(new QTransition(QEvent::User), s1);
+ s3->addTransition(new QTransition(QEvent::Type(QEvent::User+1)), s4);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s3));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s3));
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User+1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s4));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s4));
+}
+
+
+QTEST_MAIN(tst_QState)
+#include "tst_qstate.moc"
diff --git a/tests/auto/qstatemachine/qstatemachine.pro b/tests/auto/qstatemachine/qstatemachine.pro
new file mode 100644
index 0000000..e5b32b5
--- /dev/null
+++ b/tests/auto/qstatemachine/qstatemachine.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qstatemachine.cpp
+
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
new file mode 100644
index 0000000..729581e
--- /dev/null
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -0,0 +1,2177 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+#include <QtGui/QPushButton>
+
+#include "qstatemachine.h"
+#include "qstate.h"
+#include "qtransition.h"
+#include "qhistorystate.h"
+#include "qkeyeventtransition.h"
+#include "qmouseeventtransition.h"
+#include "private/qstatemachine_p.h"
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+static int globalTick;
+
+class tst_QStateMachine : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QStateMachine();
+ virtual ~tst_QStateMachine();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void rootState();
+ void addAndRemoveState();
+ void stateEntryAndExit();
+ void postEvent();
+ void stateFinished();
+ void parallelStates();
+ void allSourceToTargetConfigurations();
+ void signalTransitions();
+ void eventTransitions();
+ void historyStates();
+ void stateActions();
+ void transitionActions();
+ void transitionToRootState();
+ void transitionEntersParent();
+
+ void defaultErrorState();
+ void customGlobalErrorState();
+ void customLocalErrorStateInBrokenState();
+ void customLocalErrorStateInOtherState();
+ void customLocalErrorStateInParentOfBrokenState();
+ void customLocalErrorStateOverridesParent();
+ void errorStateHasChildren();
+ void errorStateHasErrors();
+ void errorStateIsRootState();
+ void errorStateEntersParentFirst();
+ void customErrorStateIsNull();
+ void clearError();
+ void historyStateHasNowhereToGo();
+ void brokenStateIsNeverEntered();
+ void customErrorStateNotInGraph();
+ void transitionToStateNotInGraph();
+ void restoreProperties();
+ void defaultGlobalRestorePolicy();
+ void globalRestorePolicySetToRestore();
+ void globalRestorePolicySetToDoNotRestore();
+ void restorePolicyNotInherited();
+ void mixedRestoreProperties();
+ void setRestorePolicyToDoNotRestore();
+ void setGlobalRestorePolicyToGlobalRestore();
+ void restorePolicyOnChildState();
+ void addAnimatedTransition();
+ void transitionWithParent();
+};
+
+tst_QStateMachine::tst_QStateMachine()
+{
+}
+
+tst_QStateMachine::~tst_QStateMachine()
+{
+}
+
+class TestState : public QState
+{
+public:
+ enum Event {
+ Entry,
+ Exit
+ };
+ TestState(QState *parent)
+ : QState(parent) {}
+ QList<QPair<int, Event> > events;
+protected:
+ virtual void onEntry() {
+ events.append(qMakePair(globalTick++, Entry));
+ }
+ virtual void onExit() {
+ events.append(qMakePair(globalTick++, Exit));
+ }
+};
+
+class TestTransition : public QAbstractTransition
+{
+public:
+ TestTransition(QAbstractState *target)
+ : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ QList<int> triggers;
+protected:
+ virtual bool eventTest(QEvent *) const {
+ return true;
+ }
+ virtual void onTransition() {
+ triggers.append(globalTick++);
+ }
+};
+
+static QtMsgType s_msgType;
+static QByteArray s_msg;
+static bool s_countWarnings;
+static QtMsgHandler s_oldHandler;
+
+static void defaultErrorStateTestMessageHandler(QtMsgType type, const char *msg)
+{
+ s_msgType = type;
+ s_msg = msg;
+
+ if (s_countWarnings)
+ s_oldHandler(type, msg);
+}
+
+void tst_QStateMachine::init()
+{
+ s_msg = QByteArray();
+ s_msgType = QtDebugMsg;
+ s_countWarnings = true;
+
+ s_oldHandler = qInstallMsgHandler(defaultErrorStateTestMessageHandler);
+}
+
+void tst_QStateMachine::cleanup()
+{
+ qInstallMsgHandler(s_oldHandler);
+}
+
+class EventTransition : public QTransition
+{
+public:
+ EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
+ : QTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+protected:
+ virtual bool eventTest(QEvent *e) const {
+ return (e->type() == m_type);
+ }
+private:
+ QEvent::Type m_type;
+};
+
+void tst_QStateMachine::transitionToRootState()
+{
+ QStateMachine machine;
+
+ QState *initialState = new QState();
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ initialState->addTransition(new EventTransition(QEvent::User, machine.rootState()));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(initialState));
+ QVERIFY(machine.configuration().contains(machine.rootState()));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(initialState));
+ QVERIFY(machine.configuration().contains(machine.rootState()));
+}
+
+void tst_QStateMachine::transitionEntersParent()
+{
+ QStateMachine machine;
+
+ QObject *entryController = new QObject(&machine);
+ entryController->setObjectName("entryController");
+ entryController->setProperty("greatGrandParentEntered", false);
+ entryController->setProperty("grandParentEntered", false);
+ entryController->setProperty("parentEntered", false);
+ entryController->setProperty("stateEntered", false);
+
+ QState *greatGrandParent = new QState();
+ greatGrandParent->setObjectName("grandParent");
+ greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ machine.addState(greatGrandParent);
+ machine.setInitialState(greatGrandParent);
+
+ QState *grandParent = new QState(greatGrandParent);
+ grandParent->setObjectName("grandParent");
+ grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+
+ QState *parent = new QState(grandParent);
+ parent->setObjectName("parent");
+ parent->setPropertyOnEntry(entryController, "parentEntered", true);
+
+ QState *state = new QState(parent);
+ state->setObjectName("state");
+ state->setPropertyOnEntry(entryController, "stateEntered", true);
+
+ QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
+ initialStateOfGreatGrandParent->setObjectName("initialStateOfGreatGrandParent");
+ greatGrandParent->setInitialState(initialStateOfGreatGrandParent);
+
+ initialStateOfGreatGrandParent->addTransition(new EventTransition(QEvent::User, state));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(entryController->property("greatGrandParentEntered").toBool(), true);
+ QCOMPARE(entryController->property("grandParentEntered").toBool(), false);
+ QCOMPARE(entryController->property("parentEntered").toBool(), false);
+ QCOMPARE(entryController->property("stateEntered").toBool(), false);
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(greatGrandParent));
+ QVERIFY(machine.configuration().contains(initialStateOfGreatGrandParent));
+
+ entryController->setProperty("greatGrandParentEntered", false);
+ entryController->setProperty("grandParentEntered", false);
+ entryController->setProperty("parentEntered", false);
+ entryController->setProperty("stateEntered", false);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(entryController->property("greatGrandParentEntered").toBool(), false);
+ QCOMPARE(entryController->property("grandParentEntered").toBool(), true);
+ QCOMPARE(entryController->property("parentEntered").toBool(), true);
+ QCOMPARE(entryController->property("stateEntered").toBool(), true);
+ QCOMPARE(machine.configuration().count(), 4);
+ QVERIFY(machine.configuration().contains(greatGrandParent));
+ QVERIFY(machine.configuration().contains(grandParent));
+ QVERIFY(machine.configuration().contains(parent));
+ QVERIFY(machine.configuration().contains(state));
+}
+
+void tst_QStateMachine::defaultErrorState()
+{
+ s_countWarnings = false; // we expect warnings here
+
+ QStateMachine machine;
+ QVERIFY(machine.errorState() != 0);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("MyInitialState");
+
+ machine.addState(brokenState);
+ machine.setInitialState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ // initialState has no initial state
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(s_msgType, QtWarningMsg);
+ QCOMPARE(QString::fromLatin1(s_msg.data()),
+ QString::fromLatin1("Unrecoverable error detected in running state machine: Missing initial state in compound state 'MyInitialState'"));
+
+ QCOMPARE(machine.error(), QStateMachine::NoInitialStateError);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'MyInitialState'"));
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(machine.errorState()));
+}
+
+class CustomErrorState: public QState
+{
+public:
+ CustomErrorState(QStateMachine *machine, QState *parent = 0)
+ : QState(parent), error(QStateMachine::NoError), m_machine(machine)
+ {
+ }
+
+ void onEntry()
+ {
+ error = m_machine->error();
+ errorString = m_machine->errorString();
+ }
+
+ QStateMachine::Error error;
+ QString errorString;
+
+private:
+ QStateMachine *m_machine;
+};
+
+void tst_QStateMachine::customGlobalErrorState()
+{
+ QStateMachine machine;
+
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ customErrorState->setObjectName("customErrorState");
+ machine.addState(customErrorState);
+ machine.setErrorState(customErrorState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+ machine.addState(brokenState);
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.errorState(), customErrorState);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(initialState));
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(initialState));
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(customErrorState));
+ QCOMPARE(customErrorState->error, QStateMachine::NoInitialStateError);
+ QCOMPARE(customErrorState->errorString, QString::fromLatin1("Missing initial state in compound state 'brokenState'"));
+ QCOMPARE(machine.error(), QStateMachine::NoInitialStateError);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'brokenState'"));
+ QVERIFY(s_msg.isEmpty());
+ QCOMPARE(s_msgType, QtDebugMsg);
+}
+
+void tst_QStateMachine::customLocalErrorStateInBrokenState()
+{
+ QStateMachine machine;
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ machine.addState(customErrorState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+ machine.addState(brokenState);
+ brokenState->setErrorState(customErrorState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(customErrorState));
+ QCOMPARE(customErrorState->error, QStateMachine::NoInitialStateError);
+ QVERIFY(s_msg.isEmpty());
+}
+
+void tst_QStateMachine::customLocalErrorStateInOtherState()
+{
+ s_countWarnings = false;
+
+ QStateMachine machine;
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ machine.addState(customErrorState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ initialState->setErrorState(customErrorState);
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+
+ machine.addState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(machine.errorState()));
+ QCOMPARE(s_msgType, QtWarningMsg);
+}
+
+void tst_QStateMachine::customLocalErrorStateInParentOfBrokenState()
+{
+ QStateMachine machine;
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ machine.addState(customErrorState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *parentOfBrokenState = new QState();
+ machine.addState(parentOfBrokenState);
+ parentOfBrokenState->setObjectName("parentOfBrokenState");
+ parentOfBrokenState->setErrorState(customErrorState);
+
+
+ QState *brokenState = new QState(parentOfBrokenState);
+ brokenState->setObjectName("brokenState");
+ parentOfBrokenState->setInitialState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(customErrorState));
+ QVERIFY(s_msg.isEmpty());
+}
+
+void tst_QStateMachine::customLocalErrorStateOverridesParent()
+{
+ QStateMachine machine;
+ CustomErrorState *customErrorStateForParent = new CustomErrorState(&machine);
+ machine.addState(customErrorStateForParent);
+
+ CustomErrorState *customErrorStateForBrokenState = new CustomErrorState(&machine);
+ machine.addState(customErrorStateForBrokenState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *parentOfBrokenState = new QState();
+ machine.addState(parentOfBrokenState);
+ parentOfBrokenState->setObjectName("parentOfBrokenState");
+ parentOfBrokenState->setErrorState(customErrorStateForParent);
+
+ QState *brokenState = new QState(parentOfBrokenState);
+ brokenState->setObjectName("brokenState");
+ brokenState->setErrorState(customErrorStateForBrokenState);
+ parentOfBrokenState->setInitialState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(customErrorStateForBrokenState));
+ QCOMPARE(customErrorStateForBrokenState->error, QStateMachine::NoInitialStateError);
+ QCOMPARE(customErrorStateForParent->error, QStateMachine::NoError);
+ QVERIFY(s_msg.isEmpty());
+}
+
+void tst_QStateMachine::errorStateHasChildren()
+{
+ QStateMachine machine;
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ customErrorState->setObjectName("customErrorState");
+ machine.addState(customErrorState);
+
+ machine.setErrorState(customErrorState);
+
+ QState *childOfErrorState = new QState(customErrorState);
+ childOfErrorState->setObjectName("childOfErrorState");
+ customErrorState->setInitialState(childOfErrorState);
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+ machine.addState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(customErrorState));
+ QVERIFY(machine.configuration().contains(childOfErrorState));
+ QVERIFY(s_msg.isEmpty());
+}
+
+
+void tst_QStateMachine::errorStateHasErrors()
+{
+ s_countWarnings = false;
+
+ QStateMachine machine;
+ CustomErrorState *customErrorState = new CustomErrorState(&machine);
+ customErrorState->setObjectName("customErrorState");
+ machine.addState(customErrorState);
+
+ QAbstractState *oldErrorState = machine.errorState();
+ machine.setErrorState(customErrorState);
+
+ QState *childOfErrorState = new QState(customErrorState);
+ childOfErrorState->setObjectName("childOfErrorState");
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+ machine.addState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(oldErrorState)); // Fall back to default
+ QCOMPARE(machine.error(), QStateMachine::NoInitialStateError);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'customErrorState'"));
+
+ QCOMPARE(s_msgType, QtWarningMsg);
+}
+
+void tst_QStateMachine::errorStateIsRootState()
+{
+ QStateMachine machine;
+ machine.setErrorState(machine.rootState());
+
+ QState *initialState = new QState();
+ initialState->setObjectName("initialState");
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ brokenState->setObjectName("brokenState");
+ machine.addState(brokenState);
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)));
+ QCoreApplication::processEvents();
+
+ QEXPECT_FAIL("", "Covered by transitionToRootState test. Remove this when that test passes", Continue);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(initialState));
+}
+
+void tst_QStateMachine::errorStateEntersParentFirst()
+{
+ QStateMachine machine;
+
+ QObject *entryController = new QObject(&machine);
+ entryController->setObjectName("entryController");
+ entryController->setProperty("greatGrandParentEntered", false);
+ entryController->setProperty("grandParentEntered", false);
+ entryController->setProperty("parentEntered", false);
+ entryController->setProperty("errorStateEntered", false);
+
+ QState *greatGrandParent = new QState();
+ greatGrandParent->setObjectName("greatGrandParent");
+ greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ machine.addState(greatGrandParent);
+ machine.setInitialState(greatGrandParent);
+
+ QState *grandParent = new QState(greatGrandParent);
+ grandParent->setObjectName("grandParent");
+ grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+
+ QState *parent = new QState(grandParent);
+ parent->setObjectName("parent");
+ parent->setPropertyOnEntry(entryController, "parentEntered", true);
+
+ QState *errorState = new QState(parent);
+ errorState->setObjectName("errorState");
+ errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ machine.setErrorState(errorState);
+
+ QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
+ initialStateOfGreatGrandParent->setObjectName("initialStateOfGreatGrandParent");
+ greatGrandParent->setInitialState(initialStateOfGreatGrandParent);
+
+ QState *brokenState = new QState(greatGrandParent);
+ brokenState->setObjectName("brokenState");
+
+ QState *childState = new QState(brokenState);
+ childState->setObjectName("childState");
+
+ initialStateOfGreatGrandParent->addTransition(new EventTransition(QEvent::User, brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(entryController->property("greatGrandParentEntered").toBool(), true);
+ QCOMPARE(entryController->property("grandParentEntered").toBool(), false);
+ QCOMPARE(entryController->property("parentEntered").toBool(), false);
+ QCOMPARE(entryController->property("errorStateEntered").toBool(), false);
+ QCOMPARE(machine.configuration().count(), 2);
+ QVERIFY(machine.configuration().contains(greatGrandParent));
+ QVERIFY(machine.configuration().contains(initialStateOfGreatGrandParent));
+
+ entryController->setProperty("greatGrandParentEntered", false);
+ entryController->setProperty("grandParentEntered", false);
+ entryController->setProperty("parentEntered", false);
+ entryController->setProperty("errorStateEntered", false);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(entryController->property("greatGrandParentEntered").toBool(), false);
+ QCOMPARE(entryController->property("grandParentEntered").toBool(), true);
+ QCOMPARE(entryController->property("parentEntered").toBool(), true);
+ QCOMPARE(entryController->property("errorStateEntered").toBool(), true);
+ QCOMPARE(machine.configuration().count(), 4);
+ QVERIFY(machine.configuration().contains(greatGrandParent));
+ QVERIFY(machine.configuration().contains(grandParent));
+ QVERIFY(machine.configuration().contains(parent));
+ QVERIFY(machine.configuration().contains(errorState));
+}
+
+void tst_QStateMachine::customErrorStateIsNull()
+{
+ s_countWarnings = false;
+
+ QStateMachine machine;
+ QAbstractState *oldErrorState = machine.errorState();
+ machine.rootState()->setErrorState(0);
+
+ QState *initialState = new QState();
+ machine.addState(initialState);
+ machine.setInitialState(initialState);
+
+ QState *brokenState = new QState();
+ machine.addState(brokenState);
+
+ new QState(brokenState);
+ initialState->addTransition(new EventTransition(QEvent::User, brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.errorState(), reinterpret_cast<void *>(0));
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(oldErrorState));
+ QCOMPARE(s_msgType, QtWarningMsg);
+}
+
+void tst_QStateMachine::clearError()
+{
+ QStateMachine machine;
+ machine.setErrorState(new QState(machine.rootState())); // avoid warnings
+
+ QState *brokenState = new QState(machine.rootState());
+ brokenState->setObjectName("brokenState");
+ machine.setInitialState(brokenState);
+ new QState(brokenState);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.error(), QStateMachine::NoInitialStateError);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'brokenState'"));
+
+ machine.clearError();
+
+ QCOMPARE(machine.error(), QStateMachine::NoError);
+ QVERIFY(machine.errorString().isEmpty());
+}
+
+void tst_QStateMachine::historyStateHasNowhereToGo()
+{
+ QStateMachine machine;
+
+ QState *initialState = new QState(machine.rootState());
+ machine.setInitialState(initialState);
+ machine.setErrorState(new QState(machine.rootState())); // avoid warnings
+
+ QState *brokenState = new QState(machine.rootState());
+ brokenState->setObjectName("brokenState");
+ brokenState->setInitialState(new QState(brokenState));
+
+ QHistoryState *historyState = brokenState->addHistoryState();
+ historyState->setObjectName("historyState");
+ initialState->addTransition(new EventTransition(QEvent::User, historyState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(machine.errorState()));
+ QCOMPARE(machine.error(), QStateMachine::NoDefaultStateInHistoryState);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing transition from history state 'historyState'"));
+}
+
+void tst_QStateMachine::brokenStateIsNeverEntered()
+{
+ QStateMachine machine;
+
+ QObject *entryController = new QObject();
+ entryController->setProperty("brokenStateEntered", false);
+ entryController->setProperty("childStateEntered", false);
+ entryController->setProperty("errorStateEntered", false);
+
+ QState *initialState = new QState(machine.rootState());
+ machine.setInitialState(initialState);
+
+ QState *errorState = new QState(machine.rootState());
+ errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ machine.setErrorState(errorState);
+
+ QState *brokenState = new QState(machine.rootState());
+ brokenState->setPropertyOnEntry(entryController, "brokenStateEntered", true);
+ brokenState->setObjectName("brokenState");
+
+ QState *childState = new QState(brokenState);
+ childState->setPropertyOnEntry(entryController, "childStateEntered", true);
+
+ initialState->addTransition(new EventTransition(QEvent::User, brokenState));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(entryController->property("errorStateEntered").toBool(), true);
+ QCOMPARE(entryController->property("brokenStateEntered").toBool(), false);
+ QCOMPARE(entryController->property("childStateEntered").toBool(), false);
+}
+
+void tst_QStateMachine::transitionToStateNotInGraph()
+{
+ QSKIP("Hangs", SkipAll);
+
+ s_countWarnings = false;
+
+ QStateMachine machine;
+
+ QState *initialState = new QState(machine.rootState());
+ initialState->setObjectName("initialState");
+ machine.setInitialState(initialState);
+
+ QState *independentState = new QState();
+ initialState->addTransition(independentState);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(initialState));
+}
+
+void tst_QStateMachine::customErrorStateNotInGraph()
+{
+ s_countWarnings = false;
+
+ QStateMachine machine;
+
+ QState *errorState = new QState();
+ errorState->setObjectName("errorState");
+ machine.setErrorState(errorState);
+ QVERIFY(errorState != machine.errorState());
+
+ QState *initialBrokenState = new QState(machine.rootState());
+ initialBrokenState->setObjectName("initialBrokenState");
+ machine.setInitialState(initialBrokenState);
+ new QState(initialBrokenState);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(machine.errorState()));
+}
+
+void tst_QStateMachine::restoreProperties()
+{
+ QObject *object = new QObject();
+ object->setProperty("a", 1);
+ object->setProperty("b", 2);
+
+ QStateMachine machine;
+
+ QState *S1 = new QState();
+ S1->setObjectName("S1");
+ S1->setPropertyOnEntry(object, "a", 3);
+ S1->setRestorePolicy(QState::RestoreProperties);
+ machine.addState(S1);
+
+ QState *S2 = new QState();
+ S2->setObjectName("S2");
+ S2->setPropertyOnEntry(object, "b", 5);
+ S2->setRestorePolicy(QState::RestoreProperties);
+ machine.addState(S2);
+
+ QState *S3 = new QState();
+ S3->setObjectName("S3");
+ S3->setRestorePolicy(QState::RestoreProperties);
+ machine.addState(S3);
+
+ QFinalState *S4 = new QFinalState();
+ machine.addState(S4);
+
+ S1->addTransition(new EventTransition(QEvent::User, S2));
+ S2->addTransition(new EventTransition(QEvent::User, S3));
+ S3->addTransition(S4);
+
+ machine.setInitialState(S1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 3);
+ QCOMPARE(object->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 1);
+ QCOMPARE(object->property("b").toInt(), 5);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 1);
+ QCOMPARE(object->property("b").toInt(), 2);
+}
+
+void tst_QStateMachine::rootState()
+{
+ QStateMachine machine;
+ QVERIFY(machine.rootState() != 0);
+ QVERIFY(qobject_cast<QState*>(machine.rootState()) != 0);
+ QCOMPARE(qobject_cast<QState*>(machine.rootState())->parentState(), (QState*)0);
+ QCOMPARE(machine.rootState()->parent(), (QObject*)&machine);
+
+ QState *s1 = new QState(machine.rootState());
+ QCOMPARE(s1->parentState(), machine.rootState());
+
+ QState *s2 = new QState();
+ s2->setParent(&machine);
+ QCOMPARE(s2->parentState(), machine.rootState());
+}
+
+void tst_QStateMachine::addAndRemoveState()
+{
+ QStateMachine machine;
+ QCOMPARE(machine.states().size(), 1); // the error state
+ QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: cannot add null state");
+ machine.addState(0);
+
+ QState *s1 = new QState();
+ QCOMPARE(s1->parentState(), (QState*)0);
+ machine.addState(s1);
+ QCOMPARE(s1->parentState(), machine.rootState());
+ QCOMPARE(machine.states().size(), 2);
+ QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(machine.states().at(1), (QAbstractState*)s1);
+
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: state has already been added to this machine");
+ machine.addState(s1);
+
+ QState *s2 = new QState();
+ QCOMPARE(s2->parentState(), (QState*)0);
+ machine.addState(s2);
+ QCOMPARE(s2->parentState(), machine.rootState());
+ QCOMPARE(machine.states().size(), 3);
+ QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(machine.states().at(1), (QAbstractState*)s1);
+ QCOMPARE(machine.states().at(2), (QAbstractState*)s2);
+
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: state has already been added to this machine");
+ machine.addState(s2);
+
+ machine.removeState(s1);
+ QCOMPARE(s1->parentState(), (QState*)0);
+ QCOMPARE(machine.states().size(), 2);
+ QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(machine.states().at(1), (QAbstractState*)s2);
+
+ machine.removeState(s2);
+ QCOMPARE(s2->parentState(), (QState*)0);
+ QCOMPARE(machine.states().size(), 1);
+ QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::removeState: cannot remove null state");
+ machine.removeState(0);
+
+ delete s1;
+ delete s2;
+ // ### how to deal with this?
+ // machine.removeState(machine.errorState());
+}
+
+void tst_QStateMachine::stateEntryAndExit()
+{
+ // Two top-level states
+ {
+ QStateMachine machine;
+
+ TestState *s1 = new TestState(machine.rootState());
+ TestState *s2 = new TestState(machine.rootState());
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ TestTransition *t = new TestTransition(s2);
+ s1->addTransition(t);
+ s2->addTransition(s3);
+
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s1);
+ QVERIFY(machine.configuration().isEmpty());
+ globalTick = 0;
+ machine.start();
+
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s3));
+
+ // s1 is entered
+ QCOMPARE(s1->events.count(), 2);
+ QCOMPARE(s1->events.at(0).first, 0);
+ QCOMPARE(s1->events.at(0).second, TestState::Entry);
+ // s1 is exited
+ QCOMPARE(s1->events.at(1).first, 1);
+ QCOMPARE(s1->events.at(1).second, TestState::Exit);
+ // t is triggered
+ QCOMPARE(t->triggers.count(), 1);
+ QCOMPARE(t->triggers.at(0), 2);
+ // s2 is entered
+ QCOMPARE(s2->events.count(), 2);
+ QCOMPARE(s2->events.at(0).first, 3);
+ QCOMPARE(s2->events.at(0).second, TestState::Entry);
+ // s2 is exited
+ QCOMPARE(s2->events.at(1).first, 4);
+ QCOMPARE(s2->events.at(1).second, TestState::Exit);
+ }
+ // Two top-level states, one has two child states
+ {
+ QStateMachine machine;
+
+ TestState *s1 = new TestState(machine.rootState());
+ TestState *s11 = new TestState(s1);
+ TestState *s12 = new TestState(s1);
+ TestState *s2 = new TestState(machine.rootState());
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ s1->setInitialState(s11);
+ TestTransition *t1 = new TestTransition(s12);
+ s11->addTransition(t1);
+ TestTransition *t2 = new TestTransition(s2);
+ s12->addTransition(t2);
+ s2->addTransition(s3);
+
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s1);
+ globalTick = 0;
+ machine.start();
+
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s3));
+
+ // s1 is entered
+ QCOMPARE(s1->events.count(), 2);
+ QCOMPARE(s1->events.at(0).first, 0);
+ QCOMPARE(s1->events.at(0).second, TestState::Entry);
+ // s11 is entered
+ QCOMPARE(s11->events.count(), 2);
+ QCOMPARE(s11->events.at(0).first, 1);
+ QCOMPARE(s11->events.at(0).second, TestState::Entry);
+ // s11 is exited
+ QCOMPARE(s11->events.at(1).first, 2);
+ QCOMPARE(s11->events.at(1).second, TestState::Exit);
+ // t1 is triggered
+ QCOMPARE(t1->triggers.count(), 1);
+ QCOMPARE(t1->triggers.at(0), 3);
+ // s12 is entered
+ QCOMPARE(s12->events.count(), 2);
+ QCOMPARE(s12->events.at(0).first, 4);
+ QCOMPARE(s12->events.at(0).second, TestState::Entry);
+ // s12 is exited
+ QCOMPARE(s12->events.at(1).first, 5);
+ QCOMPARE(s12->events.at(1).second, TestState::Exit);
+ // s1 is exited
+ QCOMPARE(s1->events.at(1).first, 6);
+ QCOMPARE(s1->events.at(1).second, TestState::Exit);
+ // t2 is triggered
+ QCOMPARE(t2->triggers.count(), 1);
+ QCOMPARE(t2->triggers.at(0), 7);
+ // s2 is entered
+ QCOMPARE(s2->events.count(), 2);
+ QCOMPARE(s2->events.at(0).first, 8);
+ QCOMPARE(s2->events.at(0).second, TestState::Entry);
+ // s2 is exited
+ QCOMPARE(s2->events.at(1).first, 9);
+ QCOMPARE(s2->events.at(1).second, TestState::Exit);
+ }
+}
+
+struct StringEvent : public QEvent
+{
+public:
+ StringEvent(const QString &val)
+ : QEvent(QEvent::Type(QEvent::User+2)),
+ value(val) {}
+
+ QString value;
+};
+
+class StringTransition : public QAbstractTransition
+{
+public:
+ StringTransition(const QString &value, QAbstractState *target)
+ : QAbstractTransition(QList<QAbstractState*>() << target), m_value(value) {}
+
+protected:
+ virtual bool eventTest(QEvent *e) const
+ {
+ if (e->type() != QEvent::Type(QEvent::User+2))
+ return false;
+ StringEvent *se = static_cast<StringEvent*>(e);
+ return (m_value == se->value) && (!m_cond.isValid() || (m_cond.indexIn(m_value) != -1));
+ }
+ virtual void onTransition() {}
+
+private:
+ QString m_value;
+ QRegExp m_cond;
+};
+
+class StringEventPoster : public QState
+{
+public:
+ StringEventPoster(QStateMachine *machine, const QString &value, QState *parent = 0)
+ : QState(parent), m_machine(machine), m_value(value) {}
+
+ void setString(const QString &value)
+ { m_value = value; }
+
+protected:
+ virtual void onEntry()
+ {
+ m_machine->postEvent(new StringEvent(m_value));
+ }
+ virtual void onExit() {}
+
+private:
+ QStateMachine *m_machine;
+ QString m_value;
+};
+
+void tst_QStateMachine::postEvent()
+{
+ QStateMachine machine;
+ StringEventPoster *s1 = new StringEventPoster(&machine, "a");
+ QFinalState *s2 = new QFinalState;
+ s1->addTransition(new StringTransition("a", s2));
+ machine.addState(s1);
+ machine.addState(s2);
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+
+ s1->setString("b");
+ QFinalState *s3 = new QFinalState();
+ machine.addState(s3);
+ s1->addTransition(new StringTransition("b", s3));
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s3));
+}
+
+void tst_QStateMachine::stateFinished()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+ QState *s1_1 = new QState(s1);
+ QFinalState *s1_2 = new QFinalState(s1);
+ s1_1->addTransition(s1_2);
+ s1->setInitialState(s1_1);
+ QFinalState *s2 = new QFinalState(machine.rootState());
+ s1->addTransition(new QStateFinishedTransition(s1, QList<QAbstractState*>() << s2));
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+}
+
+void tst_QStateMachine::parallelStates()
+{
+ QStateMachine machine;
+
+ QState *s1 = new QState(QState::ParallelGroup);
+ QState *s1_1 = new QState(s1);
+ QState *s1_1_1 = new QState(s1_1);
+ QFinalState *s1_1_f = new QFinalState(s1_1);
+ s1_1_1->addTransition(s1_1_f);
+ s1_1->setInitialState(s1_1_1);
+ QState *s1_2 = new QState(s1);
+ QState *s1_2_1 = new QState(s1_2);
+ QFinalState *s1_2_f = new QFinalState(s1_2);
+ s1_2_1->addTransition(s1_2_f);
+ s1_2->setInitialState(s1_2_1);
+ machine.addState(s1);
+
+ QFinalState *s2 = new QFinalState();
+ machine.addState(s2);
+
+ s1->addFinishedTransition(s2);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
+void tst_QStateMachine::allSourceToTargetConfigurations()
+{
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ s0->setObjectName("s0");
+ QState *s1 = new QState(s0);
+ s1->setObjectName("s1");
+ QState *s11 = new QState(s1);
+ s11->setObjectName("s11");
+ QState *s2 = new QState(s0);
+ s2->setObjectName("s2");
+ QState *s21 = new QState(s2);
+ s21->setObjectName("s21");
+ QState *s211 = new QState(s21);
+ s211->setObjectName("s211");
+ QFinalState *f = new QFinalState(machine.rootState());
+ f->setObjectName("f");
+
+ s0->setInitialState(s1);
+ s1->setInitialState(s11);
+ s2->setInitialState(s21);
+ s21->setInitialState(s211);
+
+ s11->addTransition(new StringTransition("g", s211));
+ s1->addTransition(new StringTransition("a", s1));
+ s1->addTransition(new StringTransition("b", s11));
+ s1->addTransition(new StringTransition("c", s2));
+ s1->addTransition(new StringTransition("d", s0));
+ s1->addTransition(new StringTransition("f", s211));
+ s211->addTransition(new StringTransition("d", s21));
+ s211->addTransition(new StringTransition("g", s0));
+ s211->addTransition(new StringTransition("h", f));
+ s21->addTransition(new StringTransition("b", s211));
+ s2->addTransition(new StringTransition("c", s1));
+ s2->addTransition(new StringTransition("f", s11));
+ s0->addTransition(new StringTransition("e", s211));
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new StringEvent("a"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("b"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("c"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("d"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("e"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("f"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("g"));
+ QCoreApplication::processEvents();
+ machine.postEvent(new StringEvent("h"));
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
+class SignalEmitter : public QObject
+{
+Q_OBJECT
+ public:
+ SignalEmitter(QObject *parent = 0)
+ : QObject(parent) {}
+ void emitSignalWithNoArg()
+ { emit signalWithNoArg(); }
+ void emitSignalWithIntArg(int arg)
+ { emit signalWithIntArg(arg); }
+ void emitSignalWithStringArg(const QString &arg)
+ { emit signalWithStringArg(arg); }
+Q_SIGNALS:
+ void signalWithNoArg();
+ void signalWithIntArg(int);
+ void signalWithStringArg(const QString &);
+};
+
+class TestSignalTransition : public QSignalTransition
+{
+public:
+ TestSignalTransition()
+ : QSignalTransition() {}
+ TestSignalTransition(QObject *sender, const char *signal,
+ QAbstractState *target)
+ : QSignalTransition(sender, signal, QList<QAbstractState*>() << target) {}
+ QVariantList argumentsReceived() const {
+ return m_args;
+ }
+protected:
+ bool eventTest(QEvent *e) const {
+ if (!QSignalTransition::eventTest(e))
+ return false;
+ QSignalEvent *se = static_cast<QSignalEvent*>(e);
+ const_cast<TestSignalTransition*>(this)->m_args = se->arguments();
+ return true;
+ }
+private:
+ QVariantList m_args;
+};
+
+void tst_QStateMachine::signalTransitions()
+{
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+ SignalEmitter emitter;
+ s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ emitter.emitSignalWithNoArg();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+ SignalEmitter emitter;
+ TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithIntArg(int)), s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ emitter.emitSignalWithIntArg(123);
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(trans->argumentsReceived().size(), 1);
+ QCOMPARE(trans->argumentsReceived().at(0).toInt(), 123);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+ SignalEmitter emitter;
+ TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithStringArg(QString)), s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QString testString = QString::fromLatin1("hello");
+ emitter.emitSignalWithStringArg(testString);
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(trans->argumentsReceived().size(), 1);
+ QCOMPARE(trans->argumentsReceived().at(0).toString(), testString);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ TestSignalTransition *trans = new TestSignalTransition();
+ QCOMPARE(trans->senderObject(), (QObject*)0);
+ QCOMPARE(trans->signal(), QByteArray());
+
+ SignalEmitter emitter;
+ trans->setSenderObject(&emitter);
+ QCOMPARE(trans->senderObject(), (QObject*)&emitter);
+ trans->setSignal(SIGNAL(signalWithNoArg()));
+ QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg())));
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ emitter.emitSignalWithNoArg();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+}
+
+void tst_QStateMachine::eventTransitions()
+{
+ QPushButton button;
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ QMouseEventTransition *trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton);
+ QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
+ QCOMPARE(trans->button(), Qt::LeftButton);
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTest::mousePress(&button, Qt::LeftButton);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ QEventTransition *trans = new QEventTransition();
+ QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventType(), QEvent::None);
+ trans->setEventSource(&button);
+ QCOMPARE(trans->eventSource(), (QObject*)&button);
+ trans->setEventType(QEvent::MouseButtonPress);
+ QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTest::mousePress(&button, Qt::LeftButton);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ QMouseEventTransition *trans = new QMouseEventTransition();
+ QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventType(), QEvent::None);
+ QCOMPARE(trans->button(), Qt::NoButton);
+ trans->setEventSource(&button);
+ trans->setEventType(QEvent::MouseButtonPress);
+ trans->setButton(Qt::LeftButton);
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTest::mousePress(&button, Qt::LeftButton);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ QKeyEventTransition *trans = new QKeyEventTransition(&button, QEvent::KeyPress, Qt::Key_A);
+ QCOMPARE(trans->eventType(), QEvent::KeyPress);
+ QCOMPARE(trans->key(), (int)Qt::Key_A);
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTest::keyPress(&button, Qt::Key_A);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+
+ QKeyEventTransition *trans = new QKeyEventTransition();
+ QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventType(), QEvent::None);
+ QCOMPARE(trans->key(), 0);
+ trans->setEventSource(&button);
+ trans->setEventType(QEvent::KeyPress);
+ trans->setKey(Qt::Key_A);
+ trans->setTargetState(s1);
+ s0->addTransition(trans);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTest::keyPress(&button, Qt::Key_A);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ }
+}
+
+void tst_QStateMachine::historyStates()
+{
+ QStateMachine machine;
+ QState *root = machine.rootState();
+ QState *s0 = new QState(root);
+ QState *s00 = new QState(s0);
+ QState *s01 = new QState(s0);
+ QHistoryState *s0h = s0->addHistoryState();
+ QState *s1 = new QState(root);
+ QFinalState *s2 = new QFinalState(root);
+
+ s00->addTransition(new StringTransition("a", s01));
+ s0->addTransition(new StringTransition("b", s1));
+ s1->addTransition(new StringTransition("c", s0h));
+ s0->addTransition(new StringTransition("d", s2));
+
+ root->setInitialState(s0);
+ s0->setInitialState(s00);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s0));
+ QVERIFY(machine.configuration().contains(s00));
+
+ machine.postEvent(new StringEvent("a"));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s0));
+ QVERIFY(machine.configuration().contains(s01));
+
+ machine.postEvent(new StringEvent("b"));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new StringEvent("c"));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s0));
+ QVERIFY(machine.configuration().contains(s01));
+
+ machine.postEvent(new StringEvent("d"));
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
+class TestStateAction : public QStateAction
+{
+public:
+ TestStateAction() : m_didExecute(false)
+ {}
+ bool didExecute() const {
+ return m_didExecute;
+ }
+protected:
+ void execute() {
+ m_didExecute = true;
+ }
+private:
+ bool m_didExecute;
+};
+
+void tst_QStateMachine::stateActions()
+{
+ {
+ QStateSetPropertyAction act;
+ QCOMPARE(act.targetObject(), (QObject*)0);
+ QCOMPARE(act.propertyName().length(), 0);
+ QCOMPARE(act.value(), QVariant());
+
+ act.setTargetObject(this);
+ QCOMPARE(act.targetObject(), (QObject*)this);
+ QByteArray name("foo");
+ act.setPropertyName(name);
+ QCOMPARE(act.propertyName(), name);
+ QVariant value(123);
+ act.setValue(value);
+ QCOMPARE(act.value(), value);
+ }
+ {
+ QByteArray name("foo");
+ QVariant value(123);
+ QStateSetPropertyAction act(this, name, value);
+ QCOMPARE(act.targetObject(), (QObject*)this);
+ QCOMPARE(act.propertyName(), name);
+ QCOMPARE(act.value(), value);
+ }
+
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+
+ QVERIFY(s1->entryActions().isEmpty());
+ QVERIFY(s1->exitActions().isEmpty());
+
+ QTest::ignoreMessage(QtWarningMsg, "QActionState::addEntryAction: cannot add null action");
+ s1->addEntryAction(0);
+ QTest::ignoreMessage(QtWarningMsg, "QActionState::addExitAction: cannot add null action");
+ s1->addExitAction(0);
+ QTest::ignoreMessage(QtWarningMsg, "QActionState::removeEntryAction: cannot remove null action");
+ s1->removeEntryAction(0);
+ QTest::ignoreMessage(QtWarningMsg, "QActionState::removeExitAction: cannot remove null action");
+ s1->removeExitAction(0);
+
+ QStateSetPropertyAction *spa = new QStateSetPropertyAction(s1, "objectName", "foo");
+ s1->addEntryAction(spa);
+ QCOMPARE(s1->entryActions().size(), 1);
+ QCOMPARE(s1->entryActions().at(0), (QStateAction*)spa);
+ QCOMPARE(spa->parent(), (QObject*)s1);
+ QVERIFY(s1->exitActions().isEmpty());
+
+ s1->addEntryAction(spa); // add again
+ QCOMPARE(s1->entryActions().size(), 1);
+
+ QFinalState *s2 = new QFinalState(machine.rootState());
+ s1->addTransition(s2);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+
+ s1->removeEntryAction(spa);
+ QCOMPARE(spa->parent(), (QObject*)0);
+ QVERIFY(s1->entryActions().isEmpty());
+
+ s1->removeEntryAction(spa); // remove again
+
+ s1->setObjectName(QString::fromLatin1("bar"));
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(s1->objectName(), QString::fromLatin1("bar"));
+
+ s1->addEntryAction(spa);
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+
+ s1->removeEntryAction(spa);
+ QVERIFY(s1->entryActions().isEmpty());
+ QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(spa, "deleteLater");
+ QPointer<QStateAction> ptr(spa);
+ QVERIFY(ptr != 0);
+ s1->addEntryAction(ima);
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCoreApplication::processEvents();
+ QVERIFY(ptr == 0);
+
+ s1->removeEntryAction(ima);
+
+ s1->setPropertyOnEntry(s1, "objectName", "bar");
+ QCOMPARE(s1->entryActions().size(), 1);
+ s1->setPropertyOnEntry(s1, "objectName", "bar");
+ QCOMPARE(s1->entryActions().size(), 1);
+
+ s1->invokeMethodOnEntry(ima, "deleteLater");
+ QCOMPARE(s1->entryActions().size(), 2);
+
+ ptr = ima;
+ QVERIFY(ptr != 0);
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCoreApplication::processEvents();
+ QVERIFY(ptr == 0);
+
+ while (!s1->entryActions().isEmpty()) {
+ QStateAction *act = s1->entryActions().first();
+ s1->removeEntryAction(act);
+ delete act;
+ }
+
+ TestStateAction *act1 = new TestStateAction();
+ s1->addEntryAction(act1);
+ TestStateAction *act2 = new TestStateAction();
+ s1->addExitAction(act2);
+ QVERIFY(!act1->didExecute());
+ QVERIFY(!act2->didExecute());
+
+ finishedSpy.clear();
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+
+ QVERIFY(act1->didExecute());
+ QVERIFY(act2->didExecute());
+
+ QCOMPARE(s1->entryActions().size(), 1);
+ QCOMPARE(s2->entryActions().size(), 0);
+ s2->addEntryAction(act1); // should remove it from s1
+ QCOMPARE(s1->entryActions().size(), 0);
+ QCOMPARE(s2->entryActions().size(), 1);
+ QCOMPARE(act1->parent(), (QObject*)s2);
+
+ QCOMPARE(s2->exitActions().size(), 0);
+ s2->addExitAction(act1); // should remove entry action
+ QCOMPARE(s2->exitActions().size(), 1);
+ QCOMPARE(s2->entryActions().size(), 0);
+ QCOMPARE(act1->parent(), (QObject*)s2);
+}
+
+void tst_QStateMachine::transitionActions()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+
+ QFinalState *s2 = new QFinalState(machine.rootState());
+ QTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ QVERIFY(trans->actions().isEmpty());
+ QTest::ignoreMessage(QtWarningMsg, "QTransition::addAction: cannot add null action");
+ trans->addAction(0);
+ QVERIFY(trans->actions().isEmpty());
+
+ TestStateAction *act = new TestStateAction();
+ trans->addAction(act);
+ QCOMPARE(trans->actions().size(), 1);
+ QCOMPARE(trans->actions().at(0), (QStateAction*)act);
+ QCOMPARE(act->parent(), (QObject*)trans);
+ QVERIFY(!act->didExecute());
+
+ trans->removeAction(act);
+ QVERIFY(trans->actions().isEmpty());
+ QCOMPARE(act->parent(), (QObject*)0);
+
+ trans->addAction(act);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QVERIFY(act->didExecute());
+
+ trans->setPropertyOnTransition(s1, "objectName", "foo");
+ trans->invokeMethodOnTransition(act, "deleteLater");
+
+ QPointer<QStateAction> ptr(act);
+ QVERIFY(ptr != 0);
+ finishedSpy.clear();
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCoreApplication::processEvents();
+ QVERIFY(ptr == 0);
+ QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+}
+
+void tst_QStateMachine::defaultGlobalRestorePolicy()
+{
+ QStateMachine machine;
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+ propertyHolder->setProperty("b", 2);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->setPropertyOnEntry(propertyHolder, "b", 4);
+
+ QState *s3 = new QState(machine.rootState());
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+}
+
+void tst_QStateMachine::restorePolicyNotInherited()
+{
+ QStateMachine machine;
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+ propertyHolder->setProperty("b", 2);
+
+ QState *parentState = new QState(machine.rootState());
+ parentState->setObjectName("parentState");
+ parentState->setRestorePolicy(QState::RestoreProperties);
+
+ QState *s1 = new QState(parentState);
+ s1->setObjectName("s1");
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ parentState->setInitialState(s1);
+
+ QState *s2 = new QState(parentState);
+ s2->setObjectName("s2");
+ s2->setPropertyOnEntry(propertyHolder, "b", 4);
+
+ QState *s3 = new QState(parentState);
+ s3->setObjectName("s3");
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(parentState);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+}
+
+void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QState::DoNotRestoreProperties);
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+ propertyHolder->setProperty("b", 2);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->setPropertyOnEntry(propertyHolder, "b", 4);
+
+ QState *s3 = new QState(machine.rootState());
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+}
+
+void tst_QStateMachine::setRestorePolicyToDoNotRestore()
+{
+ QObject *object = new QObject();
+ object->setProperty("a", 1);
+ object->setProperty("b", 2);
+
+ QStateMachine machine;
+
+ QState *S1 = new QState();
+ S1->setObjectName("S1");
+ S1->setPropertyOnEntry(object, "a", 3);
+ S1->setRestorePolicy(QState::DoNotRestoreProperties);
+ machine.addState(S1);
+
+ QState *S2 = new QState();
+ S2->setObjectName("S2");
+ S2->setPropertyOnEntry(object, "b", 5);
+ S2->setRestorePolicy(QState::DoNotRestoreProperties);
+ machine.addState(S2);
+
+ QState *S3 = new QState();
+ S3->setObjectName("S3");
+ S3->setRestorePolicy(QState::DoNotRestoreProperties);
+ machine.addState(S3);
+
+ QFinalState *S4 = new QFinalState();
+ machine.addState(S4);
+
+ S1->addTransition(new EventTransition(QEvent::User, S2));
+ S2->addTransition(new EventTransition(QEvent::User, S3));
+ S3->addTransition(S4);
+
+ machine.setInitialState(S1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 3);
+ QCOMPARE(object->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 3);
+ QCOMPARE(object->property("b").toInt(), 5);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(object->property("a").toInt(), 3);
+ QCOMPARE(object->property("b").toInt(), 5);
+}
+
+void tst_QStateMachine::setGlobalRestorePolicyToGlobalRestore()
+{
+ s_countWarnings = false;
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QState::GlobalRestorePolicy);
+
+ QCOMPARE(machine.globalRestorePolicy(), QState::DoNotRestoreProperties);
+ QCOMPARE(s_msgType, QtWarningMsg);
+
+ s_msgType = QtDebugMsg;
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
+ machine.setGlobalRestorePolicy(QState::GlobalRestorePolicy);
+
+ QCOMPARE(machine.globalRestorePolicy(), QState::RestoreProperties);
+ QCOMPARE(s_msgType, QtWarningMsg);
+}
+
+void tst_QStateMachine::restorePolicyOnChildState()
+{
+ QStateMachine machine;
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+ propertyHolder->setProperty("b", 2);
+
+ QState *parentState = new QState(machine.rootState());
+ parentState->setObjectName("parentState");
+
+ QState *s1 = new QState(parentState);
+ s1->setRestorePolicy(QState::RestoreProperties);
+ s1->setObjectName("s1");
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ parentState->setInitialState(s1);
+
+ QState *s2 = new QState(parentState);
+ s2->setRestorePolicy(QState::RestoreProperties);
+ s2->setObjectName("s2");
+ s2->setPropertyOnEntry(propertyHolder, "b", 4);
+
+ QState *s3 = new QState(parentState);
+ s3->setRestorePolicy(QState::RestoreProperties);
+ s3->setObjectName("s3");
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(parentState);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 1);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 1);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+}
+
+void tst_QStateMachine::globalRestorePolicySetToRestore()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QState::RestoreProperties);
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+ propertyHolder->setProperty("b", 2);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->setPropertyOnEntry(propertyHolder, "b", 4);
+
+ QState *s3 = new QState(machine.rootState());
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 1);
+ QCOMPARE(propertyHolder->property("b").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("a").toInt(), 1);
+ QCOMPARE(propertyHolder->property("b").toInt(), 2);
+}
+
+void tst_QStateMachine::mixedRestoreProperties()
+{
+ QStateMachine machine;
+
+ QObject *propertyHolder = new QObject();
+ propertyHolder->setProperty("a", 1);
+
+ QState *s1 = new QState(machine.rootState());
+ s1->setRestorePolicy(QState::RestoreProperties);
+ s1->setPropertyOnEntry(propertyHolder, "a", 3);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->setPropertyOnEntry(propertyHolder, "a", 4);
+
+ QState *s3 = new QState(machine.rootState());
+
+ QState *s4 = new QState(machine.rootState());
+ s4->setPropertyOnEntry(propertyHolder, "a", 5);
+
+ QState *s5 = new QState(machine.rootState());
+ s5->setRestorePolicy(QState::RestoreProperties);
+ s5->setPropertyOnEntry(propertyHolder, "a", 6);
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s2->addTransition(new EventTransition(QEvent::User, s3));
+ s3->addTransition(new EventTransition(QEvent::User, s4));
+ s4->addTransition(new EventTransition(QEvent::User, s5));
+ s5->addTransition(new EventTransition(QEvent::User, s3));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ // Enter s1, save current
+ QCOMPARE(propertyHolder->property("a").toInt(), 3);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ // Enter s2, restorePolicy == DoNotRestore, so restore all properties
+ QCOMPARE(propertyHolder->property("a").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ // Enter s3
+ QCOMPARE(propertyHolder->property("a").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ // Enter s4
+ QCOMPARE(propertyHolder->property("a").toInt(), 5);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ // Enter s5, save current
+ QCOMPARE(propertyHolder->property("a").toInt(), 6);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ // Enter s3, restore
+ QCOMPARE(propertyHolder->property("a").toInt(), 5);
+}
+
+void tst_QStateMachine::addAnimatedTransition()
+{
+ {
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ SignalEmitter emitter;
+ QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
+ QVERIFY(as != 0);
+ QCOMPARE(as->parentState(), s2->parentState());
+ }
+ {
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ QState *s21 = new QState(s2);
+ SignalEmitter emitter;
+ QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s21);
+ QVERIFY(as != 0);
+ QCOMPARE(as->parentState(), s2);
+ }
+ {
+ QStateMachine machine;
+ QState *s1 = new QState();
+ QState *s2 = new QState();
+ SignalEmitter emitter;
+ QTest::ignoreMessage(QtWarningMsg, "QState::addAnimatedTransition: cannot add transition to target that doesn't have a parent state");
+ QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
+ QCOMPARE(as, (QState*)0);
+ }
+}
+
+void tst_QStateMachine::transitionWithParent()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ EventTransition *trans = new EventTransition(QEvent::User, s2, s1);
+ QCOMPARE(trans->sourceState(), s1);
+ QCOMPARE(trans->targetState(), (QAbstractState*)s2);
+ QCOMPARE(trans->targetStates().size(), 1);
+ QCOMPARE(trans->targetStates().at(0), (QAbstractState*)s2);
+}
+
+QTEST_MAIN(tst_QStateMachine)
+#include "tst_qstatemachine.moc"