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

Method testClosing

kdevplatform/shell/tests/test_shelldocumentoperation.cpp:59–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void TestShellDocumentOperation::testClosing()
60{
61 // Test that both the view and the view widget is deleted when closing
62 // document.
63 {
64 IDocumentController *documentController = Core::self()->documentController();
65 documentController->openDocumentFromText(QStringLiteral("Test1"));
66 Sublime::Area *area = Core::self()->uiControllerInternal()->activeArea();
67 QCOMPARE(area->views().count(), 1);
68 QPointer<Sublime::View> the_view = area->views().at(0);
69 QPointer<QWidget> the_widget = the_view->widget();
70 QVERIFY(the_widget);
71 documentController->openDocuments().at(0)->close(IDocument::Discard);
72 QCOMPARE(the_view.data(), (Sublime::View*)nullptr);
73 QCOMPARE(the_widget.data(), (QWidget*)nullptr);
74 }
75
76 // Now try the same, where there are two open documents.
77 {
78 IDocumentController *documentController = Core::self()->documentController();
79 // Annoying, the order of documents in
80 // documentController->openDocuments() depends on how URLs hash. So,
81 // to reliably close the second one, get hold of a pointer.
82 IDocument* doc1 = documentController->openDocumentFromText(QStringLiteral("Test1"));
83 IDocument* doc2 = documentController->openDocumentFromText(QStringLiteral("Test2"));
84 Sublime::Area *area = Core::self()->uiControllerInternal()->activeArea();
85 QCOMPARE(area->views().count(), 2);
86
87 QPointer<Sublime::View> the_view = area->views().at(1);
88 qDebug() << this << "see views " << area->views().at(0)
89 << " " << area->views().at(1);
90 QPointer<QWidget> the_widget = the_view->widget();
91 QVERIFY(the_widget);
92 doc2->close(IDocument::Discard);
93 QCOMPARE(the_view.data(), (Sublime::View*)nullptr);
94 QCOMPARE(the_widget.data(), (QWidget*)nullptr);
95 doc1->close(IDocument::Discard);
96 }
97}
98
99void TestShellDocumentOperation::testKateDocumentAndViewCreation()
100{

Callers

nothing calls this directly

Calls 11

documentControllerMethod · 0.80
openDocumentFromTextMethod · 0.80
activeAreaMethod · 0.80
uiControllerInternalMethod · 0.80
openDocumentsMethod · 0.80
countMethod · 0.45
viewsMethod · 0.45
atMethod · 0.45
widgetMethod · 0.45
closeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected