| 39 | |
| 40 | private slots: |
| 41 | void testWidgetReparent() |
| 42 | { |
| 43 | createProbe(); |
| 44 | |
| 45 | // we need one widget for the plugin to activate, otherwise the model will not be available |
| 46 | std::unique_ptr<QWidget> w1(new QWidget); |
| 47 | QTest::qWait(1); // event loop re-entry |
| 48 | |
| 49 | auto *model = ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.WidgetTree")); |
| 50 | QVERIFY(model); |
| 51 | QAbstractItemModelTester modelTest(model); |
| 52 | |
| 53 | std::unique_ptr<QWidget> w2(new QWidget); |
| 54 | QTest::qWait(1); // event loop re-entry |
| 55 | QCOMPARE(visibleRowCount(model), 2); |
| 56 | |
| 57 | w2->setParent(w1.get()); |
| 58 | QTest::qWait(1); // event loop re-entry |
| 59 | QCOMPARE(visibleRowCount(model), 1); |
| 60 | |
| 61 | w2->setParent(w1.get()); |
| 62 | QTest::qWait(1); // event loop re-entry |
| 63 | QCOMPARE(visibleRowCount(model), 1); |
| 64 | |
| 65 | std::unique_ptr<QWidget> w3(new QWidget); |
| 66 | w2->setParent(w3.get()); // reparent without event loop reentry! |
| 67 | QTest::qWait(1); // event loop re-entry |
| 68 | QCOMPARE(visibleRowCount(model), 2); |
| 69 | |
| 70 | w2.reset(); |
| 71 | QTest::qWait(1); // event loop re-entry |
| 72 | QCOMPARE(visibleRowCount(model), 2); |
| 73 | |
| 74 | w1.reset(); |
| 75 | QTest::qWait(1); // event loop re-entry |
| 76 | QCOMPARE(visibleRowCount(model), 1); |
| 77 | |
| 78 | w3.reset(); |
| 79 | QTest::qWait(1); // event loop re-entry |
| 80 | QCOMPARE(visibleRowCount(model), 0); |
| 81 | } |
| 82 | |
| 83 | void testPaintBuffer() |
| 84 | { |