diff options
Diffstat (limited to 'tests/auto/gui/text')
9 files changed, 127 insertions, 4 deletions
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 2a53f5d633..cfd24a8701 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -1509,6 +1509,12 @@ void tst_QCssParser::gradient_data() "spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF() << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4); + // spaces before first function parameter lead to parser errors + QTest::newRow("QTBUG-61795") << + "selection-background-color: qconicalgradient( cx: 4, cy : 2, angle: 23, " + "spread: repeat, stop:0.2 rgb( 1, 2, 3), stop:0.5 rgba( 1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF() + << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4); + /* won't pass: stop values are expected to be sorted QTest::newRow("unsorted-stop") << "selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, " diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 79058e5073..da2f100c0b 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -65,6 +65,7 @@ private slots: void fallbackFonts(); void condensedFontWidth(); + void condensedFontWidthNoFontMerging(); void condensedFontMatching(); void rasterFonts(); @@ -297,6 +298,29 @@ static QString testString() return QStringLiteral("foo bar"); } +void tst_QFontDatabase::condensedFontWidthNoFontMerging() +{ + int regularFontId = QFontDatabase::addApplicationFont(m_testFont); + int condensedFontId = QFontDatabase::addApplicationFont(m_testFontCondensed); + + QVERIFY(!QFontDatabase::applicationFontFamilies(regularFontId).isEmpty()); + QVERIFY(!QFontDatabase::applicationFontFamilies(condensedFontId).isEmpty()); + + QString regularFontName = QFontDatabase::applicationFontFamilies(regularFontId).first(); + QString condensedFontName = QFontDatabase::applicationFontFamilies(condensedFontId).first(); + + QFont condensedFont1(condensedFontName); + if (regularFontName == condensedFontName) + condensedFont1.setStyleName(QStringLiteral("Condensed")); + condensedFont1.setStyleStrategy(QFont::PreferMatch); + + QFont condensedFont2 = condensedFont1; + condensedFont2.setStyleStrategy(QFont::StyleStrategy(QFont::NoFontMerging | QFont::PreferMatch)); + + QCOMPARE(QFontMetricsF(condensedFont2).horizontalAdvance(QStringLiteral("foobar")), + QFontMetricsF(condensedFont1).horizontalAdvance(QStringLiteral("foobar"))); + } + void tst_QFontDatabase::condensedFontWidth() { QFontDatabase db; diff --git a/tests/auto/gui/text/qglyphrun/BLACKLIST b/tests/auto/gui/text/qglyphrun/BLACKLIST new file mode 100644 index 0000000000..57f32c683d --- /dev/null +++ b/tests/auto/gui/text/qglyphrun/BLACKLIST @@ -0,0 +1,3 @@ +[mixedScripts] +ubuntu-18.04 +b2qt diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 21b2697b90..b7f014d0e2 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -731,6 +731,9 @@ void tst_QGlyphRun::mixedScripts() layout.endLayout(); QList<QGlyphRun> glyphRuns = layout.glyphRuns(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Hangul character not rendered on winrt", Continue); +#endif QCOMPARE(glyphRuns.size(), 2); } diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 0089aeb43e..d00dc251d8 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -61,6 +61,8 @@ private slots: void drawToPoint(); void drawToRect_data(); void drawToRect(); + void compareToDrawText_data(); + void compareToDrawText(); void setFont(); void setTextWidth(); void prepareToCorrectData(); @@ -212,6 +214,66 @@ void tst_QStaticText::drawToRect() QCOMPARE(imageDrawStaticText, imageDrawText); } +void tst_QStaticText::compareToDrawText_data() +{ + QTest::addColumn<QFont>("font"); + + QTest::newRow("default") << QFont(); + QFont sansserif; sansserif.setStyleHint(QFont::SansSerif); + QFont serif; serif.setStyleHint(QFont::Serif); + QFont monospace; monospace.setStyleHint(QFont::Monospace); + QTest::newRow("sans-serif") << QFont(sansserif.defaultFamily()); + QTest::newRow("serif") << QFont(serif.defaultFamily()); + QTest::newRow("monospace") << QFont(monospace.defaultFamily()); +} + +void tst_QStaticText::compareToDrawText() +{ + QFETCH(QFont, font); + + QPixmap imageDrawText(1000, 1000); + imageDrawText.fill(Qt::white); + { + QPainter p(&imageDrawText); + p.setFont(font); + p.drawText(QRectF(11, 12, 30, 500), "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + } + + QPixmap imageDrawStaticPlainText(1000, 1000); + imageDrawStaticPlainText.fill(Qt::white); + { + QPainter p(&imageDrawStaticPlainText); + p.setFont(font); + QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + text.setTextWidth(10), + p.setClipRect(QRectF(11, 12, 30, 500)); + text.setTextFormat(Qt::PlainText); + p.drawStaticText(QPointF(11, 12), text); + } + + QPixmap imageDrawStaticRichText(1000, 1000); + imageDrawStaticRichText.fill(Qt::white); + { + QPainter p(&imageDrawStaticRichText); + p.setFont(font); + QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + text.setTextWidth(10), + p.setClipRect(QRectF(11, 12, 30, 500)); + text.setTextFormat(Qt::RichText); + p.drawStaticText(QPointF(11, 12), text); + } + +#if defined(DEBUG_SAVE_IMAGE) + imageDrawText.save("compareToDrawText_imageDrawText.png"); + imageDrawStaticText.save("compareToDrawText_imageDrawStaticPlainText.png"); + imageDrawStaticText.save("compareToDrawText_imageDrawStaticRichText.png"); +#endif + + QVERIFY(imageDrawText.toImage() != m_whiteSquare); + QCOMPARE(imageDrawStaticPlainText, imageDrawText); + QCOMPARE(imageDrawStaticRichText, imageDrawText); +} + void tst_QStaticText::prepareToCorrectData() { QTransform transform; diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp index d2c4adb888..2bc611fe93 100644 --- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp @@ -137,6 +137,7 @@ private slots: void cursorPositionWithBlockUndoAndRedo3(); void joinNonEmptyRemovedBlockUserState(); + void crashOnDetachingDanglingCursor(); private: int blockCount(); @@ -1974,5 +1975,14 @@ void tst_QTextCursor::joinNonEmptyRemovedBlockUserState() QCOMPARE(cursor.block().userState(), 10); } +void tst_QTextCursor::crashOnDetachingDanglingCursor() +{ + QTextDocument *document = new QTextDocument; + QTextCursor cursor(document); + QTextCursor cursor2 = cursor; + delete document; + cursor2.setPosition(0); // Don't crash here +} + QTEST_MAIN(tst_QTextCursor) #include "tst_qtextcursor.moc" diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index ed69802d95..3e354b7523 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -1692,6 +1692,9 @@ void tst_QTextDocumentFragment::html_bodyBackground() const char html[] = "<body background=\"foo.png\">Foo</body>"; doc->setHtml(html); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on winrt. Investigate - QTBUG-68297", Continue); +#endif QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern); } @@ -1706,6 +1709,9 @@ void tst_QTextDocumentFragment::html_tableCellBackground() QVERIFY(table); QTextTableCell cell = table->cellAt(0, 0); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on winrt. Investigate - QTBUG-68297", Continue); +#endif QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } @@ -1714,6 +1720,9 @@ void tst_QTextDocumentFragment::css_bodyBackground() const char html[] = "<body style=\"background-image:url('foo.png')\">Foo</body>"; doc->setHtml(html); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on winrt. Investigate - QTBUG-68297", Continue); +#endif QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern); } @@ -1728,6 +1737,9 @@ void tst_QTextDocumentFragment::css_tableCellBackground() QVERIFY(table); QTextTableCell cell = table->cellAt(0, 0); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on winrt. Investigate - QTBUG-68297", Continue); +#endif QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } diff --git a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp index 082d16f62d..c79f787547 100644 --- a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +++ b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp @@ -299,8 +299,11 @@ void tst_QTextDocumentLayout::imageAtRightAlignedTab() imgFormat.setName(name); cursor.insertImage(imgFormat); - // Everything should fit into the 300 pixels - QCOMPARE(doc->idealWidth(), 300.0); + // Everything should fit into the 300 pixels +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on winrt. Figure out why - QTBUG-68297", Continue); +#endif + QCOMPARE(doc->idealWidth(), 300.0); } void tst_QTextDocumentLayout::blockVisibility() diff --git a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp index fb92b5a20f..bbb90ec82a 100644 --- a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp @@ -131,7 +131,7 @@ void tst_QTextOdfWriter::testWriteParagraph_data() QTest::newRow("misc2") << "\t \tFoo" << "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\"><text:tab/> <text:s text:c=\"4\"/><text:tab/>Foo</text:span></text:p>"; QTest::newRow("linefeed") << (QStringLiteral("line1") + QChar(0x2028) + QStringLiteral("line2")) << - "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">line1<text:line-break/>line2</text:span></text:p>"; + "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">line1<text:tab/><text:line-break/>line2</text:span></text:p>"; QTest::newRow("spaces") << "The quick brown fox jumped over the lazy dog" << "<text:p text:style-name=\"p1\"><text:span text:style-name=\"c0\">The quick brown fox jumped over the lazy dog</text:span></text:p>"; } @@ -378,7 +378,7 @@ void tst_QTextOdfWriter::testWriteTable() odfWriter->writeFrame(*xmlWriter, document->rootFrame()); QString xml = QString::fromLatin1( "<text:p text:style-name=\"p1\"/>" - "<table:table>" + "<table:table table:style-name=\"Table2\">" "<table:table-column table:number-columns-repeated=\"3\"/>" "<table:table-row>" "<table:table-cell table:style-name=\"T3\">" |