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

Method testDocumentSetText

kdevplatform/debugger/tests/test_breakpointmodel.cpp:610–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608}
609
610void TestBreakpointModel::testDocumentSetText()
611{
612 const auto [url, doc, b1, b2] = setupEditCheckAndSavePrimaryDocumentAndBreakpoints();
613 RETURN_IF_TEST_FAILED();
614
615 // Grab document text lines [0, b2->line()].
616 auto* const textDoc = doc->textDocument();
617 const auto newText = textDoc->text({0, 0, b2->line() + 1, 0});
618 // Replace all text in the document, shortening it.
619 QVERIFY(textDoc->setText(newText));
620
621 // Wait needed to process events.
622 QTest::qWait(1);
623
624 // A breakpoint should become detached from its document when its text line is removed or when
625 // it falls out of bounds of the document on reload. KTextEditor::Document::setText() removes
626 // all text from the document first. The document line tracking must stop before this removal
627 // to retain the line numbers. KTextEditor changes are required to make this work correctly
628 // (see the commit message of 16932f0cd159fb4666154a76ecaa8b41710c1afb). Once fixed, both the
629 // breakpoint marks and their moving cursors can be removed, and the breakpoints can be marked
630 // as inactive/detached. The breakpoints will remain inactive until the user activates them
631 // again, e.g. by double-clicking an inactive breakpoint's row in the Breakpoints tool view
632 // (such a breakpoint reactivation is not yet implemented, only planned).
633
634 // The breakpoints should become inactive/detached, so their breakpoint marks should be removed.
635 const auto marks = documentMarks(doc);
636 QEXPECT_FAIL("", "Some breakpoint marks erroneously remain in the document.", Continue);
637 QCOMPARE(marks.size(), 0);
638
639 // The breakpoints must be the same.
640 QCOMPARE(breakpointModel()->rowCount(), 2);
641 QVERIFY(breakpointModel()->breakpoint(0));
642 QVERIFY(breakpointModel()->breakpoint(1));
643 QEXPECT_FAIL("", "Breakpoint b1 was erroneously re-created.", Abort);
644 QCOMPARE(breakpointModel()->breakpoint(0), b1);
645 QEXPECT_FAIL("", "Breakpoint b2 was erroneously re-created.", Abort);
646 QCOMPARE(breakpointModel()->breakpoint(1), b2);
647 // TODO: replace the above checks with the equivalent helper function call
648 // verifyTwoModelBreakpoints(b1, b2) once this test unexpectedly passes.
649
650 // The breakpoint locations must be unaffected.
651 VERIFY_UNTRACKED_BREAKPOINT(b1, 23, );
652 VERIFY_UNTRACKED_BREAKPOINT(b2, 24, );
653}
654
655void TestBreakpointModel::testDocumentReload_data()
656{

Callers

nothing calls this directly

Calls 8

breakpointModelFunction · 0.85
breakpointMethod · 0.80
textDocumentMethod · 0.45
textMethod · 0.45
lineMethod · 0.45
setTextMethod · 0.45
sizeMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected