summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-02-25 07:07:16 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-02-25 07:09:05 (GMT)
commitb469289a6ed067be92eb24239c59f5cd1f5f7956 (patch)
tree9d176cff9128c342333d710b062097f771eee72f /tests/auto/declarative
parente6c85641ddc6068b1d50a52b95b136f366cad15a (diff)
downloadQt-b469289a6ed067be92eb24239c59f5cd1f5f7956.zip
Qt-b469289a6ed067be92eb24239c59f5cd1f5f7956.tar.gz
Qt-b469289a6ed067be92eb24239c59f5cd1f5f7956.tar.bz2
Document and test resetting properties in a state change.
Task-number: QT-1817
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/reset.qml20
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp21
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml
new file mode 100644
index 0000000..a0a2b8c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Rectangle {
+ width: 640
+ height: 480
+ Text {
+ id: theText
+ width: 50
+ wrap: true
+ text: "a text string that is longer than 50 pixels"
+ }
+
+ states: State {
+ name: "state1"
+ PropertyChanges {
+ target: theText
+ width: undefined
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 44fb51f..5ffce11 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/qdeclarativetext_p.h>
#include <private/qdeclarativepropertychanges_p.h>
#include <private/qdeclarativestategroup_p.h>
@@ -81,6 +82,7 @@ private slots:
void tempState();
void illegalTempState();
void nonExistantProperty();
+ void reset();
};
QByteArray tst_qdeclarativestates::fullDataPath(const QString &path)
@@ -912,6 +914,25 @@ void tst_qdeclarativestates::nonExistantProperty()
QCOMPARE(rect->state(), QLatin1String("blue"));
}
+void tst_qdeclarativestates::reset()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeText *text = rect->findChild<QDeclarativeText*>();
+ QVERIFY(text != 0);
+ QCOMPARE(text->width(), qreal(50.));
+ QVERIFY(text->width() < text->height());
+
+ rect->setState("state1");
+
+ QVERIFY(text->width() > 51);
+ QVERIFY(text->width() > text->height());
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"