MCPcopy Create free account
hub / github.com/KDE/kdevelop / toolViewAdditionAndDeletion

Method toolViewAdditionAndDeletion

kdevplatform/sublime/tests/test_areaoperation.cpp:603–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603void 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\
624toolview1.1.1 [ left ]\n\
625toolview1.2.1 [ bottom ]\n\
626toolview1.2.2 [ bottom ]\n\
627toolview1.4.1 [ right ]\n\
628"));
629 } else {
630 QCOMPARE(toolViewsPrinter1.result, QStringLiteral("\n\
631toolview1.1.1 [ left ]\n\
632toolview1.2.1 [ bottom ]\n\
633toolview1.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\
657toolview1.1.1 [ left ]\n\
658toolview1.2.1 [ bottom ]\n\
659toolview1.2.2 [ bottom ]\n\
660"));

Callers

nothing calls this directly

Calls 9

showAreaMethod · 0.80
walkToolViewsMethod · 0.80
toolDocksMethod · 0.80
areaMethod · 0.45
createViewMethod · 0.45
addToolViewMethod · 0.45
widgetMethod · 0.45
countMethod · 0.45
removeToolViewMethod · 0.45

Tested by

no test coverage detected