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

Method sharedToolViewRemoval

kdevplatform/sublime/tests/test_areaoperation.cpp:678–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678void TestAreaOperation::sharedToolViewRemoval()
679{
680 MainWindow mw(m_controller);
681 m_controller->showArea(m_area1, &mw);
682 QCOMPARE_EQ(mw.area(), m_area1);
683 checkArea1(&mw);
684
685 auto* const toolView12 = findNamedView(m_area1->toolViews(), "toolview1.2.1");
686 auto* const toolView22 = findNamedView(m_area2->toolViews(), "toolview2.2.1");
687 RETURN_IF_TEST_FAILED();
688 QCOMPARE_EQ(toolView12->document(), toolView22->document());
689
690 QPointer viewWidget = toolView12->widget();
691 QVERIFY(viewWidget);
692 QCOMPARE_EQ(toolView22->widget(), nullptr);
693
694 // m_area2 contains another view of toolView12's document, but m_area2 has never
695 // been shown, so its widget is null and it does not reuse viewWidget. Therefore,
696 // viewWidget should be destroyed upon removal of the single view that uses it.
697 m_area1->removeToolView(toolView12);
698 QCOMPARE_EQ(viewWidget, nullptr);
699 QCOMPARE_EQ(toolView22->widget(), nullptr);
700
701 m_controller->showArea(m_area2, &mw);
702 QCOMPARE_EQ(mw.area(), m_area2);
703 checkArea2(&mw);
704
705 // Deliberately do not check the removed toolView12. Ideally it should be destroyed rather than leaked.
706 viewWidget = toolView22->widget();
707 QVERIFY(viewWidget);
708
709 m_area2->removeToolView(toolView22);
710 QCOMPARE_EQ(viewWidget, nullptr);
711}
712
713void TestAreaOperation::toolViewWidgetReuseAndDestruction()
714{

Callers

nothing calls this directly

Calls 6

findNamedViewFunction · 0.85
showAreaMethod · 0.80
areaMethod · 0.45
documentMethod · 0.45
widgetMethod · 0.45
removeToolViewMethod · 0.45

Tested by

no test coverage detected