diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-10-11 06:23:32 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-13 03:17:53 +0200 |
commit | ec4593d6d06b6b6de5cd26cf66d5c6a866231251 (patch) | |
tree | 51fed93b972e9ce29e3ad7c152a6184f8e0c6cfa /tests/auto/gui | |
parent | 4717d36c9110f016868e37d9eff74b1d28af5a9c (diff) |
QGlyphRun: Fix isEmpty() and boundingRect() didn't work after setRawData()
Change-Id: I44a347ef24961493d6b8353abbb215c713ccce52
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index d982428706..024559448c 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -63,6 +63,7 @@ private slots: void assignment(); void equalsOperator_data(); void equalsOperator(); + void isEmpty(); void textLayoutGlyphIndexes(); void drawExistingGlyphs(); void drawNonExistentGlyphs(); @@ -75,6 +76,7 @@ private slots: void detach(); void setRawData(); void setRawDataAndGetAsVector(); + void boundingRect(); private: int m_testFontId; @@ -235,6 +237,22 @@ void tst_QGlyphRun::equalsOperator() QCOMPARE(one != two, !equals); } +void tst_QGlyphRun::isEmpty() +{ + QGlyphRun glyphs; + QVERIFY(glyphs.isEmpty()); + + glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3); + QVERIFY(!glyphs.isEmpty()); + + glyphs.clear(); + QVERIFY(glyphs.isEmpty()); + + QVector<quint32> glyphIndexes = QVector<quint32>() << 1 << 2 << 3; + QVector<QPointF> positions = QVector<QPointF>() << QPointF(0, 0) << QPointF(0, 0) << QPointF(0, 0); + glyphs.setRawData(glyphIndexes.constData(), positions.constData(), glyphIndexes.size()); + QVERIFY(!glyphs.isEmpty()); +} void tst_QGlyphRun::textLayoutGlyphIndexes() { @@ -675,6 +693,34 @@ void tst_QGlyphRun::drawRightToLeft() } +void tst_QGlyphRun::boundingRect() +{ + QString s(QLatin1String("AbCdE")); + + QRawFont rawFont(QRawFont::fromFont(QFont())); + QVERIFY(rawFont.isValid()); + QVector<quint32> glyphIndexes = rawFont.glyphIndexesForString(s); + QVector<QPointF> positions = rawFont.advancesForGlyphIndexes(glyphIndexes); + QCOMPARE(glyphIndexes.size(), s.size()); + QCOMPARE(positions.size(), glyphIndexes.size()); + + QGlyphRun glyphs; + glyphs.setRawFont(rawFont); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + + QRectF boundingRect = glyphs.boundingRect(); + + glyphs.clear(); + glyphs.setRawFont(rawFont); + glyphs.setRawData(glyphIndexes.constData(), positions.constData(), glyphIndexes.size()); + QCOMPARE(glyphs.boundingRect(), boundingRect); + + boundingRect = QRectF(0, 0, 1, 1); + glyphs.setBoundingRect(boundingRect); + QCOMPARE(glyphs.boundingRect(), boundingRect); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QGlyphRun) |