summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativestates
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativestates')
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml32
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml14
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/reset.qml2
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/urlResolution.qml12
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml11
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp61
7 files changed, 131 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml
new file mode 100644
index 0000000..1872de8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml
@@ -0,0 +1,32 @@
+import Qt 4.7
+
+Item {
+ Column {
+ anchors.centerIn: parent
+ Image { id: image1; objectName: "image1" }
+ Image { id: image2; objectName: "image2" }
+ Image { id: image3; objectName: "image3" }
+ }
+
+ states: State {
+ name: "SetImageState"
+ PropertyChanges {
+ target: image1
+ source: "images/qt-logo.png"
+ }
+ PropertyChanges {
+ target: image2
+ source: "images/" + "qt-logo.png"
+ }
+ PropertyChanges {
+ target: image3
+ source: "images/" + (true ? "qt-logo.png" : "")
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.state = "SetImageState"
+ }
+
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png
new file mode 100644
index 0000000..14ddf2a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml
new file mode 100644
index 0000000..861ef8f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+Rectangle {
+ id: container
+ width: 400
+ height: 400
+
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ anchors.top: container.top
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml
index 8e9b13a..7da80b3 100644
--- a/tests/auto/declarative/qdeclarativestates/data/reset.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml
@@ -6,7 +6,7 @@ Rectangle {
Text {
id: theText
width: 40
- wrap: true
+ wrapMode: Text.WordWrap
text: "a text string that is longer than 40 pixels"
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml
new file mode 100644
index 0000000..8995b56
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml
@@ -0,0 +1,12 @@
+import Qt 4.7
+import "Implementation"
+
+Rectangle {
+ width: 100
+ height: 200
+
+ MyType {
+ objectName: "MyType"
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml
new file mode 100644
index 0000000..7369c63
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Rectangle {
+ property bool condition1: false
+ property bool condition2: false
+
+ states: [
+ State { name: "state1"; when: condition1 },
+ State { name: "state2"; when: condition2 }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 2ab21a4..578bcb4 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -43,6 +43,7 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativeanchors_p_p.h>
#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeimage_p.h>
#include <private/qdeclarativetext_p.h>
#include <private/qdeclarativepropertychanges_p.h>
#include <private/qdeclarativestategroup_p.h>
@@ -94,6 +95,7 @@ private slots:
void anchorChanges3();
void anchorChanges4();
void anchorChanges5();
+ void anchorChangesCrash();
void script();
void restoreEntryValues();
void explicitChanges();
@@ -107,6 +109,8 @@ private slots:
void nonExistantProperty();
void reset();
void illegalObjectCreation();
+ void whenOrdering();
+ void urlResolution();
};
void tst_qdeclarativestates::initTestCase()
@@ -716,6 +720,20 @@ void tst_qdeclarativestates::anchorChanges5()
delete rect;
}
+//QTBUG-9609
+void tst_qdeclarativestates::anchorChangesCrash()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("reanchored");
+
+ delete rect;
+}
+
void tst_qdeclarativestates::script()
{
QDeclarativeEngine engine;
@@ -978,6 +996,49 @@ void tst_qdeclarativestates::illegalObjectCreation()
QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
}
+void tst_qdeclarativestates::whenOrdering()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->state(), QLatin1String(""));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rect->state(), QLatin1String("state2"));
+ rect->setProperty("condition1", true);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", false);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rect->state(), QLatin1String("state1"));
+ rect->setProperty("condition1", false);
+ rect->setProperty("condition2", false);
+ QCOMPARE(rect->state(), QLatin1String(""));
+}
+
+void tst_qdeclarativestates::urlResolution()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItem *myType = rect->findChild<QDeclarativeItem*>("MyType");
+ QDeclarativeImage *image1 = rect->findChild<QDeclarativeImage*>("image1");
+ QDeclarativeImage *image2 = rect->findChild<QDeclarativeImage*>("image2");
+ QDeclarativeImage *image3 = rect->findChild<QDeclarativeImage*>("image3");
+ QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
+
+ myType->setState("SetImageState");
+ QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png");
+ QCOMPARE(image1->source(), resolved);
+ QCOMPARE(image2->source(), resolved);
+ QCOMPARE(image3->source(), resolved);
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"