Fix tests

This commit is contained in:
James Graham
2026-02-12 17:33:32 +00:00
parent 9f6853f771
commit c5457a893f
5 changed files with 12 additions and 5 deletions

View File

@@ -48,7 +48,6 @@ public:
if (!doc) { if (!doc) {
return false; return false;
} }
// qWarning() << doc->toPlainText() <<text;
return text == doc->toPlainText(); return text == doc->toPlainText();
} }
@@ -58,7 +57,6 @@ public:
if (cursor.isNull()) { if (cursor.isNull()) {
return false; return false;
} }
// qWarning() << RichFormat::formatsAtCursor(cursor) <<formats;
return RichFormat::formatsAtCursor(cursor) == formats; return RichFormat::formatsAtCursor(cursor) == formats;
} }

View File

@@ -65,6 +65,11 @@ TestCase {
spyCursor.clear(); spyCursor.clear();
} }
function cleanupTestCase(): void {
testHelper.textItem = null;
textItemHelper.textItem = null;
}
function test_item(): void { function test_item(): void {
compare(textItemHelper.textItem, textEdit); compare(textItemHelper.textItem, textEdit);
compare(spyItem.count, 0); compare(spyItem.count, 0);

View File

@@ -42,6 +42,9 @@ public:
Q_INVOKABLE void setFixedChars(const QString &startChars, const QString &endChars) Q_INVOKABLE void setFixedChars(const QString &startChars, const QString &endChars)
{ {
if (!m_textItem) {
return;
}
m_textItem->setFixedChars(startChars, endChars); m_textItem->setFixedChars(startChars, endChars);
} }
@@ -138,10 +141,11 @@ public:
if (!m_textItem) { if (!m_textItem) {
return; return;
} }
const auto textItem = new ChatTextItemHelper(); const auto textItem = new ChatTextItemHelper(this);
textItem->setTextItem(item); textItem->setTextItem(item);
textItem->setCursorPosition(cursorPos); textItem->setCursorPosition(cursorPos);
m_textItem->setCursorFromTextItem(textItem, infront); m_textItem->setCursorFromTextItem(textItem, infront);
textItem->deleteLater();
} }
Q_INVOKABLE void mergeFormatOnCursor(RichFormat::Format format) Q_INVOKABLE void mergeFormatOnCursor(RichFormat::Format format)

View File

@@ -181,7 +181,7 @@ void ModelTest::testRoomTreeModel()
void ModelTest::testMessageContentModel() void ModelTest::testMessageContentModel()
{ {
auto contentModel = std::make_unique<MessageContentModel>(room, eventId); auto contentModel = std::make_unique<MessageContentModel>(room, eventId);
auto tester = new QAbstractItemModelTester(contentModel.get()); auto tester = new QAbstractItemModelTester(contentModel.get(), contentModel.get());
tester->setUseFetchMore(true); tester->setUseFetchMore(true);
} }

View File

@@ -95,7 +95,7 @@ QQC2.Control {
} }
width: chatScrollView.width width: chatScrollView.width
spacing: Kirigami.Units.smallSpacing spacing: 0
Repeater { Repeater {
id: chatContentView id: chatContentView