| 601 | } |
| 602 | |
| 603 | void TestAreaOperation::toolViewAdditionAndDeletion() |
| 604 | { |
| 605 | MainWindow mw(m_controller); |
| 606 | m_controller->showArea(m_area1, &mw); |
| 607 | QCOMPARE_EQ(mw.area(), m_area1); |
| 608 | checkArea1(&mw); |
| 609 | |
| 610 | Document *tool4 = new ToolDocument(QStringLiteral("tool4"), m_controller, new SimpleToolWidgetFactory<QTextEdit>(QStringLiteral("tool4"))); |
| 611 | View *view = tool4->createView(); |
| 612 | view->setObjectName(QStringLiteral("toolview1.4.1")); |
| 613 | m_area1->addToolView(view, Sublime::Right); |
| 614 | |
| 615 | const QPointer viewWidget = view->widget(); |
| 616 | QVERIFY(viewWidget); |
| 617 | checkArea1(&mw); // verify that nothing has been broken |
| 618 | |
| 619 | //check that area is in valid state |
| 620 | AreaToolViewsPrinter toolViewsPrinter1; |
| 621 | m_area1->walkToolViews(toolViewsPrinter1, Sublime::AllPositions); |
| 622 | if constexpr (enableMultipleToolViewWidgets) { |
| 623 | QCOMPARE(toolViewsPrinter1.result, QStringLiteral("\n\ |
| 624 | toolview1.1.1 [ left ]\n\ |
| 625 | toolview1.2.1 [ bottom ]\n\ |
| 626 | toolview1.2.2 [ bottom ]\n\ |
| 627 | toolview1.4.1 [ right ]\n\ |
| 628 | ")); |
| 629 | } else { |
| 630 | QCOMPARE(toolViewsPrinter1.result, QStringLiteral("\n\ |
| 631 | toolview1.1.1 [ left ]\n\ |
| 632 | toolview1.2.1 [ bottom ]\n\ |
| 633 | toolview1.4.1 [ right ]\n\ |
| 634 | ")); |
| 635 | } |
| 636 | |
| 637 | //check that mainwindow has newly added tool view |
| 638 | { |
| 639 | const auto toolDocks = mw.toolDocks(); |
| 640 | for (const auto* const dock : toolDocks) { |
| 641 | QVERIFY(dock->widget() != nullptr); |
| 642 | } |
| 643 | QCOMPARE(toolDocks.count(), m_area1->toolViews().count()); |
| 644 | } |
| 645 | |
| 646 | //now remove tool view |
| 647 | m_area1->removeToolView(view); |
| 648 | |
| 649 | QCOMPARE_EQ(viewWidget, nullptr); // the view widget is not reused, and thus should be destroyed |
| 650 | checkArea1(&mw); // verify that nothing has been broken |
| 651 | |
| 652 | AreaToolViewsPrinter toolViewsPrinter2; |
| 653 | //check that area doesn't have it anymore |
| 654 | m_area1->walkToolViews(toolViewsPrinter2, Sublime::AllPositions); |
| 655 | if constexpr (enableMultipleToolViewWidgets) { |
| 656 | QCOMPARE(toolViewsPrinter2.result, QStringLiteral("\n\ |
| 657 | toolview1.1.1 [ left ]\n\ |
| 658 | toolview1.2.1 [ bottom ]\n\ |
| 659 | toolview1.2.2 [ bottom ]\n\ |
| 660 | ")); |
nothing calls this directly
no test coverage detected