diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-01-19 13:49:52 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-01-21 11:10:14 +0100 |
commit | b6191b16d41459ed73cea738dfaf8e25e81ae22b (patch) | |
tree | 6ad0952af507bf1ab8df9612023d6e224db8d7e2 /tests/auto/gui/text | |
parent | b2883a6acc7a8d8372a815cc91dd1a8449f25723 (diff) | |
parent | 9087df6bd2dd5198ccf101a237aadee331e51ec3 (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/corelib/global/global.pri
src/corelib/global/qcompilerdetection.h
src/corelib/global/qglobal.h
src/corelib/tools/qdatetime.cpp
src/plugins/platforms/xcb/qxcbscreen.h
src/plugins/platforms/xcb/qxcbwindow.h
src/widgets/dialogs/qcolordialog.cpp
src/widgets/dialogs/qcolordialog_p.h
tools/configure/configureapp.cpp
Change-Id: Ie9d6e9df13e570da0a90a67745a0d05f46c532af
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r-- | tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 42 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 62 |
2 files changed, 85 insertions, 19 deletions
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index df7de2b3b7..8cb32dabd1 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -307,24 +307,22 @@ void tst_QRawFont::advances() bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions(); QVector<QPointF> advances = font.advancesForGlyphIndexes(glyphIndices); - // On Windows and QNX, freetype engine returns advance of 9 for some of the glyphs - // when full hinting is used (default on Windows). - bool mayFail = false; -#if defined (Q_OS_WIN) - mayFail = font_d->fontEngine->type() == QFontEngine::Freetype - && (hintingPreference == QFont::PreferFullHinting - || hintingPreference == QFont::PreferDefaultHinting); -#elif defined(Q_OS_QNX) - mayFail = font_d->fontEngine->type() == QFontEngine::Freetype - && hintingPreference == QFont::PreferFullHinting; -#endif + bool mayDiffer = font_d->fontEngine->type() == QFontEngine::Freetype + && (hintingPreference == QFont::PreferFullHinting + || hintingPreference == QFont::PreferDefaultHinting); for (int i = 0; i < glyphIndices.size(); ++i) { - if (mayFail && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "FreeType engine reports unexpected advance " - "for some glyphs (9 instead of 8)", Continue); + if ((i == 0 || i == 5) && mayDiffer) { + QVERIFY2(qRound(advances.at(i).x()) == 8 + || qRound(advances.at(i).x()) == 9, + qPrintable(QStringLiteral("%1 != %2 && %1 != %3") + .arg(qRound(advances.at(i).x())) + .arg(8) + .arg(9))); + } else { + QCOMPARE(qRound(advances.at(i).x()), 8); } - QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); + if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); @@ -342,11 +340,17 @@ void tst_QRawFont::advances() QVERIFY(font.advancesForGlyphIndexes(glyphIndices.constData(), advances.data(), numGlyphs)); for (int i = 0; i < glyphIndices.size(); ++i) { - if (mayFail && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "FreeType engine reports unexpected advance " - "for some glyphs (9 instead of 8)", Continue); + if ((i == 0 || i == 5) && mayDiffer) { + QVERIFY2(qRound(advances.at(i).x()) == 8 + || qRound(advances.at(i).x()) == 9, + qPrintable(QStringLiteral("%1 != %2 && %1 != %3") + .arg(qRound(advances.at(i).x())) + .arg(8) + .arg(9))); + } else { + QCOMPARE(qRound(advances.at(i).x()), 8); } - QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); + if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 4b2970cd17..4fa8575153 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1280,6 +1280,13 @@ void tst_QTextLayout::smallTextLengthWrapAtWordBoundaryOrAnywhere() void tst_QTextLayout::testDefaultTabs() { QTextLayout layout("Foo\tBar\ta slightly longer text\tend.", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); layout.beginLayout(); QTextLine line = layout.createLine(); @@ -1322,6 +1329,13 @@ void tst_QTextLayout::testDefaultTabs() void tst_QTextLayout::testTabs() { QTextLayout layout("Foo\tBar.", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); QTextOption option = layout.textOption(); option.setTabStop(150); @@ -1339,6 +1353,13 @@ void tst_QTextLayout::testTabs() void tst_QTextLayout::testMultilineTab() { QTextLayout layout("Lorem ipsum dolor sit\tBar.", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); // test if this works on the second line. layout.beginLayout(); @@ -1348,12 +1369,20 @@ void tst_QTextLayout::testMultilineTab() line.setLineWidth(220.); layout.endLayout(); + QCOMPARE(line.cursorToX(22), 80.); } void tst_QTextLayout::testMultiTab() { QTextLayout layout("Foo\t\t\tBar.", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); layout.beginLayout(); QTextLine line = layout.createLine(); @@ -1367,6 +1396,13 @@ void tst_QTextLayout::testTabsInAlignedParag() { QTextLayout layout("Foo\tsome more words", testFont); layout.setCacheEnabled(true); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + QTextOption option = layout.textOption(); // right option.setAlignment(Qt::AlignRight); @@ -1426,6 +1462,12 @@ void tst_QTextLayout::testRightTab() */ layout.setCacheEnabled(true); + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + QTextOption option = layout.textOption(); QList<QTextOption::Tab> tabs; QTextOption::Tab tab; @@ -1463,6 +1505,13 @@ void tst_QTextLayout::testRightTab() void tst_QTextLayout::testCenteredTab() { QTextLayout layout("Foo\tBar", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); // test if centering the tab works. We expect the center of 'Bar.' to be at the tab point. QTextOption option = layout.textOption(); @@ -1484,6 +1533,13 @@ void tst_QTextLayout::testCenteredTab() void tst_QTextLayout::testDelimiterTab() { QTextLayout layout("Foo\tBar. Barrabas", testFont); + + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + layout.setCacheEnabled(true); // try the different delimiter characters to see if the alignment works there. QTextOption option = layout.textOption(); @@ -1537,6 +1593,12 @@ void tst_QTextLayout::tabsForRtl() */ layout.setCacheEnabled(true); + QFont font = layout.font(); + QFontPrivate *fd = QFontPrivate::get(font); + qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY()); + if (!qFuzzyCompare(dpiScale, 1.0)) + QSKIP("Test logic does not work when tabs are scaled by dpi"); + QTextOption option = layout.textOption(); QList<QTextOption::Tab> tabs; QTextOption::Tab tab; |