| 676 | } |
| 677 | |
| 678 | void 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 | |
| 713 | void TestAreaOperation::toolViewWidgetReuseAndDestruction() |
| 714 | { |
nothing calls this directly
no test coverage detected