aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-10-06 14:14:40 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-06 07:55:59 +0200
commit625bb0520708879ef5d281ab0c62fc7ad5415441 (patch)
treec2e1e2c1d54988972387aec91cda756e7a3287b1 /tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
parent6028d8ebceccc4edd7c31ba0d16773ae866336c3 (diff)
Allow incubators to be driven recursively
Change-Id: If8ce239372c3cf3166b666329ba812b25ee54669 Reviewed-on: http://codereview.qt-project.org/6102 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
index f870ffb5cd..52ddf81602 100644
--- a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
+++ b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
@@ -78,6 +78,7 @@ private slots:
void forceCompletion();
void setInitialState();
void clearDuringCompletion();
+ void recursiveClear();
private:
QDeclarativeIncubationController controller;
@@ -422,10 +423,56 @@ void tst_qdeclarativeincubator::clearDuringCompletion()
QPointer<QObject> srt = SelfRegisteringType::me();
incubator.clear();
+ QCoreApplication::processEvents(QEventLoop::DeferredDeletion);
QVERIFY(incubator.isNull());
QVERIFY(srt.isNull());
}
+class Switcher : public QObject
+{
+ Q_OBJECT
+public:
+ Switcher(QDeclarativeEngine *e) : QObject(), engine(e) { }
+
+ struct MyIncubator : public QDeclarativeIncubator
+ {
+ MyIncubator(QDeclarativeIncubator::IncubationMode mode, QObject *s)
+ : QDeclarativeIncubator(mode), switcher(s) {}
+
+ virtual void setInitialState(QObject *o) {
+ if (o->objectName() == "switchMe")
+ connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt()));
+ }
+
+ QObject *switcher;
+ };
+
+ void start()
+ {
+ incubator = new MyIncubator(QDeclarativeIncubator::Synchronous, this);
+ component = new QDeclarativeComponent(engine, TEST_FILE("recursiveClear.1.qml"));
+ component->create(*incubator);
+ }
+
+ QDeclarativeEngine *engine;
+ MyIncubator *incubator;
+ QDeclarativeComponent *component;
+
+public slots:
+ void switchIt() {
+ component->deleteLater();
+ incubator->clear();
+ component = new QDeclarativeComponent(engine, TEST_FILE("recursiveClear.2.qml"));
+ component->create(*incubator);
+ }
+};
+
+void tst_qdeclarativeincubator::recursiveClear()
+{
+ Switcher switcher(&engine);
+ switcher.start();
+}
+
QTEST_MAIN(tst_qdeclarativeincubator)
#include "tst_qdeclarativeincubator.moc"