| 31 | } |
| 32 | |
| 33 | void TestController::areaDeletion() |
| 34 | { |
| 35 | Controller controller; |
| 36 | Document *doc = new ToolDocument(QStringLiteral("tool"), &controller, new SimpleToolWidgetFactory<QTextEdit>(QStringLiteral("tool"))); |
| 37 | //create a view which does not belong to an area |
| 38 | View* view1 = doc->createView(); |
| 39 | Q_UNUSED(view1); |
| 40 | //create an area and two views in it |
| 41 | Area *area = new Area(&controller, QStringLiteral("MyArea")); |
| 42 | controller.addDefaultArea(area); |
| 43 | QCOMPARE(controller.defaultAreas().count(), 1); |
| 44 | View* view2 = doc->createView(); |
| 45 | view2->setObjectName(QStringLiteral("VIEW2")); |
| 46 | area->addView(view2); |
| 47 | View* view3 = doc->createView(); |
| 48 | view3->setObjectName(QStringLiteral("VIEW3")); |
| 49 | area->addView(view3); |
| 50 | QCOMPARE(doc->views().count(), 3); |
| 51 | QCOMPARE(area->views().count(), 2); |
| 52 | |
| 53 | delete area; |
| 54 | view2 = nullptr; view3= nullptr; |
| 55 | |
| 56 | QEXPECT_FAIL("", "Fails because of delayed view deletion", Continue); |
| 57 | QCOMPARE(doc->views().count(), 1); |
| 58 | QCOMPARE(controller.defaultAreas().count(), 0); |
| 59 | |
| 60 | QTest::qWait(100); // wait for deleteLaters |
| 61 | qDebug() << "Deleting doc"; |
| 62 | delete doc; |
| 63 | QTest::qWait(100); // wait for deleteLaters |
| 64 | qDebug() << "View2 & view3 are destructored at this point (but no earlier)."; |
| 65 | } |
| 66 | |
| 67 | void TestController::namedAreas() |
| 68 | { |
nothing calls this directly
no test coverage detected