diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2011-04-20 08:59:13 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2011-04-20 08:59:13 (GMT) |
commit | 97d57498481598d0d4babfa77f816761dead29b8 (patch) | |
tree | 8709b1f70c8ad75e225acf476e827cf4e15b85f3 /tests/auto/qtextlayout/tst_qtextlayout.cpp | |
parent | 0edbaca5e7b718bb9bbbeaccc9e322b525b4327e (diff) | |
parent | 6037cb7f68fe0dec52f922d9e2f18c8e12a396cb (diff) | |
download | Qt-97d57498481598d0d4babfa77f816761dead29b8.zip Qt-97d57498481598d0d4babfa77f816761dead29b8.tar.gz Qt-97d57498481598d0d4babfa77f816761dead29b8.tar.bz2 |
Merge branch '4.7-upstream' into 4.7
Diffstat (limited to 'tests/auto/qtextlayout/tst_qtextlayout.cpp')
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 0f1ff66..85e6616 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -124,6 +124,8 @@ private slots: void lineWidthFromBOM(); void textWidthVsWIdth(); void textWidthWithStackedTextEngine(); + void textWidthWithLineSeparator(); + void textWithSurrogates_qtbug15679(); private: QFont testFont; @@ -1399,5 +1401,40 @@ void tst_QTextLayout::textWidthWithStackedTextEngine() QCOMPARE(line.naturalTextWidth(), fm.width(text)); } +void tst_QTextLayout::textWidthWithLineSeparator() +{ + QString s1("Save Project"), s2("Save Project\ntest"); + s2.replace('\n', QChar::LineSeparator); + + QTextLayout layout1(s1), layout2(s2); + layout1.beginLayout(); + layout2.beginLayout(); + + QTextLine line1 = layout1.createLine(); + QTextLine line2 = layout2.createLine(); + line1.setLineWidth(0x1000); + line2.setLineWidth(0x1000); + QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth()); +} + +void tst_QTextLayout::textWithSurrogates_qtbug15679() +{ + QString str = QString::fromUtf8("🀀a🀀"); + QTextLayout layout(str); + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + qreal x[6]; + for (int i = 0; i < 6; i++) + x[i] = line.cursorToX(i); + + // If the first and third character are using the same + // font, they must have the same advance (since they + // are surrogate pairs, we need to add two for each + // character) + QCOMPARE(x[2] - x[0], x[5] - x[3]); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" |