Commit b0c5813a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Grantlee generator doesn't support yet title support .

This autotest will allow us to implement it
parent 3617d5c1
...@@ -789,3 +789,49 @@ void TextHTMLBuilderTest::testInsertImageWithSize() ...@@ -789,3 +789,49 @@ void TextHTMLBuilderTest::testInsertImageWithSize()
delete doc; delete doc;
} }
void TextHTMLBuilderTest::testTitle1()
{
const int boundedLevel = 1;
auto doc = new QTextDocument(this);
QTextCursor cursor(doc);
cursor.movePosition(QTextCursor::Start);
cursor.insertText(QStringLiteral("Foo"));
const int sizeAdjustment = boundedLevel > 0 ? 5 - boundedLevel : 0;
QTextBlockFormat blkfmt;
blkfmt.setHeadingLevel(boundedLevel);
cursor.mergeBlockFormat(blkfmt);
QTextCharFormat chrfmt;
chrfmt.setFontWeight(boundedLevel > 0 ? QFont::Bold : QFont::Normal);
chrfmt.setProperty(QTextFormat::FontSizeAdjustment, sizeAdjustment);
QTextCursor selectCursor = cursor;
QTextCursor top = selectCursor;
top.setPosition(qMin(top.anchor(), top.position()));
top.movePosition(QTextCursor::StartOfBlock);
QTextCursor bottom = selectCursor;
bottom.setPosition(qMax(bottom.anchor(), bottom.position()));
bottom.movePosition(QTextCursor::EndOfBlock);
selectCursor.setPosition(top.position(), QTextCursor::MoveAnchor);
selectCursor.setPosition(bottom.position(), QTextCursor::KeepAnchor);
selectCursor.mergeCharFormat(chrfmt);
cursor.mergeBlockCharFormat(chrfmt);
auto hb = new KPIMTextEdit::TextHTMLBuilder();
auto md = new KPIMTextEdit::MarkupDirector(hb);
md->processDocument(doc);
auto result = hb->getResult();
auto regex = QRegularExpression(
QStringLiteral("^<p style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"font-size:29pt;\"><strong>Foo</strong></span></p>\n$"));
qDebug() << " result : " << result;
//TODO implement header support now.
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
delete doc;
}
...@@ -56,6 +56,7 @@ private Q_SLOTS: ...@@ -56,6 +56,7 @@ private Q_SLOTS:
void testNewlinesThroughQTextCursor(); void testNewlinesThroughQTextCursor();
void testInsertImage(); void testInsertImage();
void testInsertImageWithSize(); void testInsertImageWithSize();
void testTitle1();
}; };
#endif // TEXTHTMLBUILDERTEST_H #endif // TEXTHTMLBUILDERTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment