summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/arthur/data/qps/borderimage.qps19
-rw-r--r--tests/arthur/data/qps/borderimage_qps.pngbin90704 -> 91838 bytes
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp6
-rw-r--r--tests/auto/declarative/layouts/data/grid-margin.qml38
-rw-r--r--tests/auto/declarative/layouts/data/grid-margin.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing-margin.qml39
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing-margin.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.qml38
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.xml9
-rw-r--r--tests/auto/declarative/layouts/data/grid.qml37
-rw-r--r--tests/auto/declarative/layouts/data/grid.xml9
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-margin.qml25
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml26
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.qml25
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.xml7
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.qml24
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-margin.qml25
-rw-r--r--tests/auto/declarative/layouts/data/vertical-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing-margin.qml26
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing-margin.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.qml25
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.xml7
-rw-r--r--tests/auto/declarative/layouts/data/vertical.qml24
-rw-r--r--tests/auto/declarative/layouts/data/vertical.xml7
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp28
-rw-r--r--tests/auto/declarative/listview/data/listview.qml39
-rw-r--r--tests/auto/declarative/listview/data/listview.xml14
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp4
-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/tst_numberformatter.cpp4
-rw-r--r--tests/auto/declarative/pathview/data/pathview.qml60
-rw-r--r--tests/auto/declarative/pathview/data/pathview.xml20
-rw-r--r--tests/auto/declarative/pathview/tst_pathview.cpp4
-rw-r--r--tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp2
-rw-r--r--tests/auto/declarative/qfxtext/tst_qfxtext.cpp61
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp44
-rw-r--r--tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp12
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp8
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp64
-rw-r--r--tests/auto/declarative/repeater/data/repeater.qml18
-rw-r--r--tests/auto/declarative/repeater/data/repeater.xml7
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp2
-rw-r--r--tests/auto/declarative/simplecanvasitem/data/test.qml58
-rw-r--r--tests/auto/declarative/simplecanvasitem/data/test.xml12
-rw-r--r--tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp6
-rw-r--r--tests/auto/qanimationstate/qanimationstate.pro5
-rw-r--r--tests/auto/qanimationstate/tst_qanimationstate.cpp625
-rw-r--r--tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp73
-rw-r--r--tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp33
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp5
-rw-r--r--tests/auto/qstate/tst_qstate.cpp27
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp1558
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp76
-rw-r--r--tests/auto/selftests/expected_xunit.txt11
-rw-r--r--tests/auto/selftests/xunit/tst_xunit.cpp2
-rw-r--r--tests/benchmarks/qanimation/main.cpp57
-rw-r--r--tests/benchmarks/qanimation/rectanimation.cpp28
-rw-r--r--tests/benchmarks/qanimation/rectanimation.h10
63 files changed, 2258 insertions, 1290 deletions
diff --git a/tests/arthur/data/qps/borderimage.qps b/tests/arthur/data/qps/borderimage.qps
index 14073fe..8d2e54b 100644
--- a/tests/arthur/data/qps/borderimage.qps
+++ b/tests/arthur/data/qps/borderimage.qps
@@ -123,6 +123,21 @@ end_block one_pixel_border
resetMatrix
+translate 205.1 626.1
+scale 0.4 0.4
+
+repeat_block one_pixel_border
+
+resetMatrix
+
+translate 255.1 624.1
+scale 0.4 0.4
+rotate 10
+
+repeat_block one_pixel_border
+
+resetMatrix
+
setPen red
drawRect 0 0 70 680
@@ -145,5 +160,5 @@ drawText 174 114 "smoothpixmaptransform off"
drawRect 164 128 224 134
drawText 174 252 "smoothpixmaptransform on"
-drawRect 200 520 97 128
-drawText 210 638 "1x1 edges"
+drawRect 200 520 97 188
+drawText 210 698 "1x1 edges"
diff --git a/tests/arthur/data/qps/borderimage_qps.png b/tests/arthur/data/qps/borderimage_qps.png
index a4ec6cb..ed51d5f 100644
--- a/tests/arthur/data/qps/borderimage_qps.png
+++ b/tests/arthur/data/qps/borderimage_qps.png
Binary files differ
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
index 4593033..67cff02 100644
--- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -18,7 +18,7 @@ private slots:
void tst_datetimeformatter::date()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "<DateTimeFormatter date=\"2008-12-24\"/>");
+ QmlComponent formatterComponent(&engine, "DateTimeFormatter { date: \"2008-12-24\" }");
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
QVERIFY(formatter != 0);
@@ -38,7 +38,7 @@ void tst_datetimeformatter::date()
void tst_datetimeformatter::time()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "<DateTimeFormatter time=\"14:15:38.200\"/>");
+ QmlComponent formatterComponent(&engine, "DateTimeFormatter { time: \"14:15:38.200\" }");
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
QVERIFY(formatter != 0);
@@ -64,7 +64,7 @@ void tst_datetimeformatter::time()
void tst_datetimeformatter::dateTime()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "<DateTimeFormatter dateTime=\"1978-03-04T09:13:54\"/>");
+ QmlComponent formatterComponent(&engine, "DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }");
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
QVERIFY(formatter != 0);
diff --git a/tests/auto/declarative/layouts/data/grid-margin.qml b/tests/auto/declarative/layouts/data/grid-margin.qml
new file mode 100644
index 0000000..bae47f9
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-margin.qml
@@ -0,0 +1,38 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/grid-margin.xml b/tests/auto/declarative/layouts/data/grid-margin.xml
deleted file mode 100644
index fe58eef..0000000
--- a/tests/auto/declarative/layouts/data/grid-margin.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/grid-spacing-margin.qml
new file mode 100644
index 0000000..100d8c5
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-spacing-margin.qml
@@ -0,0 +1,39 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/grid-spacing-margin.xml b/tests/auto/declarative/layouts/data/grid-spacing-margin.xml
deleted file mode 100644
index 807b653..0000000
--- a/tests/auto/declarative/layouts/data/grid-spacing-margin.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml
new file mode 100644
index 0000000..494127b
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid-spacing.qml
@@ -0,0 +1,38 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/grid-spacing.xml b/tests/auto/declarative/layouts/data/grid-spacing.xml
deleted file mode 100644
index 55ef5a5..0000000
--- a/tests/auto/declarative/layouts/data/grid-spacing.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/grid.qml
new file mode 100644
index 0000000..598915f
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/grid.qml
@@ -0,0 +1,37 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/grid.xml b/tests/auto/declarative/layouts/data/grid.xml
deleted file mode 100644
index abef813..0000000
--- a/tests/auto/declarative/layouts/data/grid.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/horizontal-margin.qml
new file mode 100644
index 0000000..8bf2329
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-margin.qml
@@ -0,0 +1,25 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/horizontal-margin.xml b/tests/auto/declarative/layouts/data/horizontal-margin.xml
deleted file mode 100644
index 7ee9706..0000000
--- a/tests/auto/declarative/layouts/data/horizontal-margin.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml
new file mode 100644
index 0000000..79652f6
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml
@@ -0,0 +1,26 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml
deleted file mode 100644
index 8767818..0000000
--- a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
new file mode 100644
index 0000000..5130e4a
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
@@ -0,0 +1,25 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.xml b/tests/auto/declarative/layouts/data/horizontal-spacing.xml
deleted file mode 100644
index cb58711..0000000
--- a/tests/auto/declarative/layouts/data/horizontal-spacing.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/horizontal.qml
new file mode 100644
index 0000000..7ad6b55
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/horizontal.qml
@@ -0,0 +1,24 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/horizontal.xml b/tests/auto/declarative/layouts/data/horizontal.xml
deleted file mode 100644
index f9deaf1..0000000
--- a/tests/auto/declarative/layouts/data/horizontal.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/vertical-margin.qml
new file mode 100644
index 0000000..ad34906
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-margin.qml
@@ -0,0 +1,25 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/vertical-margin.xml b/tests/auto/declarative/layouts/data/vertical-margin.xml
deleted file mode 100644
index abd7635..0000000
--- a/tests/auto/declarative/layouts/data/vertical-margin.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml
new file mode 100644
index 0000000..5de50b3
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml
@@ -0,0 +1,26 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml b/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml
deleted file mode 100644
index 3d41ca0..0000000
--- a/tests/auto/declarative/layouts/data/vertical-spacing-margin.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml
new file mode 100644
index 0000000..c364e3f
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml
@@ -0,0 +1,25 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.xml b/tests/auto/declarative/layouts/data/vertical-spacing.xml
deleted file mode 100644
index e25f981..0000000
--- a/tests/auto/declarative/layouts/data/vertical-spacing.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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.qml b/tests/auto/declarative/layouts/data/vertical.qml
new file mode 100644
index 0000000..50931cd
--- /dev/null
+++ b/tests/auto/declarative/layouts/data/vertical.qml
@@ -0,0 +1,24 @@
+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
+ }
+ }
+}
diff --git a/tests/auto/declarative/layouts/data/vertical.xml b/tests/auto/declarative/layouts/data/vertical.xml
deleted file mode 100644
index 198d99f..0000000
--- a/tests/auto/declarative/layouts/data/vertical.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index ad6a0b2..732551c 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -36,7 +36,7 @@ tst_QFxLayouts::tst_QFxLayouts()
void tst_QFxLayouts::test_horizontal()
{
- QFxView *canvas = createView(SRCDIR "/data/horizontal.xml");
+ QFxView *canvas = createView(SRCDIR "/data/horizontal.qml");
canvas->execute();
qApp->processEvents();
@@ -60,7 +60,7 @@ void tst_QFxLayouts::test_horizontal()
void tst_QFxLayouts::test_horizontal_spacing()
{
- QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing.xml");
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
canvas->execute();
qApp->processEvents();
@@ -84,7 +84,7 @@ void tst_QFxLayouts::test_horizontal_spacing()
void tst_QFxLayouts::test_horizontal_margin()
{
- QFxView *canvas = createView(SRCDIR "/data/horizontal-margin.xml");
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -108,7 +108,7 @@ void tst_QFxLayouts::test_horizontal_margin()
void tst_QFxLayouts::test_horizontal_spacing_margin()
{
- QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing-margin.xml");
+ QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -132,7 +132,7 @@ void tst_QFxLayouts::test_horizontal_spacing_margin()
void tst_QFxLayouts::test_vertical()
{
- QFxView *canvas = createView(SRCDIR "/data/vertical.xml");
+ QFxView *canvas = createView(SRCDIR "/data/vertical.qml");
canvas->execute();
qApp->processEvents();
@@ -156,7 +156,7 @@ void tst_QFxLayouts::test_vertical()
void tst_QFxLayouts::test_vertical_spacing()
{
- QFxView *canvas = createView(SRCDIR "/data/vertical-spacing.xml");
+ QFxView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
canvas->execute();
qApp->processEvents();
@@ -180,7 +180,7 @@ void tst_QFxLayouts::test_vertical_spacing()
void tst_QFxLayouts::test_vertical_margin()
{
- QFxView *canvas = createView(SRCDIR "/data/vertical-margin.xml");
+ QFxView *canvas = createView(SRCDIR "/data/vertical-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -204,7 +204,7 @@ void tst_QFxLayouts::test_vertical_margin()
void tst_QFxLayouts::test_vertical_spacing_margin()
{
- QFxView *canvas = createView(SRCDIR "/data/vertical-spacing-margin.xml");
+ QFxView *canvas = createView(SRCDIR "/data/vertical-spacing-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -228,7 +228,7 @@ void tst_QFxLayouts::test_vertical_spacing_margin()
void tst_QFxLayouts::test_grid()
{
- QFxView *canvas = createView("data/grid.xml");
+ QFxView *canvas = createView("data/grid.qml");
canvas->execute();
qApp->processEvents();
@@ -258,7 +258,7 @@ void tst_QFxLayouts::test_grid()
void tst_QFxLayouts::test_grid_spacing()
{
- QFxView *canvas = createView("data/grid-spacing.xml");
+ QFxView *canvas = createView("data/grid-spacing.qml");
canvas->execute();
qApp->processEvents();
@@ -288,7 +288,7 @@ void tst_QFxLayouts::test_grid_spacing()
void tst_QFxLayouts::test_grid_margin()
{
- QFxView *canvas = createView("data/grid-margin.xml");
+ QFxView *canvas = createView("data/grid-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -319,7 +319,7 @@ void tst_QFxLayouts::test_grid_margin()
void tst_QFxLayouts::test_grid_spacing_margin()
{
- QFxView *canvas = createView("data/grid-spacing-margin.xml");
+ QFxView *canvas = createView("data/grid-spacing-margin.qml");
canvas->execute();
qApp->processEvents();
@@ -354,7 +354,7 @@ QFxView *tst_QFxLayouts::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
QString xml = file.readAll();
- canvas->setXml(xml, filename);
+ canvas->setQml(xml, filename);
return canvas;
}
@@ -371,7 +371,7 @@ T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &id, int index)
QFxItem *item = parent->children()->at(i);
if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
if (index != -1) {
- QmlExpression e(item->itemContext(), "index", item);
+ QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
if (e.value().toInt() == index)
return static_cast<T*>(item);
diff --git a/tests/auto/declarative/listview/data/listview.qml b/tests/auto/declarative/listview/data/listview.qml
new file mode 100644
index 0000000..891f9a8
--- /dev/null
+++ b/tests/auto/declarative/listview/data/listview.qml
@@ -0,0 +1,39 @@
+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
+ }
+ }
+ }
+ ]
+ ListView {
+ id: list
+ width: 240
+ height: 320
+ model: testModel
+ delegate: Delegate
+ }
+}
diff --git a/tests/auto/declarative/listview/data/listview.xml b/tests/auto/declarative/listview/data/listview.xml
deleted file mode 100644
index 7fda2b5..0000000
--- a/tests/auto/declarative/listview/data/listview.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<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/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 681af57..25f546a 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -446,7 +446,7 @@ QFxView *tst_QFxListView::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
QString xml = file.readAll();
- canvas->setXml(xml, filename);
+ canvas->setQml(xml, filename);
return canvas;
}
@@ -463,7 +463,7 @@ T *tst_QFxListView::findItem(QFxItem *parent, const QString &id, int index)
QFxItem *item = parent->children()->at(i);
if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
if (index != -1) {
- QmlExpression e(item->itemContext(), "index", item);
+ QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
if (e.value().toInt() == index)
return static_cast<T*>(item);
diff --git a/tests/auto/declarative/namespaces/data/Red/Rect.qml b/tests/auto/declarative/namespaces/data/Red/Rect.qml
deleted file mode 100644
index c7b3d8c..0000000
--- a/tests/auto/declarative/namespaces/data/Red/Rect.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-<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
deleted file mode 100644
index f232770..0000000
--- a/tests/auto/declarative/namespaces/namespaces.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-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
deleted file mode 100644
index 665651d..0000000
--- a/tests/auto/declarative/namespaces/tst_namespaces.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#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/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
index eaeab51..e70d651 100644
--- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
+++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
@@ -165,7 +165,7 @@ void tst_numberformat::number()
QFETCH(QString, string);
QFETCH(float, number);
- QString componentStr = QString("<NumberFormatter number=\"") + string + QString("\"/>");
+ QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\" }");
QmlEngine engine;
QmlComponent formatterComponent(&engine, componentStr.toAscii());
@@ -200,7 +200,7 @@ void tst_numberformat::text()
QFETCH(QString, format);
QFETCH(QString, text);
- QString componentStr = QString("<NumberFormatter number=\"") + string + QString("\" format=\"") + format + QString("\" />");
+ QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }");
QmlEngine engine;
QmlComponent formatterComponent(&engine, componentStr.toAscii());
diff --git a/tests/auto/declarative/pathview/data/pathview.qml b/tests/auto/declarative/pathview/data/pathview.qml
new file mode 100644
index 0000000..0fec1e9
--- /dev/null
+++ b/tests/auto/declarative/pathview/data/pathview.qml
@@ -0,0 +1,60 @@
+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
+ }
+ }
+ }
+ ]
+ 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
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/pathview/data/pathview.xml b/tests/auto/declarative/pathview/data/pathview.xml
deleted file mode 100644
index 26b426c..0000000
--- a/tests/auto/declarative/pathview/data/pathview.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<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/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp
index 110d129..92890ba 100644
--- a/tests/auto/declarative/pathview/tst_pathview.cpp
+++ b/tests/auto/declarative/pathview/tst_pathview.cpp
@@ -221,7 +221,7 @@ QFxView *tst_QFxPathView::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
QString xml = file.readAll();
- canvas->setXml(xml, filename);
+ canvas->setQml(xml, filename);
return canvas;
}
@@ -238,7 +238,7 @@ T *tst_QFxPathView::findItem(QFxItem *parent, const QString &id, int index)
QFxItem *item = parent->children()->at(i);
if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
if (index != -1) {
- QmlExpression e(item->itemContext(), "index", item);
+ QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
if (e.value().toInt() == index)
return static_cast<T*>(item);
diff --git a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
index da58857..a8046e6 100644
--- a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
+++ b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
@@ -59,7 +59,7 @@ void tst_QBindableMap::changed()
QmlEngine engine;
QmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty(QLatin1String("data"), &map);
- QmlComponent component(&engine, "<Script script=\"data.key1 = 'Hello World';\"/>");
+ QmlComponent component(&engine, "Script { script: \"data.key1 = 'Hello World';\" }");
component.create();
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
diff --git a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
index ee74040..0eb9f97 100644
--- a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
+++ b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
@@ -48,8 +48,8 @@ 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>";
+ 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"
@@ -99,7 +99,7 @@ tst_qfxtext::tst_qfxtext()
void tst_qfxtext::text()
{
{
- QmlComponent textComponent(&engine, "<Text text=\"\" />");
+ QmlComponent textComponent(&engine, "Text { text: \"\" }");
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -108,7 +108,7 @@ void tst_qfxtext::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "<Text>" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -118,12 +118,13 @@ void tst_qfxtext::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "<Text><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), richText.at(i));
+ QString expected = richText.at(i);
+ QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
}
}
@@ -131,7 +132,7 @@ 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=\"\"/>");
+ QmlComponent textComponent(&engine, "Text { text: \"\" }");
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 0.);
@@ -143,7 +144,7 @@ void tst_qfxtext::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "<Text>" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -158,7 +159,7 @@ void tst_qfxtext::width()
int documentWidth = document.idealWidth();
- QString componentStr = "<Text><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -172,7 +173,7 @@ void tst_qfxtext::wrap()
// for specified width and wrap set true
{
- QmlComponent textComponent(&engine, "<Text text=\"\" wrap=\"true\" width=\"300\"/>");
+ QmlComponent textComponent(&engine, "Text { text: \"\"; wrap: true; width: 300 }");
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -180,7 +181,7 @@ void tst_qfxtext::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "<Text wrap=\"true\" width=\"300\">" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -189,7 +190,7 @@ void tst_qfxtext::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "<Text wrap=\"true\" width=\"300\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -202,12 +203,12 @@ 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)])+"\"";
+ QString elide = "elide: \""+QString(elidename[int(m)])+"\";";
// XXX Poor coverage.
{
- QmlComponent textComponent(&engine, ("<Text text=\"\" "+elide+" width=\"300\"/>").toLatin1());
+ QmlComponent textComponent(&engine, ("Text { text: \"\"; "+elide+" width: 300 }").toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -215,7 +216,7 @@ void tst_qfxtext::elide()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "<Text "+elide+" width=\"300\">" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -225,7 +226,7 @@ void tst_qfxtext::elide()
// richtext - does nothing
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "<Text "+elide+" width=\"300\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -243,7 +244,7 @@ void tst_qfxtext::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "<Text hAlign=\"" + hAlignmentStrings.at(j) + "\">" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -255,7 +256,7 @@ void tst_qfxtext::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "<Text hAlign=\"" + hAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -273,7 +274,7 @@ void tst_qfxtext::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "<Text vAlign=\"" + vAlignmentStrings.at(j) + "\">" + standard.at(i) + "</Text>";
+ QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -285,7 +286,7 @@ void tst_qfxtext::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "<Text vAlign=\"" + vAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></Text>";
+ QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -299,7 +300,7 @@ void tst_qfxtext::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "<Text font.size=\"40\" text=\"Hello World\"/>";
+ QString componentStr = "Text { font.size: 40; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -309,7 +310,7 @@ void tst_qfxtext::font()
}
{
- QString componentStr = "<Text font.bold=\"true\" text=\"Hello World\"/>";
+ QString componentStr = "Text { font.bold: true; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -318,7 +319,7 @@ void tst_qfxtext::font()
}
{
- QString componentStr = "<Text font.italic=\"true\" text=\"Hello World\"/>";
+ QString componentStr = "Text { font.italic: true; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -327,7 +328,7 @@ void tst_qfxtext::font()
}
{
- QString componentStr = "<Text font.family=\"Helvetica\" text=\"Hello World\"/>";
+ QString componentStr = "Text { font.family: \"Helvetica\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -337,7 +338,7 @@ void tst_qfxtext::font()
}
{
- QString componentStr = "<Text font.family=\"\" text=\"Hello World\"/>";
+ QString componentStr = "Text { font.family: \"\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -350,7 +351,7 @@ void tst_qfxtext::style()
//test style
for (int i = 0; i < styles.size(); i++)
{
- QString componentStr = "<Text style=\"" + styleStrings.at(i) + "\" text=\"Hello World\"/>";
+ QString componentStr = "Text { style: \"" + styleStrings.at(i) + "\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -364,7 +365,7 @@ void tst_qfxtext::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "<Text color=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ QString componentStr = "Text { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -374,7 +375,7 @@ void tst_qfxtext::color()
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "<Text styleColor=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ QString componentStr = "Text { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
@@ -387,7 +388,7 @@ void tst_qfxtext::color()
{
for (int j = 0; j < colorStrings.size(); j++)
{
- QString componentStr = "<Text color=\"" + colorStrings.at(i) + "\" styleColor=\"" + colorStrings.at(j) + "\" text=\"Hello World\"/>";
+ 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());
@@ -400,7 +401,7 @@ void tst_qfxtext::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "<Text color=\"" + colorStr + "\" text=\"Hello World\"/>";
+ QString componentStr = "Text { color: \"" + colorStr + "\"; text: \"Hello World\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1());
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 8baef3d..7be5b50 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -43,8 +43,8 @@ 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>";
+ 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"
@@ -84,7 +84,7 @@ tst_qfxtextedit::tst_qfxtextedit()
void tst_qfxtextedit::text()
{
{
- QmlComponent texteditComponent(&engine, "<TextEdit text=\"\" />");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }");
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -93,7 +93,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "<TextEdit>" + standard.at(i) + "</TextEdit>";
+ QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -103,7 +103,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "<TextEdit><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -121,7 +121,7 @@ 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=\"\"/>");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }");
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QCOMPARE(textEditObject->width(), 0.);
@@ -133,7 +133,7 @@ void tst_qfxtextedit::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "<TextEdit>" + standard.at(i) + "</TextEdit>";
+ QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -148,7 +148,7 @@ void tst_qfxtextedit::width()
int documentWidth = document.idealWidth();
- QString componentStr = "<TextEdit><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -160,7 +160,7 @@ void tst_qfxtextedit::wrap()
{
// for specified width and wrap set true
{
- QmlComponent texteditComponent(&engine, "<TextEdit text=\"\" wrap=\"true\" width=\"300\"/>");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\"; wrap: true; width: 300 }");
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QCOMPARE(textEditObject->width(), 300.);
@@ -168,7 +168,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "<TextEdit wrap=\"true\" width=\"300\">" + standard.at(i) + "</TextEdit>";
+ QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -177,7 +177,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "<TextEdit wrap=\"true\" width=\"300\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -195,7 +195,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "<TextEdit hAlign=\"" + hAlignmentStrings.at(j) + "\">" + standard.at(i) + "</TextEdit>";
+ QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -207,7 +207,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "<TextEdit hAlign=\"" + hAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -225,7 +225,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "<TextEdit vAlign=\"" + vAlignmentStrings.at(j) + "\">" + standard.at(i) + "</TextEdit>";
+ QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -237,7 +237,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "<TextEdit vAlign=\"" + vAlignmentStrings.at(j) + "\"><![CDATA[" + richText.at(i) + "]]></TextEdit>";
+ QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -251,7 +251,7 @@ void tst_qfxtextedit::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "<TextEdit font.size=\"40\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { font.size: 40; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -261,7 +261,7 @@ void tst_qfxtextedit::font()
}
{
- QString componentStr = "<TextEdit font.bold=\"true\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { font.bold: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -270,7 +270,7 @@ void tst_qfxtextedit::font()
}
{
- QString componentStr = "<TextEdit font.italic=\"true\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { font.italic: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -279,7 +279,7 @@ void tst_qfxtextedit::font()
}
{
- QString componentStr = "<TextEdit font.family=\"Helvetica\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -289,7 +289,7 @@ void tst_qfxtextedit::font()
}
{
- QString componentStr = "<TextEdit font.family=\"\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { font.family: \"\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -302,7 +302,7 @@ void tst_qfxtextedit::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "<TextEdit color=\"" + colorStrings.at(i) + "\" text=\"Hello World\"/>";
+ 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));
@@ -314,7 +314,7 @@ void tst_qfxtextedit::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "<TextEdit color=\"" + colorStr + "\" text=\"Hello World\"/>";
+ QString componentStr = "TextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
diff --git a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
index f5b32e8..0875690 100644
--- a/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
+++ b/tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
@@ -59,13 +59,13 @@ private:
void tst_qmlbindengine::boolPropertiesEvaluateAsBool()
{
{
- QmlComponent component(&engine, "<MyQmlObject stringProperty=\"{trueProperty?'pass':'fail'}\" />");
+ 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'}\" />");
+ QmlComponent component(&engine, "MyQmlObject { stringProperty: falseProperty?'fail':'pass' }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->stringProperty(), QLatin1String("pass"));
@@ -75,7 +75,7 @@ void tst_qmlbindengine::boolPropertiesEvaluateAsBool()
void tst_qmlbindengine::signalAssignment()
{
{
- QmlComponent component(&engine, "<MyQmlObject onBasicSignal=\"setString('pass')\" />");
+ QmlComponent component(&engine, "MyQmlObject { onBasicSignal: setString('pass') }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
@@ -84,7 +84,7 @@ void tst_qmlbindengine::signalAssignment()
}
{
- QmlComponent component(&engine, "<MyQmlObject onArgumentSignal=\"setString('pass ' + a + ' ' + b + ' ' + c)\" />");
+ QmlComponent component(&engine, "MyQmlObject { onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c) }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
@@ -96,7 +96,7 @@ void tst_qmlbindengine::signalAssignment()
void tst_qmlbindengine::methods()
{
{
- QmlComponent component(&engine, "<MyQmlObject id=\"MyObject\" onBasicSignal=\"MyObject.method()\" />");
+ QmlComponent component(&engine, "MyQmlObject { id: MyObject; onBasicSignal: MyObject.method() }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
@@ -107,7 +107,7 @@ void tst_qmlbindengine::methods()
}
{
- QmlComponent component(&engine, "<MyQmlObject id=\"MyObject\" onBasicSignal=\"MyObject.method(163)\" />");
+ QmlComponent component(&engine, "MyQmlObject { id: MyObject; onBasicSignal: MyObject.method(163) }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index 3a87070..e35a006 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -1,5 +1,5 @@
#include <qtest.h>
-#include <QtDeclarative/QmlEngine.h>
+#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlmetaproperty.h>
#include <QtGui/QLineEdit>
@@ -52,7 +52,7 @@ private:
void tst_QmlMetaProperty::writeObjectToList()
{
- QmlComponent containerComponent(&engine, "<MyContainer><children><MyQmlObject/></children></MyContainer>");
+ QmlComponent containerComponent(&engine, "MyContainer { children: MyQmlObject {} }");
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
QVERIFY(container->children()->size() == 1);
@@ -67,7 +67,7 @@ void tst_QmlMetaProperty::writeObjectToList()
Q_DECLARE_METATYPE(QList<QObject *>);
void tst_QmlMetaProperty::writeListToList()
{
- QmlComponent containerComponent(&engine, "<MyContainer><children><MyQmlObject/></children></MyContainer>");
+ QmlComponent containerComponent(&engine, "MyContainer { children: MyQmlObject {} }");
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
QVERIFY(container->children()->size() == 1);
@@ -87,7 +87,7 @@ void tst_QmlMetaProperty::writeListToList()
void tst_QmlMetaProperty::writeObjectToQmlList()
{
- QmlComponent containerComponent(&engine, "<MyContainer><qmlChildren><MyQmlObject/></qmlChildren></MyContainer>");
+ QmlComponent containerComponent(&engine, "MyContainer { qmlChildren: MyQmlObject {} }");
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
QVERIFY(container->qmlChildren()->size() == 1);
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index 24d3c22..96f6f4f 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -147,13 +147,13 @@ private slots:
//void readWriteDotProperty();
void emptyInput();
void missingObject();
- void invalidXML();
+ //void invalidXML();
void duplicateIDs();
void invalidID();
void interfaceProperty();
void interfaceQmlList();
void interfaceQList();
- void cannotAssignBindingToSignal();
+ //void cannotAssignBindingToSignal();
void assignObjectToSignal();
private:
@@ -162,14 +162,14 @@ private:
void tst_qmlparser::simpleObject()
{
- QmlComponent component(&engine, "<MyQmlObject/>");
+ 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>");
+ QmlComponent component(&engine, "MyContainer {\nMyQmlObject{}\nMyQmlObject{}\n}");
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QCOMPARE(container->children()->count(),2);
@@ -177,7 +177,7 @@ void tst_qmlparser::simpleContainer()
void tst_qmlparser::unregisteredObject()
{
- QmlComponent component(&engine, "<UnRegisteredObject/>", QUrl("myprogram.qml"));
+ 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);
@@ -187,14 +187,14 @@ void tst_qmlparser::nonexistantProperty()
{
//NOTE: these first 3 should all have the same error message
{
- QmlComponent component(&engine, "<MyQmlObject something=\"24\"/>");
+ 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>");
+ QmlComponent component(&engine, "MyQmlObject {\n something: 24\n}");
QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:2");
QObject *object = component.create();
QVERIFY(object == 0);
@@ -202,21 +202,21 @@ void tst_qmlparser::nonexistantProperty()
//non-existant using binding
{
- QmlComponent component(&engine, "<MyQmlObject something=\"{1}\"/>");
+ QmlComponent component(&engine, "MyQmlObject { something: 1 + 1 }");
QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
QObject *object = component.create();
QVERIFY(object == 0);
}
{
- QmlComponent component(&engine, "<MyQmlObject><something></something></MyQmlObject>");
+ QmlComponent component(&engine, "MyQmlObject { something: }");
QObject *object = component.create();
QVERIFY(object != 0);
}
//non-existant value-type default property
{
- QmlComponent component(&engine, "<MyQmlObject>\n24\n</MyQmlObject>");
+ QmlComponent component(&engine, "MyQmlObject {\n24\n}");
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();
@@ -225,7 +225,7 @@ void tst_qmlparser::nonexistantProperty()
//non-existant object-type default property
{
- QmlComponent component(&engine, "<MyQmlObject>\n<MyQmlObject/>\n</MyQmlObject>");
+ QmlComponent component(&engine, "MyQmlObject {\nMyQmlObject{}\n}");
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();
@@ -236,7 +236,7 @@ void tst_qmlparser::nonexistantProperty()
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\"/>");
+ QmlComponent component(&engine, "MyQmlObject { matrix: \"1,0,0,0,1,0,0,0,1\" }");
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object == 0);
}
@@ -246,7 +246,7 @@ 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\"/>");
+ QmlComponent component(&engine, "MyQmlObject { value: \"hello\" }");
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object == 0);
}
@@ -254,7 +254,7 @@ void tst_qmlparser::wrongType()
//int for bool
{
QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5' to property 'enabled' @<unspecified file>:1");
- QmlComponent component(&engine, "<MyQmlObject enabled=\"5\"/>");
+ QmlComponent component(&engine, "MyQmlObject { enabled: 5 }");
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object == 0);
}
@@ -262,7 +262,7 @@ void tst_qmlparser::wrongType()
//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\"/>");
+ QmlComponent component(&engine, "MyQmlObject { rect: \"5,5x10\" }");
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object == 0);
}
@@ -274,14 +274,14 @@ 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\"/>");
+ 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'}\"/>");
+ QmlComponent component(&engine, "MyQmlObject { readOnlyString: {'hello'} }");
QObject *object = component.create();
QVERIFY(object == 0);
}
@@ -290,7 +290,7 @@ void tst_qmlparser::readOnly()
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\"/>");
+ QmlComponent component(&engine, "MyDotPropertyObject { obj.value: 1 }");
QObject *object = component.create();
QVERIFY(object == 0);
}
@@ -298,7 +298,7 @@ void tst_qmlparser::nullDotProperty()
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\"/>");
+ QmlComponent component(&engine, "MyQmlObject { value.something: \"hello\" }");
QObject *object = component.create();
QVERIFY(object == 0);
}
@@ -306,13 +306,13 @@ void tst_qmlparser::fakeDotProperty()
//XXX need to define correct behavior first
/*void tst_qmlparser::readWriteDotProperty()
{
- QmlComponent component(&engine, "<MyDotPropertyObject readWriteObj.value=\"1\"/>");
+ 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>");
+ QmlComponent component(&engine, "MyContainer { MyQmlObject { id: Obj value: 1 } MyDotPropertyObject { readWriteObj: Obj } }");
MyContainer *object = qobject_cast<MyContainer*>(component.create());
QVERIFY(object != 0);
MyDotPropertyObject *dpo = qobject_cast<MyDotPropertyObject *>(object->children()->at(1));
@@ -333,13 +333,13 @@ 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/>");
+ QmlComponent component(&engine, "something:");
QObject *object = component.create();
QVERIFY(object == 0);
}
-void tst_qmlparser::invalidXML()
+/*void tst_qmlparser::invalidXML()
{
//extra stuff on end
{
@@ -375,12 +375,12 @@ void tst_qmlparser::invalidXML()
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>");
+ QmlComponent component(&engine, "MyContainer {\nMyQmlObject { id: MyID }\nMyQmlObject { id: MyID }\n}");
QObject *object = component.create();
QVERIFY(object == 0);
}
@@ -388,14 +388,14 @@ void tst_qmlparser::duplicateIDs()
void tst_qmlparser::invalidID()
{
QTest::ignoreMessage(QtWarningMsg, "'1' is not a valid id @<unspecified file>:1");
- QmlComponent component(&engine, "<MyQmlObject id=\"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>");
+ QmlComponent component(&engine, "MyQmlObject { interface: MyQmlObject }");
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QVERIFY(object->interface());
@@ -404,7 +404,7 @@ void tst_qmlparser::interfaceProperty()
void tst_qmlparser::interfaceQmlList()
{
- QmlComponent component(&engine, "<MyContainer><qmllistInterfaces>\n<MyQmlObject/>\n<MyQmlObject/>\n</qmllistInterfaces>\n</MyContainer>");
+ QmlComponent component(&engine, "MyContainer { qmllistInterfaces: MyQmlObject {} }");
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qmllistAccessor().count() == 2);
@@ -414,7 +414,7 @@ void tst_qmlparser::interfaceQmlList()
void tst_qmlparser::interfaceQList()
{
- QmlComponent component(&engine, "<MyContainer><qlistInterfaces>\n<MyQmlObject/>\n<MyQmlObject/>\n</qlistInterfaces>\n</MyContainer>");
+ QmlComponent component(&engine, "MyContainer { qlistInterfaces: MyQmlObject {} }");
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qlistInterfaces()->count() == 2);
@@ -422,17 +422,17 @@ void tst_qmlparser::interfaceQList()
QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
}
-void tst_qmlparser::cannotAssignBindingToSignal()
+/*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>");
+ QmlComponent component(&engine, "MyQmlObject { onBasicSignal: MyQmlObject {} }");
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
diff --git a/tests/auto/declarative/repeater/data/repeater.qml b/tests/auto/declarative/repeater/data/repeater.qml
new file mode 100644
index 0000000..2498646
--- /dev/null
+++ b/tests/auto/declarative/repeater/data/repeater.qml
@@ -0,0 +1,18 @@
+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
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/repeater/data/repeater.xml b/tests/auto/declarative/repeater/data/repeater.xml
deleted file mode 100644
index f863716..0000000
--- a/tests/auto/declarative/repeater/data/repeater.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<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/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index cdf1716..0d3ec98 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -66,7 +66,7 @@ QFxView *tst_QFxRepeater::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
QString xml = file.readAll();
- canvas->setXml(xml, filename);
+ canvas->setQml(xml, filename);
return canvas;
}
diff --git a/tests/auto/declarative/simplecanvasitem/data/test.qml b/tests/auto/declarative/simplecanvasitem/data/test.qml
new file mode 100644
index 0000000..d206a6b
--- /dev/null
+++ b/tests/auto/declarative/simplecanvasitem/data/test.qml
@@ -0,0 +1,58 @@
+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 {
+ 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
+ }
+}
diff --git a/tests/auto/declarative/simplecanvasitem/data/test.xml b/tests/auto/declarative/simplecanvasitem/data/test.xml
deleted file mode 100644
index 9b8f10a..0000000
--- a/tests/auto/declarative/simplecanvasitem/data/test.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<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/tst_simplecanvasitem.cpp b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
index 47608a0..cce4df1 100644
--- a/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
+++ b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp
@@ -26,7 +26,7 @@ tst_SimpleCanvasItem::tst_SimpleCanvasItem()
void tst_SimpleCanvasItem::test_pos()
{
- QFxView *canvas = createView(SRCDIR "/data/test.xml");
+ QFxView *canvas = createView(SRCDIR "/data/test.qml");
canvas->execute();
qApp->processEvents();
QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
@@ -42,7 +42,7 @@ void tst_SimpleCanvasItem::test_pos()
void tst_SimpleCanvasItem::test_scenePos()
{
- QFxView *canvas = createView(SRCDIR "/data/test.xml");
+ QFxView *canvas = createView(SRCDIR "/data/test.qml");
canvas->execute();
qApp->processEvents();
QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root());
@@ -69,7 +69,7 @@ QFxView *tst_SimpleCanvasItem::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
QString xml = file.readAll();
- canvas->setXml(xml, filename);
+ canvas->setQml(xml, filename);
return canvas;
}
diff --git a/tests/auto/qanimationstate/qanimationstate.pro b/tests/auto/qanimationstate/qanimationstate.pro
deleted file mode 100644
index 8862c27..0000000
--- a/tests/auto/qanimationstate/qanimationstate.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index 085db24..0000000
--- a/tests/auto/qanimationstate/tst_qanimationstate.cpp
+++ /dev/null
@@ -1,625 +0,0 @@
-/****************************************************************************
-**
-** 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/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp
index 58707f1..947e8d6 100644
--- a/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp
+++ b/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp
@@ -90,6 +90,8 @@ private Q_SLOTS:
void watcher();
void watcher_error();
void watcher_waitForFinished();
+ void watcher_waitForFinished_alreadyFinished();
+ void watcher_waitForFinished_alreadyFinished_eventLoop();
void watcher_waitForFinished_error();
void callInsideWaitForFinished();
@@ -375,6 +377,77 @@ void tst_QDBusPendingCall::watcher_waitForFinished()
QVERIFY(args2.at(0).toStringList().contains(conn.baseService()));
}
+void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished()
+{
+ QDBusPendingCall ac = sendMessage();
+ QVERIFY(!ac.isFinished());
+ QVERIFY(!ac.isError());
+ QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
+
+ ac.waitForFinished();
+ QVERIFY(ac.isFinished());
+ QVERIFY(!ac.isError());
+
+ callCount = 0;
+ watchArgument = 0;
+
+ // create a watcher on an already-finished reply
+ QDBusPendingCallWatcher watch(ac);
+ connect(&watch, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(finished(QDBusPendingCallWatcher*)));
+
+ watch.waitForFinished();
+
+ QVERIFY(ac.isFinished());
+ QVERIFY(!ac.isError());
+
+ QCOMPARE(callCount, 1);
+ QCOMPARE(slotCalled, (int)FinishCalled);
+ QCOMPARE(watchArgument, &watch);
+ QVERIFY(!watch.isError());
+
+ const QVariantList args2 = ac.reply().arguments();
+ QVERIFY(!args2.isEmpty());
+ QVERIFY(args2.at(0).toStringList().contains(conn.baseService()));
+}
+
+void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished_eventLoop()
+{
+ QDBusPendingCall ac = sendMessage();
+ QVERIFY(!ac.isFinished());
+ QVERIFY(!ac.isError());
+ QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
+
+ ac.waitForFinished();
+ QVERIFY(ac.isFinished());
+ QVERIFY(!ac.isError());
+
+ callCount = 0;
+ watchArgument = 0;
+
+ // create a watcher on an already-finished reply
+ QDBusPendingCallWatcher watch(ac);
+ connect(&watch, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(finished(QDBusPendingCallWatcher*)));
+ connect(&watch, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QVERIFY(ac.isFinished());
+ QVERIFY(!ac.isError());
+
+ QCOMPARE(callCount, 1);
+ QCOMPARE(slotCalled, (int)FinishCalled);
+ QCOMPARE(watchArgument, &watch);
+ QVERIFY(!watch.isError());
+
+ const QVariantList args2 = ac.reply().arguments();
+ QVERIFY(!args2.isEmpty());
+ QVERIFY(args2.at(0).toStringList().contains(conn.baseService()));
+}
+
void tst_QDBusPendingCall::watcher_waitForFinished_error()
{
QDBusPendingCall ac = sendError();
diff --git a/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp b/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
index 31a5391..0760ce8 100644
--- a/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
+++ b/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
@@ -59,6 +59,7 @@ public:
private slots:
void getSetCheck();
+ void capabilitiesPerType();
};
tst_QNetworkProxy::tst_QNetworkProxy()
@@ -79,6 +80,38 @@ void tst_QNetworkProxy::getSetCheck()
QCOMPARE(quint16(0), obj1.port());
obj1.setPort(quint16(0xffff));
QCOMPARE(quint16(0xffff), obj1.port());
+
+ obj1.setType(QNetworkProxy::DefaultProxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::DefaultProxy);
+ obj1.setType(QNetworkProxy::HttpProxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::HttpProxy);
+ obj1.setType(QNetworkProxy::Socks5Proxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::Socks5Proxy);
+}
+
+void tst_QNetworkProxy::capabilitiesPerType()
+{
+ QNetworkProxy proxy(QNetworkProxy::Socks5Proxy);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::TunnelingCapability);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability);
+
+ proxy.setType(QNetworkProxy::NoProxy);
+ // verify that the capabilities changed
+ QVERIFY(!(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability));
+ QVERIFY(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability);
+
+ proxy.setType(QNetworkProxy::HttpProxy);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability);
+ QVERIFY(!(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability));
+
+ // now set the capabilities on stone:
+ proxy.setCapabilities(QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
+ QCOMPARE(proxy.capabilities(), QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
+
+ // changing the type shouldn't change the capabilities any more
+ proxy.setType(QNetworkProxy::Socks5Proxy);
+ QCOMPARE(proxy.capabilities(), QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
}
QTEST_MAIN(tst_QNetworkProxy)
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index f0deab5..2e5fd00 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -624,6 +624,7 @@ QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progr
void tst_QPropertyAnimation::interpolated()
{
QObject o;
+ o.setProperty("point", QPointF()); //this will avoid warnings
o.setProperty("number", qVariantFromValue<Number>(Number(42)));
QCOMPARE(qVariantValue<Number>(o.property("number")), Number(42));
{
@@ -649,9 +650,9 @@ void tst_QPropertyAnimation::interpolated()
anim.start();
anim.pause();
anim.setCurrentTime(100);
- QCOMPARE(o.property("point").toPointF(), QPointF(10, 0));
+ QCOMPARE(o.property("point"), QVariant(QPointF(10, 0)));
anim.setCurrentTime(500);
- QCOMPARE(o.property("point").toPointF(), QPointF(50, 0));
+ QCOMPARE(o.property("point"), QVariant(QPointF(50, 0)));
}
{
// unregister it and see if we get back the default behaviour
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
index f28c3fa..bb7de20 100644
--- a/tests/auto/qstate/tst_qstate.cpp
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -9,9 +9,7 @@
#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) \
@@ -45,7 +43,6 @@ private slots:
void assignProperty();
void assignPropertyTwice();
void historyInitialState();
- void addEntryAction();
private:
bool functionCalled;
@@ -214,22 +211,6 @@ public slots:
};
-void tst_QState::addEntryAction()
-{
- QStateMachine sm;
-
- TestClass testObject;
-
- QState *s0 = new QState(sm.rootState());
- s0->addEntryAction(new QStateInvokeMethodAction(&testObject, "slot"));
- sm.setInitialState(s0);
-
- sm.start();
- QCoreApplication::processEvents();
-
- QCOMPARE(testObject.called, true);
-}
-
void tst_QState::assignProperty()
{
QStateMachine machine;
@@ -265,11 +246,11 @@ void tst_QState::assignPropertyTwice()
QCOMPARE(object->property("fooBar").toInt(), 30);
}
-class EventTestTransition: public QTransition
+class EventTestTransition: public QAbstractTransition
{
public:
EventTestTransition(QEvent::Type type, QState *targetState)
- : QTransition(QList<QAbstractState*>() << targetState), m_type(type)
+ : QAbstractTransition(QList<QAbstractState*>() << targetState), m_type(type)
{
}
@@ -279,6 +260,8 @@ protected:
return e->type() == m_type;
}
+ void onTransition(QEvent *) {}
+
private:
QEvent::Type m_type;
@@ -291,7 +274,7 @@ void tst_QState::historyInitialState()
QState *s1 = new QState(machine.rootState());
QState *s2 = new QState(machine.rootState());
- QHistoryState *h1 = s2->addHistoryState();
+ QHistoryState *h1 = new QHistoryState(s2);
s2->setInitialState(h1);
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 085d16b..edd6459 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -45,10 +45,10 @@
#include "qstatemachine.h"
#include "qstate.h"
-#include "qactiontransition.h"
#include "qhistorystate.h"
#include "qkeyeventtransition.h"
#include "qmouseeventtransition.h"
+#include "private/qstate_p.h"
#include "private/qstatemachine_p.h"
// Will try to wait for the condition while allowing event processing
@@ -70,6 +70,17 @@
static int globalTick;
+// Run exec for a maximum of TIMEOUT msecs
+#define QCOREAPPLICATION_EXEC(TIMEOUT) \
+{ \
+ QTimer timer; \
+ timer.setSingleShot(true); \
+ timer.setInterval(TIMEOUT); \
+ timer.start(); \
+ connect(&timer, SIGNAL(timeout()), QCoreApplication::instance(), SLOT(quit())); \
+ QCoreApplication::exec(); \
+}
+
class tst_QStateMachine : public QObject
{
Q_OBJECT
@@ -84,6 +95,8 @@ private slots:
void rootState();
void addAndRemoveState();
void stateEntryAndExit();
+ void assignProperty();
+ void assignPropertyWithAnimation();
void postEvent();
void stateFinished();
void parallelStates();
@@ -91,8 +104,7 @@ private slots:
void signalTransitions();
void eventTransitions();
void historyStates();
- void stateActions();
- void transitionActions();
+ void startAndStop();
void transitionToRootState();
void transitionEntersParent();
@@ -109,19 +121,51 @@ private slots:
void customErrorStateIsNull();
void clearError();
void historyStateHasNowhereToGo();
+ void historyStateAsInitialState();
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 restorePolicyNotInherited();
+ //void mixedRestoreProperties();
+ //void setRestorePolicyToDoNotRestore();
+ //void setGlobalRestorePolicyToGlobalRestore();
+ //void restorePolicyOnChildState();
+
void transitionWithParent();
+ void transitionsFromParallelStateWithNoChildren();
+ void parallelStateTransition();
+ void parallelStateAssignmentsDone();
+ void nestedRestoreProperties();
+ void nestedRestoreProperties2();
+
+ void simpleAnimation();
+ void twoAnimations();
+ void twoAnimatedTransitions();
+ void playAnimationTwice();
+ void nestedTargetStateForAnimation();
+ void animatedGlobalRestoreProperty();
+ void specificTargetValueOfAnimation();
+
+ void addDefaultAnimation();
+ void addDefaultAnimationWithUnusedAnimation();
+ void removeDefaultAnimation();
+ void overrideDefaultAnimationWithSpecific();
+
+// void addDefaultAnimationForSource();
+// void addDefaultAnimationForTarget();
+// void removeDefaultAnimationForSource();
+// void removeDefaultAnimationForTarget();
+// void overrideDefaultAnimationWithSource();
+// void overrideDefaultAnimationWithTarget();
+// void overrideDefaultSourceAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSource();
};
tst_QStateMachine::tst_QStateMachine()
@@ -143,10 +187,10 @@ public:
: QState(parent) {}
QList<QPair<int, Event> > events;
protected:
- virtual void onEntry() {
+ virtual void onEntry(QEvent *) {
events.append(qMakePair(globalTick++, Entry));
}
- virtual void onExit() {
+ virtual void onExit(QEvent *) {
events.append(qMakePair(globalTick++, Exit));
}
};
@@ -161,7 +205,7 @@ protected:
virtual bool eventTest(QEvent *) const {
return true;
}
- virtual void onTransition() {
+ virtual void onTransition(QEvent *) {
triggers.append(globalTick++);
}
};
@@ -194,15 +238,16 @@ void tst_QStateMachine::cleanup()
qInstallMsgHandler(s_oldHandler);
}
-class EventTransition : public QActionTransition
+class EventTransition : public QAbstractTransition
{
public:
EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
- : QActionTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+ : QAbstractTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
protected:
virtual bool eventTest(QEvent *e) const {
return (e->type() == m_type);
}
+ virtual void onTransition(QEvent *) {}
private:
QEvent::Type m_type;
};
@@ -220,16 +265,14 @@ void tst_QStateMachine::transitionToRootState()
machine.start();
QCoreApplication::processEvents();
- QCOMPARE(machine.configuration().count(), 2);
+ QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(initialState));
- QVERIFY(machine.configuration().contains(machine.rootState()));
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
- QCOMPARE(machine.configuration().count(), 2);
+ QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(initialState));
- QVERIFY(machine.configuration().contains(machine.rootState()));
}
void tst_QStateMachine::transitionEntersParent()
@@ -336,7 +379,7 @@ public:
{
}
- void onEntry()
+ void onEntry(QEvent *)
{
error = m_machine->error();
errorString = m_machine->errorString();
@@ -777,6 +820,40 @@ void tst_QStateMachine::clearError()
QVERIFY(machine.errorString().isEmpty());
}
+void tst_QStateMachine::historyStateAsInitialState()
+{
+ QStateMachine machine;
+
+ QHistoryState *hs = new QHistoryState(machine.rootState());
+ machine.setInitialState(hs);
+
+ QState *s1 = new QState(machine.rootState());
+ hs->setDefaultState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+
+ QHistoryState *s2h = new QHistoryState(s2);
+ s2->setInitialState(s2h);
+
+ QState *s21 = new QState(s2);
+ s2h->setDefaultState(s21);
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ 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(s21));
+}
+
void tst_QStateMachine::historyStateHasNowhereToGo()
{
QStateMachine machine;
@@ -789,7 +866,7 @@ void tst_QStateMachine::historyStateHasNowhereToGo()
brokenState->setObjectName("brokenState");
brokenState->setInitialState(new QState(brokenState));
- QHistoryState *historyState = brokenState->addHistoryState();
+ QHistoryState *historyState = new QHistoryState(brokenState);
historyState->setObjectName("historyState");
initialState->addTransition(new EventTransition(QEvent::User, historyState));
@@ -801,8 +878,8 @@ void tst_QStateMachine::historyStateHasNowhereToGo()
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'"));
+ QCOMPARE(machine.error(), QStateMachine::NoDefaultStateInHistoryStateError);
+ QCOMPARE(machine.errorString(), QString::fromLatin1("Missing default state in history state 'historyState'"));
}
void tst_QStateMachine::brokenStateIsNeverEntered()
@@ -843,8 +920,6 @@ void tst_QStateMachine::brokenStateIsNeverEntered()
void tst_QStateMachine::transitionToStateNotInGraph()
{
- QSKIP("Hangs", SkipAll);
-
s_countWarnings = false;
QStateMachine machine;
@@ -854,13 +929,14 @@ void tst_QStateMachine::transitionToStateNotInGraph()
machine.setInitialState(initialState);
QState *independentState = new QState();
+ independentState->setObjectName("independentState");
initialState->addTransition(independentState);
machine.start();
QCoreApplication::processEvents();
QCOMPARE(machine.configuration().count(), 1);
- QVERIFY(machine.configuration().contains(initialState));
+ QVERIFY(machine.configuration().contains(qobject_cast<QState*>(machine.rootState())->errorState()));
}
void tst_QStateMachine::customErrorStateNotInGraph()
@@ -893,22 +969,20 @@ void tst_QStateMachine::restoreProperties()
object->setProperty("b", 2);
QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QState *S1 = new QState();
S1->setObjectName("S1");
S1->assignProperty(object, "a", 3);
- S1->setRestorePolicy(QState::RestoreProperties);
machine.addState(S1);
QState *S2 = new QState();
S2->setObjectName("S2");
S2->assignProperty(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();
@@ -957,8 +1031,9 @@ void tst_QStateMachine::rootState()
void tst_QStateMachine::addAndRemoveState()
{
QStateMachine machine;
- QCOMPARE(machine.states().size(), 1); // the error state
- QCOMPARE(machine.states().at(0), (QAbstractState*)machine.errorState());
+ QStatePrivate *root_d = QStatePrivate::get(machine.rootState());
+ QCOMPARE(root_d->childStates().size(), 1); // the error state
+ QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState());
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: cannot add null state");
machine.addState(0);
@@ -967,9 +1042,9 @@ void tst_QStateMachine::addAndRemoveState()
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);
+ QCOMPARE(root_d->childStates().size(), 2);
+ QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s1);
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: state has already been added to this machine");
machine.addState(s1);
@@ -978,24 +1053,24 @@ void tst_QStateMachine::addAndRemoveState()
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);
+ QCOMPARE(root_d->childStates().size(), 3);
+ QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s1);
+ QCOMPARE(root_d->childStates().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);
+ QCOMPARE(root_d->childStates().size(), 2);
+ QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState());
+ QCOMPARE(root_d->childStates().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());
+ QCOMPARE(root_d->childStates().size(), 1);
+ QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState());
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::removeState: cannot remove null state");
machine.removeState(0);
@@ -1020,14 +1095,17 @@ void tst_QStateMachine::stateEntryAndExit()
s2->addTransition(s3);
QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
machine.setInitialState(s1);
QVERIFY(machine.configuration().isEmpty());
globalTick = 0;
+ QVERIFY(!machine.isRunning());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
QTRY_COMPARE(finishedSpy.count(), 1);
+ QTRY_COMPARE(stoppedSpy.count(), 0);
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s3));
@@ -1113,6 +1191,159 @@ void tst_QStateMachine::stateEntryAndExit()
}
}
+void tst_QStateMachine::assignProperty()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(machine.rootState());
+
+ QTest::ignoreMessage(QtWarningMsg, "QState::assignProperty: cannot assign property 'foo' of null object");
+ s1->assignProperty(0, "foo", QVariant());
+
+ s1->assignProperty(s1, "objectName", "s1");
+ QFinalState *s2 = new QFinalState(machine.rootState());
+ s1->addTransition(s2);
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+ QCOMPARE(s1->objectName(), QString::fromLatin1("s1"));
+
+ s1->assignProperty(s1, "objectName", "foo");
+ machine.start();
+ QCoreApplication::processEvents();
+ QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+
+ s1->assignProperty(s1, "noSuchProperty", 123);
+ machine.start();
+ QCoreApplication::processEvents();
+ QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+ QCOMPARE(s1->dynamicPropertyNames().size(), 1);
+ QCOMPARE(s1->dynamicPropertyNames().at(0), QByteArray("noSuchProperty"));
+
+ QSignalSpy polishedSpy(s1, SIGNAL(polished()));
+ machine.start();
+ QCoreApplication::processEvents();
+ QCOMPARE(polishedSpy.count(), 1);
+}
+
+void tst_QStateMachine::assignPropertyWithAnimation()
+{
+ // Single animation
+ {
+ QStateMachine machine;
+ QObject obj;
+ QState *s1 = new QState(machine.rootState());
+ s1->assignProperty(&obj, "foo", 123);
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(&obj, "foo", 456);
+ s2->assignProperty(&obj, "bar", 789);
+ QAbstractTransition *trans = s1->addTransition(s2);
+ QPropertyAnimation anim(&obj, "foo");
+ anim.setDuration(250);
+ trans->addAnimation(&anim);
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ s2->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(obj.property("foo").toInt(), 456);
+ QCOMPARE(obj.property("bar").toInt(), 789);
+ }
+ // Two animations
+ {
+ QStateMachine machine;
+ QObject obj;
+ QState *s1 = new QState(machine.rootState());
+ s1->assignProperty(&obj, "foo", 123);
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(&obj, "foo", 456);
+ s2->assignProperty(&obj, "bar", 789);
+ QAbstractTransition *trans = s1->addTransition(s2);
+ QPropertyAnimation anim(&obj, "foo");
+ anim.setDuration(150);
+ trans->addAnimation(&anim);
+ QPropertyAnimation anim2(&obj, "bar");
+ anim2.setDuration(150);
+ trans->addAnimation(&anim2);
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ s2->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(obj.property("foo").toInt(), 456);
+ QCOMPARE(obj.property("bar").toInt(), 789);
+ }
+ // Animation group
+ {
+ QStateMachine machine;
+ QObject obj;
+ QState *s1 = new QState(machine.rootState());
+ s1->assignProperty(&obj, "foo", 123);
+ s1->assignProperty(&obj, "bar", 321);
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(&obj, "foo", 456);
+ s2->assignProperty(&obj, "bar", 654);
+ s2->assignProperty(&obj, "baz", 789);
+ QAbstractTransition *trans = s1->addTransition(s2);
+ QSequentialAnimationGroup group;
+ group.addAnimation(new QPropertyAnimation(&obj, "foo"));
+ group.addAnimation(new QPropertyAnimation(&obj, "bar"));
+ trans->addAnimation(&group);
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ s2->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(obj.property("foo").toInt(), 456);
+ QCOMPARE(obj.property("bar").toInt(), 654);
+ QCOMPARE(obj.property("baz").toInt(), 789);
+ }
+ // Nested states
+ {
+ QStateMachine machine;
+ QObject obj;
+ QState *s1 = new QState(machine.rootState());
+ s1->setObjectName("s1");
+ s1->assignProperty(&obj, "foo", 123);
+ s1->assignProperty(&obj, "bar", 456);
+ QState *s2 = new QState(machine.rootState());
+ s2->setObjectName("s2");
+ s2->assignProperty(&obj, "foo", 321);
+ QState *s21 = new QState(s2);
+ s21->setObjectName("s21");
+ s21->assignProperty(&obj, "bar", 654);
+ QState *s22 = new QState(s2);
+ s22->setObjectName("s22");
+ s22->assignProperty(&obj, "bar", 789);
+ s2->setInitialState(s21);
+
+ QAbstractTransition *trans = s1->addTransition(s2);
+ QPropertyAnimation anim(&obj, "foo");
+ anim.setDuration(500);
+ trans->addAnimation(&anim);
+ QPropertyAnimation anim2(&obj, "bar");
+ anim2.setDuration(250);
+ trans->addAnimation(&anim2);
+
+ s21->addTransition(s21, SIGNAL(polished()), s22);
+
+ QFinalState *s3 = new QFinalState(machine.rootState());
+ s22->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(obj.property("foo").toInt(), 321);
+ QCOMPARE(obj.property("bar").toInt(), 789);
+ }
+}
+
struct StringEvent : public QEvent
{
public:
@@ -1137,7 +1368,7 @@ protected:
StringEvent *se = static_cast<StringEvent*>(e);
return (m_value == se->value) && (!m_cond.isValid() || (m_cond.indexIn(m_value) != -1));
}
- virtual void onTransition() {}
+ virtual void onTransition(QEvent *) {}
private:
QString m_value;
@@ -1154,11 +1385,11 @@ public:
{ m_value = value; }
protected:
- virtual void onEntry()
+ virtual void onEntry(QEvent *)
{
m_machine->postEvent(new StringEvent(m_value));
}
- virtual void onExit() {}
+ virtual void onExit(QEvent *) {}
private:
QStateMachine *m_machine;
@@ -1200,7 +1431,7 @@ void tst_QStateMachine::stateFinished()
s1_1->addTransition(s1_2);
s1->setInitialState(s1_1);
QFinalState *s2 = new QFinalState(machine.rootState());
- s1->addTransition(new QStateFinishedTransition(s1, QList<QAbstractState*>() << s2));
+ s1->addTransition(s1, SIGNAL(finished()), s2);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
machine.start();
@@ -1213,7 +1444,7 @@ void tst_QStateMachine::parallelStates()
{
QStateMachine machine;
- QState *s1 = new QState(QState::ParallelGroup);
+ QState *s1 = new QState(QState::ParallelStates);
QState *s1_1 = new QState(s1);
QState *s1_1_1 = new QState(s1_1);
QFinalState *s1_1_f = new QFinalState(s1_1);
@@ -1229,7 +1460,7 @@ void tst_QStateMachine::parallelStates()
QFinalState *s2 = new QFinalState();
machine.addState(s2);
- s1->addFinishedTransition(s2);
+ s1->addTransition(s1, SIGNAL(finished()), s2);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1455,10 +1686,10 @@ void tst_QStateMachine::eventTransitions()
QFinalState *s1 = new QFinalState(machine.rootState());
QEventTransition *trans = new QEventTransition();
- QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventObject(), (QObject*)0);
QCOMPARE(trans->eventType(), QEvent::None);
- trans->setEventSource(&button);
- QCOMPARE(trans->eventSource(), (QObject*)&button);
+ trans->setEventObject(&button);
+ QCOMPARE(trans->eventObject(), (QObject*)&button);
trans->setEventType(QEvent::MouseButtonPress);
QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
trans->setTargetState(s1);
@@ -1480,10 +1711,10 @@ void tst_QStateMachine::eventTransitions()
QFinalState *s1 = new QFinalState(machine.rootState());
QMouseEventTransition *trans = new QMouseEventTransition();
- QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventObject(), (QObject*)0);
QCOMPARE(trans->eventType(), QEvent::None);
QCOMPARE(trans->button(), Qt::NoButton);
- trans->setEventSource(&button);
+ trans->setEventObject(&button);
trans->setEventType(QEvent::MouseButtonPress);
trans->setButton(Qt::LeftButton);
trans->setTargetState(s1);
@@ -1527,10 +1758,10 @@ void tst_QStateMachine::eventTransitions()
QFinalState *s1 = new QFinalState(machine.rootState());
QKeyEventTransition *trans = new QKeyEventTransition();
- QCOMPARE(trans->eventSource(), (QObject*)0);
+ QCOMPARE(trans->eventObject(), (QObject*)0);
QCOMPARE(trans->eventType(), QEvent::None);
QCOMPARE(trans->key(), 0);
- trans->setEventSource(&button);
+ trans->setEventObject(&button);
trans->setEventType(QEvent::KeyPress);
trans->setKey(Qt::Key_A);
trans->setTargetState(s1);
@@ -1555,7 +1786,7 @@ void tst_QStateMachine::historyStates()
QState *s0 = new QState(root);
QState *s00 = new QState(s0);
QState *s01 = new QState(s0);
- QHistoryState *s0h = s0->addHistoryState();
+ QHistoryState *s0h = new QHistoryState(s0);
QState *s1 = new QState(root);
QFinalState *s2 = new QFinalState(root);
@@ -1599,152 +1830,42 @@ void tst_QStateMachine::historyStates()
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()
+void tst_QStateMachine::startAndStop()
{
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);
-
- QFinalState *s2 = new QFinalState(machine.rootState());
- s1->addTransition(s2);
-
- machine.setInitialState(s1);
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
-
- QObject *obj = new QObject();
- QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(obj, "deleteLater");
- QPointer<QObject> ptr(obj);
- QVERIFY(ptr != 0);
- s1->addEntryAction(ima);
- finishedSpy.clear();
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCoreApplication::processEvents();
- QVERIFY(ptr == 0);
-
- s1->removeEntryAction(ima);
-
- s1->invokeMethodOnEntry(ima, "deleteLater");
- QCOMPARE(s1->entryActions().size(), 1);
-
- 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();
+ QVERIFY(!machine.isRunning());
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start.");
machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
-
- QVERIFY(act1->didExecute());
- QVERIFY(act2->didExecute());
+ QCOMPARE(startedSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ QVERIFY(!machine.isRunning());
+ machine.stop();
+ QCOMPARE(startedSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
- 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());
- EventTransition *trans = new EventTransition(QEvent::User, s2);
- s1->addTransition(trans);
- QVERIFY(trans->actions().isEmpty());
- QTest::ignoreMessage(QtWarningMsg, "QActionTransition::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->invokeMethodOnTransition(act, "deleteLater");
+ QTRY_COMPARE(machine.isRunning(), true);
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
- QPointer<QStateAction> ptr(act);
- QVERIFY(ptr != 0);
- finishedSpy.clear();
- machine.start();
- QCoreApplication::processEvents();
+ machine.stop();
+ QTRY_COMPARE(machine.isRunning(), false);
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
- machine.postEvent(new QEvent(QEvent::User));
- QCoreApplication::processEvents();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCoreApplication::processEvents();
- QVERIFY(ptr == 0);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
}
void tst_QStateMachine::defaultGlobalRestorePolicy()
@@ -1786,6 +1907,7 @@ void tst_QStateMachine::defaultGlobalRestorePolicy()
QCOMPARE(propertyHolder->property("b").toInt(), 4);
}
+/*
void tst_QStateMachine::restorePolicyNotInherited()
{
QStateMachine machine;
@@ -1832,12 +1954,12 @@ void tst_QStateMachine::restorePolicyNotInherited()
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
-}
+}*/
void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QState::DoNotRestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::DoNotRestoreProperties);
QObject *propertyHolder = new QObject();
propertyHolder->setProperty("a", 1);
@@ -1874,6 +1996,7 @@ void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
QCOMPARE(propertyHolder->property("b").toInt(), 4);
}
+/*
void tst_QStateMachine::setRestorePolicyToDoNotRestore()
{
QObject *object = new QObject();
@@ -1930,19 +2053,20 @@ void tst_QStateMachine::setGlobalRestorePolicyToGlobalRestore()
{
s_countWarnings = false;
QStateMachine machine;
- machine.setGlobalRestorePolicy(QState::GlobalRestorePolicy);
+ machine.setGlobalRestorePolicy(QStateMachine::GlobalRestorePolicy);
- QCOMPARE(machine.globalRestorePolicy(), QState::DoNotRestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DoNotRestoreProperties);
QCOMPARE(s_msgType, QtWarningMsg);
s_msgType = QtDebugMsg;
- machine.setGlobalRestorePolicy(QState::RestoreProperties);
- machine.setGlobalRestorePolicy(QState::GlobalRestorePolicy);
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::GlobalRestorePolicy);
- QCOMPARE(machine.globalRestorePolicy(), QState::RestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QStateMachine::RestoreProperties);
QCOMPARE(s_msgType, QtWarningMsg);
}
+
void tst_QStateMachine::restorePolicyOnChildState()
{
QStateMachine machine;
@@ -1991,11 +2115,12 @@ void tst_QStateMachine::restorePolicyOnChildState()
QCOMPARE(propertyHolder->property("a").toInt(), 1);
QCOMPARE(propertyHolder->property("b").toInt(), 2);
}
+*/
void tst_QStateMachine::globalRestorePolicySetToRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QState::RestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QObject *propertyHolder = new QObject();
propertyHolder->setProperty("a", 1);
@@ -2032,6 +2157,7 @@ void tst_QStateMachine::globalRestorePolicySetToRestore()
QCOMPARE(propertyHolder->property("b").toInt(), 2);
}
+/*
void tst_QStateMachine::mixedRestoreProperties()
{
QStateMachine machine;
@@ -2098,6 +2224,7 @@ void tst_QStateMachine::mixedRestoreProperties()
// Enter s3, restore
QCOMPARE(propertyHolder->property("a").toInt(), 5);
}
+*/
void tst_QStateMachine::transitionWithParent()
{
@@ -2111,5 +2238,1038 @@ void tst_QStateMachine::transitionWithParent()
QCOMPARE(trans->targetStates().at(0), (QAbstractState*)s2);
}
+void tst_QStateMachine::simpleAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("fooBar", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "fooBar", 2.0);
+
+ EventTransition *et = new EventTransition(QEvent::User, s2);
+ QPropertyAnimation *animation = new QPropertyAnimation(object, "fooBar", s2);
+ et->addAnimation(animation);
+ s1->addTransition(et);
+
+ QState *s3 = new QState(machine.rootState());
+ s2->addTransition(animation, SIGNAL(finished()), s3);
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("fooBar").toDouble(), 2.0);
+}
+
+class SlotCalledCounter: public QObject
+{
+ Q_OBJECT
+public:
+ SlotCalledCounter() : counter(0) {}
+
+ int counter;
+
+public slots:
+ void slot() { counter++; }
+};
+
+void tst_QStateMachine::twoAnimations()
+{
+ 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(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+ s2->assignProperty(object, "bar", 10.0);
+
+ QPropertyAnimation *animationFoo = new QPropertyAnimation(object, "foo", s2);
+ QPropertyAnimation *animationBar = new QPropertyAnimation(object, "bar", s2);
+ animationBar->setDuration(900);
+
+ SlotCalledCounter counter;
+ connect(animationFoo, SIGNAL(finished()), &counter, SLOT(slot()));
+ connect(animationBar, SIGNAL(finished()), &counter, SLOT(slot()));
+
+ EventTransition *et = new EventTransition(QEvent::User, s2);
+ et->addAnimation(animationFoo);
+ et->addAnimation(animationBar);
+ s1->addTransition(et);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+ s2->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(object->property("bar").toDouble(), 10.0);
+
+ QCOMPARE(counter.counter, 2);
+}
+
+void tst_QStateMachine::twoAnimatedTransitions()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 5.0);
+ QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
+ s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+ s2->addTransition(fooAnimation, SIGNAL(finished()), s3);
+
+ QState *s4 = new QState(machine.rootState());
+ s4->assignProperty(object, "foo", 2.0);
+ QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4);
+ s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation2);
+
+ QState *s5 = new QState(machine.rootState());
+ QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
+ s4->addTransition(fooAnimation2, SIGNAL(finished()), s5);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s5));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QStateMachine::playAnimationTwice()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 5.0);
+ QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
+ s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+ s2->addTransition(fooAnimation, SIGNAL(finished()), s3);
+
+ QState *s4 = new QState(machine.rootState());
+ s4->assignProperty(object, "foo", 2.0);
+ s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation);
+
+ QState *s5 = new QState(machine.rootState());
+ QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
+ s4->addTransition(fooAnimation, SIGNAL(finished()), s5);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 5.0);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s5));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QStateMachine::nestedTargetStateForAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 3.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s2Child = new QState(s2);
+ s2Child->assignProperty(object, "bar", 10.0);
+ s2->setInitialState(s2Child);
+
+ QState *s2Child2 = new QState(s2);
+ s2Child2->assignProperty(object, "bar", 11.0);
+ QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2));
+
+ QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2);
+ connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(animation);
+
+ at = s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ animation = new QPropertyAnimation(object, "foo", s2);
+ connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(animation);
+
+ animation = new QPropertyAnimation(object, "bar", s2);
+ connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(animation);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+ s2->addTransition(s2, SIGNAL(polished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(object->property("bar").toDouble(), 10.0);
+ QCOMPARE(counter.counter, 2);
+}
+
+void tst_QStateMachine::animatedGlobalRestoreProperty()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+
+ QState *s4 = new QState(machine.rootState());
+ QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2);
+ connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(pa);
+
+ at = s2->addTransition(pa, SIGNAL(finished()), s3);
+ pa = new QPropertyAnimation(object, "foo", s3);
+ connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(pa);
+
+ at = s3->addTransition(pa, SIGNAL(finished()), s4);
+ pa = new QPropertyAnimation(object, "foo", s4);
+ connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
+ at->addAnimation(pa);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s4));
+ QCOMPARE(object->property("foo").toDouble(), 1.0);
+ QCOMPARE(counter.counter, 2);
+}
+
+void tst_QStateMachine::specificTargetValueOfAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
+ anim->setEndValue(10.0);
+ s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(anim);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+ s2->addTransition(anim, SIGNAL(finished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(anim->endValue().toDouble(), 10.0);
+}
+
+void tst_QStateMachine::addDefaultAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ machine.addDefaultAnimation(pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+ object->setProperty("bar", 2.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
+ machine.addDefaultAnimation(pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
+
+ pa = new QPropertyAnimation(object, "bar", &machine);
+ connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
+ machine.addDefaultAnimation(pa);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(counter.counter, 1);
+}
+
+void tst_QStateMachine::removeDefaultAnimation()
+{
+ QStateMachine machine;
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
+
+ machine.addDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ machine.addDefaultAnimation(anim);
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
+ machine.addDefaultAnimation(anim2);
+
+ QCOMPARE(machine.defaultAnimations().size(), 2);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim2);
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+}
+
+void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimation(defaultAnimation);
+ at->addAnimation(moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+}
+
+/*
+void tst_QStateMachine::addDefaultAnimationForSource()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ machine.addDefaultAnimationForSourceState(s1, pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QStateMachine::addDefaultAnimationForTarget()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ QState *s1 = new QState(machine.rootState());
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ machine.addDefaultAnimationForTargetState(s2, pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
+
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
+}
+
+void tst_QStateMachine::removeDefaultAnimationForSource()
+{
+ QStateMachine machine;
+
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
+
+ machine.addDefaultAnimationForSourceState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 0);
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForSourceState(machine.rootState()).contains(anim));
+
+ machine.removeDefaultAnimationForTargetState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 0);
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForSourceState(machine.rootState()).contains(anim));
+
+ machine.removeDefaultAnimationForSourceState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 0);
+
+ machine.addDefaultAnimationForSourceState(machine.rootState(), anim);
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
+ machine.addDefaultAnimationForSourceState(machine.rootState(), anim2);
+
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 2);
+ QVERIFY(machine.defaultAnimationsForSourceState(machine.rootState()).contains(anim));
+ QVERIFY(machine.defaultAnimationsForSourceState(machine.rootState()).contains(anim2));
+
+ machine.removeDefaultAnimationForSourceState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForSourceState(machine.rootState()).contains(anim2));
+
+ machine.removeDefaultAnimationForSourceState(machine.rootState(), anim2);
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 0);
+}
+
+void tst_QStateMachine::removeDefaultAnimationForTarget()
+{
+ QStateMachine machine;
+
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
+
+ machine.addDefaultAnimationForTargetState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 0);
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForTargetState(machine.rootState()).contains(anim));
+
+ machine.removeDefaultAnimationForSourceState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+ QCOMPARE(machine.defaultAnimationsForSourceState(machine.rootState()).size(), 0);
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForTargetState(machine.rootState()).contains(anim));
+
+ machine.removeDefaultAnimationForTargetState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 0);
+
+ machine.addDefaultAnimationForTargetState(machine.rootState(), anim);
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
+ machine.addDefaultAnimationForTargetState(machine.rootState(), anim2);
+
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 2);
+ QVERIFY(machine.defaultAnimationsForTargetState(machine.rootState()).contains(anim));
+ QVERIFY(machine.defaultAnimationsForTargetState(machine.rootState()).contains(anim2));
+
+ machine.removeDefaultAnimationForTargetState(machine.rootState(), anim);
+
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 1);
+ QVERIFY(machine.defaultAnimationsForTargetState(machine.rootState()).contains(anim2));
+
+ machine.removeDefaultAnimationForTargetState(machine.rootState(), anim2);
+ QCOMPARE(machine.defaultAnimationsForTargetState(machine.rootState()).size(), 0);
+}
+
+void tst_QStateMachine::overrideDefaultAnimationWithSource()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimation(defaultAnimation);
+ machine.addDefaultAnimationForSourceState(s1, moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+}
+
+void tst_QStateMachine::overrideDefaultAnimationWithTarget()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimation(defaultAnimation);
+ machine.addDefaultAnimationForTargetState(s2, moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+
+}
+
+void tst_QStateMachine::overrideDefaultSourceAnimationWithSpecific()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimationForSourceState(s1, defaultAnimation);
+ at->addAnimation(moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+}
+
+void tst_QStateMachine::overrideDefaultTargetAnimationWithSpecific()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimationForTargetState(s2, defaultAnimation);
+ at->addAnimation(moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+}
+
+void tst_QStateMachine::overrideDefaultTargetAnimationWithSource()
+{
+ QStateMachine machine;
+
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
+
+ SlotCalledCounter counter;
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
+
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimationForTargetState(s2, defaultAnimation);
+ machine.addDefaultAnimationForSourceState(s1, moreSpecificAnimation);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
+
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
+}
+
+*/
+
+void tst_QStateMachine::parallelStateAssignmentsDone()
+{
+ QStateMachine machine;
+
+ QObject *propertyHolder = new QObject(&machine);
+ propertyHolder->setProperty("foo", 123);
+ propertyHolder->setProperty("bar", 456);
+ propertyHolder->setProperty("zoot", 789);
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *parallelState = new QState(QState::ParallelStates, machine.rootState());
+ parallelState->assignProperty(propertyHolder, "foo", 321);
+
+ QState *s2 = new QState(parallelState);
+ s2->assignProperty(propertyHolder, "bar", 654);
+
+ QState *s3 = new QState(parallelState);
+ s3->assignProperty(propertyHolder, "zoot", 987);
+
+ s1->addTransition(new EventTransition(QEvent::User, parallelState));
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("foo").toInt(), 123);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 456);
+ QCOMPARE(propertyHolder->property("zoot").toInt(), 789);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(propertyHolder->property("foo").toInt(), 321);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 654);
+ QCOMPARE(propertyHolder->property("zoot").toInt(), 987);
+}
+
+void tst_QStateMachine::transitionsFromParallelStateWithNoChildren()
+{
+ QStateMachine machine;
+
+ QState *parallelState = new QState(QState::ParallelStates, machine.rootState());
+ machine.setInitialState(parallelState);
+
+ QState *s1 = new QState(machine.rootState());
+ parallelState->addTransition(new EventTransition(QEvent::User, s1));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(1, machine.configuration().size());
+ QVERIFY(machine.configuration().contains(parallelState));
+
+ machine.postEvent(new QEvent(QEvent::User));
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(1, machine.configuration().size());
+ QVERIFY(machine.configuration().contains(s1));
+}
+
+void tst_QStateMachine::parallelStateTransition()
+{
+ QStateMachine machine;
+
+ QState *parallelState = new QState(QState::ParallelStates, machine.rootState());
+ machine.setInitialState(parallelState);
+
+ QState *s1 = new QState(parallelState);
+ QState *s2 = new QState(parallelState);
+
+ QState *s1InitialChild = new QState(s1);
+ s1->setInitialState(s1InitialChild);
+
+ QState *s2InitialChild = new QState(s2);
+ s2->setInitialState(s2InitialChild);
+
+ QState *s1OtherChild = new QState(s1);
+
+ s1->addTransition(new EventTransition(QEvent::User, s1OtherChild));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QVERIFY(machine.configuration().contains(parallelState));
+ QVERIFY(machine.configuration().contains(s1));
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s1InitialChild));
+ QVERIFY(machine.configuration().contains(s2InitialChild));
+ QCOMPARE(machine.configuration().size(), 5);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QVERIFY(machine.configuration().contains(parallelState));
+
+ QVERIFY(machine.configuration().contains(s1));
+
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s1OtherChild));
+ QVERIFY(machine.configuration().contains(s2InitialChild));
+ QCOMPARE(machine.configuration().size(), 5);
+
+}
+
+void tst_QStateMachine::nestedRestoreProperties()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+
+ QObject *propertyHolder = new QObject(&machine);
+ propertyHolder->setProperty("foo", 1);
+ propertyHolder->setProperty("bar", 2);
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(propertyHolder, "foo", 3);
+
+ QState *s21 = new QState(s2);
+ s21->assignProperty(propertyHolder, "bar", 4);
+ s2->setInitialState(s21);
+
+ QState *s22 = new QState(s2);
+ s22->assignProperty(propertyHolder, "bar", 5);
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s21->addTransition(new EventTransition(QEvent::User, s22));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 1);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s21));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 3);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s22));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 3);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 5);
+}
+
+void tst_QStateMachine::nestedRestoreProperties2()
+{
+ QStateMachine machine;
+ machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+
+ QObject *propertyHolder = new QObject(&machine);
+ propertyHolder->setProperty("foo", 1);
+ propertyHolder->setProperty("bar", 2);
+
+ QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(propertyHolder, "foo", 3);
+
+ QState *s21 = new QState(s2);
+ s21->assignProperty(propertyHolder, "bar", 4);
+ s2->setInitialState(s21);
+
+ QState *s22 = new QState(s2);
+ s22->assignProperty(propertyHolder, "foo", 6);
+ s22->assignProperty(propertyHolder, "bar", 5);
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+ s21->addTransition(new EventTransition(QEvent::User, s22));
+ s22->addTransition(new EventTransition(QEvent::User, s21));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 1);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 2);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s21));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 3);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 4);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s22));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 6);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 5);
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s21));
+ QCOMPARE(propertyHolder->property("foo").toInt(), 3);
+ QCOMPARE(propertyHolder->property("bar").toInt(), 4);
+
+}
+
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 71d7b4d..c4517d6 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -208,8 +208,8 @@ private slots:
void indexRowSizeHint();
void addRowsWhileSectionsAreHidden();
-
void filterProxyModelCrash();
+ void styleOptionViewItem();
// task-specific tests:
void task174627_moveLeftToRoot();
@@ -2028,6 +2028,8 @@ void tst_QTreeView::scrollTo()
//
view.show();
+ view.setVerticalScrollMode(QAbstractItemView::ScrollPerItem); //some styles change that in Polish
+
view.resize(300, 200);
//view.verticalScrollBar()->setValue(0);
@@ -2040,6 +2042,7 @@ void tst_QTreeView::scrollTo()
QCOMPARE(view.verticalScrollBar()->value(), 5);
view.scrollTo(model.index(60, 60, QModelIndex()));
+
CHECK_VISIBLE(60,60);
view.scrollTo(model.index(60, 30, QModelIndex()));
CHECK_VISIBLE(60,30);
@@ -2849,6 +2852,75 @@ void tst_QTreeView::filterProxyModelCrash()
view.repaint(); //used to crash
}
+void tst_QTreeView::styleOptionViewItem()
+{
+ class MyDelegate : public QStyledItemDelegate
+ {
+ public:
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
+ {
+ QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option));
+ QStyleOptionViewItemV4 opt(option);
+ initStyleOption(&opt, index);
+
+ QVERIFY(!opt.text.isEmpty());
+ QCOMPARE(opt.index, index);
+ QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2));
+ QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable"));
+
+ if (opt.text.contains("Beginning"))
+ QCOMPARE(opt.viewItemPosition, QStyleOptionViewItemV4::Beginning);
+
+ if (opt.text.contains("Middle"))
+ QCOMPARE(opt.viewItemPosition, QStyleOptionViewItemV4::Middle);
+
+ if (opt.text.contains("End"))
+ QCOMPARE(opt.viewItemPosition, QStyleOptionViewItemV4::End);
+
+ if (opt.text.contains("OnlyOne"))
+ QCOMPARE(opt.viewItemPosition, QStyleOptionViewItemV4::OnlyOne);
+
+ if (opt.text.contains("Checked"))
+ QCOMPARE(opt.checkState, Qt::Checked);
+ else
+ QCOMPARE(opt.checkState, Qt::Unchecked);
+
+ QVERIFY(!opt.text.contains("Assert"));
+
+ QStyledItemDelegate::paint(painter, option, index);
+ count++;
+ }
+ mutable int count;
+ };
+
+ QTreeView view;
+ QStandardItemModel model;
+ view.setModel(&model);
+ MyDelegate delegate;
+ view.setItemDelegate(&delegate);
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("OnlyOne") << new QStandardItem("Assert") << new QStandardItem("Assert") << new QStandardItem("Assert") );
+ QStandardItem *checkable = new QStandardItem("Checkable");
+ checkable->setCheckable(true);
+ QStandardItem *checked = new QStandardItem("Checkable Checked");
+ checkable->setCheckable(true);
+ checked->setCheckState(Qt::Checked);
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << checkable << checked << new QStandardItem("End") );
+
+ view.setFirstColumnSpanned(2, QModelIndex(), true);
+ view.setAlternatingRowColors(true);
+
+ delegate.count = 0;
+ view.showMaximized();
+ QTest::qWait(30);
+ QVERIFY(delegate.count >= 13);
+}
+
class task174627_TreeView : public QTreeView
{
Q_OBJECT
@@ -3328,7 +3400,5 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
QVERIFY(delegate.paintedIndexes.contains(sub11.index()));
}
-
-
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/selftests/expected_xunit.txt b/tests/auto/selftests/expected_xunit.txt
index 0f7e70a..875dda6 100644
--- a/tests/auto/selftests/expected_xunit.txt
+++ b/tests/auto/selftests/expected_xunit.txt
@@ -6,19 +6,24 @@
</properties>
<testcase result="pass" name="initTestCase"/>
<testcase result="pass" name="testFunc1">
- <error message="just a QWARN() !" type="warn"/>
+ <!-- message="just a QWARN() !" type="warn" -->
</testcase>
<testcase result="fail" name="testFunc2">
- <error message="a qDebug() call!" type="qdebug"/>
+ <!-- message="a qDebug() call with comment&#x002D;ending stuff &#x002D;&#x002D;&gt;" type="qdebug" -->
<failure message="Compared values are not the same
Actual (2): 2
Expected (3): 3" result="fail"/>
</testcase>
<testcase name="testFunc3">
- <error message="skipping this function!" type="skip"/>
+ <!-- message="skipping this function!" type="skip" -->
</testcase>
<testcase result="fail" name="testFunc4">
<failure message="a forced failure!" result="fail"/>
</testcase>
<testcase result="pass" name="cleanupTestCase"/>
+ <system-err>
+<![CDATA[just a QWARN() !]]>
+<![CDATA[a qDebug() call with comment-ending stuff -->]]>
+<![CDATA[skipping this function!]]>
+ </system-err>
</testsuite>
diff --git a/tests/auto/selftests/xunit/tst_xunit.cpp b/tests/auto/selftests/xunit/tst_xunit.cpp
index d0b585f..dbe9fec 100644
--- a/tests/auto/selftests/xunit/tst_xunit.cpp
+++ b/tests/auto/selftests/xunit/tst_xunit.cpp
@@ -67,7 +67,7 @@ void tst_Xunit::testFunc1()
void tst_Xunit::testFunc2()
{
- qDebug("a qDebug() call!");
+ qDebug("a qDebug() call with comment-ending stuff -->");
QCOMPARE(2, 3);
}
diff --git a/tests/benchmarks/qanimation/main.cpp b/tests/benchmarks/qanimation/main.cpp
index 7bbcffb..7bb770f 100644
--- a/tests/benchmarks/qanimation/main.cpp
+++ b/tests/benchmarks/qanimation/main.cpp
@@ -11,8 +11,6 @@ class tst_qanimation : public QObject
{
Q_OBJECT
private slots:
- void itemAnimation();
- void itemAnimation_data() { data();}
void itemPropertyAnimation();
void itemPropertyAnimation_data() { data();}
void dummyAnimation();
@@ -32,35 +30,14 @@ private:
void tst_qanimation::data()
{
- QTest::addColumn<bool>("paused");
+ QTest::addColumn<bool>("started");
QTest::newRow("NotRunning") << false;
- QTest::newRow("Paused") << true;
-}
-
-void tst_qanimation::itemAnimation()
-{
- QFETCH(bool, paused);
- QGraphicsWidget item;
-
- //first the item animation
- {
- QItemAnimation anim(&item, QItemAnimation::Position);
- anim.setDuration(ITERATION_COUNT);
- anim.setStartValue(QPointF(0,0));
- anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
- QBENCHMARK {
- for(int i = 0; i < anim.duration(); ++i) {
- anim.setCurrentTime(i);
- }
- }
- }
+ QTest::newRow("Running") << true;
}
void tst_qanimation::itemPropertyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
QGraphicsWidget item;
//then the property animation
@@ -69,8 +46,8 @@ void tst_qanimation::itemPropertyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QPointF(0,0));
anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -82,7 +59,7 @@ void tst_qanimation::itemPropertyAnimation()
void tst_qanimation::dummyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//first the dummy animation
@@ -91,8 +68,8 @@ void tst_qanimation::dummyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < anim.duration(); ++i) {
anim.setCurrentTime(i);
@@ -103,7 +80,7 @@ void tst_qanimation::dummyAnimation()
void tst_qanimation::dummyPropertyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -112,8 +89,8 @@ void tst_qanimation::dummyPropertyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -125,7 +102,7 @@ void tst_qanimation::dummyPropertyAnimation()
void tst_qanimation::rectAnimation()
{
//this is the simplest animation you can do
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -134,8 +111,8 @@ void tst_qanimation::rectAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -147,7 +124,7 @@ void tst_qanimation::rectAnimation()
void tst_qanimation::floatAnimation()
{
//this is the simplest animation you can do
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -156,8 +133,8 @@ void tst_qanimation::floatAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(0.f);
anim.setEndValue(1.f);
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp
index 66c7a33..d60a943 100644
--- a/tests/benchmarks/qanimation/rectanimation.cpp
+++ b/tests/benchmarks/qanimation/rectanimation.cpp
@@ -7,49 +7,49 @@ static inline int interpolateInteger(int from, int to, qreal progress)
}
-RectAnimation::RectAnimation(DummyObject *obj) : object(obj), dura(250)
+RectAnimation::RectAnimation(DummyObject *obj) : m_object(obj), m_dura(250)
{
}
void RectAnimation::setEndValue(const QRect &rect)
{
- end = rect;
+ m_end = rect;
}
void RectAnimation::setStartValue(const QRect &rect)
{
- start = rect;
+ m_start = rect;
}
void RectAnimation::setDuration(int d)
{
- dura = d;
+ m_dura = d;
}
int RectAnimation::duration() const
{
- return dura;
+ return m_dura;
}
void RectAnimation::updateCurrentTime(int msecs)
{
- qreal progress = easing.valueForProgress( qreal(msecs) / qreal(dura) );
+ qreal progress = m_easing.valueForProgress( qreal(msecs) / qreal(m_dura) );
QRect now;
- now.setCoords(interpolateInteger(start.left(), end.left(), progress),
- interpolateInteger(start.top(), end.top(), progress),
- interpolateInteger(start.right(), end.right(), progress),
- interpolateInteger(start.bottom(), end.bottom(), progress));
+ now.setCoords(interpolateInteger(m_start.left(), m_end.left(), progress),
+ interpolateInteger(m_start.top(), m_end.top(), progress),
+ interpolateInteger(m_start.right(), m_end.right(), progress),
+ interpolateInteger(m_start.bottom(), m_end.bottom(), progress));
- bool changed = (now != current);
+ bool changed = (now != m_current);
if (changed)
- current = now;
+ m_current = now;
if (state() == Stopped)
return;
- if (object)
- object->setRect(current);
+ if (m_object)
+ m_object->setRect(m_current);
}
void RectAnimation::updateState(QAbstractAnimation::State state)
diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h
index c9770c4..99b82b4 100644
--- a/tests/benchmarks/qanimation/rectanimation.h
+++ b/tests/benchmarks/qanimation/rectanimation.h
@@ -21,10 +21,10 @@ public:
virtual void updateState(QAbstractAnimation::State state);
private:
- DummyObject *object;
- QEasingCurve easing;
- QRect start, end, current;
- int dura;
+ DummyObject *m_object;
+ QEasingCurve m_easing;
+ QRect m_start, m_end, m_current;
+ int m_dura;
};
-#endif \ No newline at end of file
+#endif