diff options
Diffstat (limited to 'tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp')
-rw-r--r-- | tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index d6d0b0402a..0b9872f94c 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -52,6 +52,8 @@ #include <QQmlComponent> #include <QQmlIncubator> #include "../../shared/util.h" +#include <private/qqmlincubator_p.h> +#include <private/qqmlobjectcreator_p.h> class tst_qqmlincubator : public QQmlDataTest { @@ -141,35 +143,50 @@ void tst_qqmlincubator::incubationMode() void tst_qqmlincubator::objectDeleted() { - SelfRegisteringType::clearMe(); + { + QQmlEngine engine; + QQmlIncubationController controller; + engine.setIncubationController(&controller); + SelfRegisteringType::clearMe(); - QQmlComponent component(&engine, testFileUrl("objectDeleted.qml")); - QVERIFY(component.isReady()); + QQmlComponent component(&engine, testFileUrl("objectDeleted.qml")); + QVERIFY(component.isReady()); - QQmlIncubator incubator; - component.create(incubator); + QQmlIncubator incubator; + component.create(incubator); - QCOMPARE(incubator.status(), QQmlIncubator::Loading); - QVERIFY(SelfRegisteringType::me() == 0); + QCOMPARE(incubator.status(), QQmlIncubator::Loading); + QVERIFY(SelfRegisteringType::me() == 0); - while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { - bool b = false; - controller.incubateWhile(&b); - } + while (SelfRegisteringOuterType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } - QVERIFY(SelfRegisteringType::me() != 0); - QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringOuterType::me() != 0); + QVERIFY(incubator.isLoading()); - delete SelfRegisteringType::me(); + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } - { - bool b = true; - controller.incubateWhile(&b); - } + // We have to cheat and manually remove it from the creator->allCreatedObjects + // otherwise we will do a double delete + QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(&incubator); + incubatorPriv->creator->allCreatedObjects().pop(); + delete SelfRegisteringType::me(); - QVERIFY(incubator.isError()); - VERIFY_ERRORS(incubator, "objectDeleted.errors.txt"); - QVERIFY(incubator.object() == 0); + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isError()); + VERIFY_ERRORS(incubator, "objectDeleted.errors.txt"); + QVERIFY(incubator.object() == 0); + } + QVERIFY(SelfRegisteringOuterType::beenDeleted); } void tst_qqmlincubator::clear() @@ -1111,6 +1128,10 @@ void tst_qqmlincubator::selfDelete() QVERIFY(SelfRegisteringType::me() != 0); QVERIFY(incubator->isLoading()); + // We have to cheat and manually remove it from the creator->allCreatedObjects + // otherwise we will do a double delete + QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(incubator); + incubatorPriv->creator->allCreatedObjects().pop(); delete SelfRegisteringType::me(); { |