| 57 | } |
| 58 | |
| 59 | void 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 | |
| 99 | void TestShellDocumentOperation::testKateDocumentAndViewCreation() |
| 100 | { |
nothing calls this directly
no test coverage detected