summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 5c2c145..174967b 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -80,6 +80,7 @@ private slots:
void startup();
void groupedPropertyCrash();
void runningTrue();
+ void sameValue();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -384,6 +385,33 @@ void tst_qdeclarativebehaviors::runningTrue()
QTRY_VERIFY(runningSpy.count() > 0);
}
+//QTBUG-12295
+void tst_qdeclarativebehaviors::sameValue()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *target = rect->findChild<QDeclarativeRectangle*>("myRect");
+ QVERIFY(target);
+
+ target->setX(100);
+ QCOMPARE(target->x(), qreal(100));
+
+ target->setProperty("x", 0);
+ QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+ QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished.
+
+ target->setX(100);
+ QCOMPARE(target->x(), qreal(100));
+
+ //this is the main point of the test -- the behavior needs to be triggered again
+ //even though we set 0 twice in a row.
+ target->setProperty("x", 0);
+ QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"