summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-05-05 01:49:20 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-05-05 01:53:37 (GMT)
commit4982b883c31874206aaa05268852fbcee81a8a39 (patch)
tree05baa3fc23ee1d69ce056135f5d20fa7f6b0d1be /tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
parent3b3ec6bc4114db82462eef812a47db420d4505c2 (diff)
downloadQt-4982b883c31874206aaa05268852fbcee81a8a39.zip
Qt-4982b883c31874206aaa05268852fbcee81a8a39.tar.gz
Qt-4982b883c31874206aaa05268852fbcee81a8a39.tar.bz2
Enable states to be activated via their 'when' clause even if unnamed.
Autogenerate a name for unnamed states: "anonymousState1", etc. Task-number: QTBUG-10352 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index d384d26..13992ad 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -110,6 +110,7 @@ private slots:
void illegalObjectCreation();
void whenOrdering();
void urlResolution();
+ void unnamedWhen();
};
void tst_qdeclarativestates::initTestCase()
@@ -1049,6 +1050,25 @@ void tst_qdeclarativestates::urlResolution()
QCOMPARE(image3->source(), resolved);
}
+void tst_qdeclarativestates::unnamedWhen()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"