tests/auto/qfontmetrics/tst_qfontmetrics.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp	Tue Jul 06 15:10:48 2010 +0300
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp	Wed Aug 18 10:37:55 2010 +0300
@@ -71,9 +71,9 @@
     void elidedText();
     void veryNarrowElidedText();
     void averageCharWidth();
+    void bypassShaping();
     void elidedMultiLength();
     void elidedMultiLengthF();
-    void bearingIncludedInBoundingRect();
 };
 
 tst_QFontMetrics::tst_QFontMetrics()
@@ -219,6 +219,21 @@
     QVERIFY(fmf.averageCharWidth() != 0);
 }
 
+void tst_QFontMetrics::bypassShaping()
+{
+    QFont f;
+    f.setStyleStrategy(QFont::ForceIntegerMetrics);
+    QFontMetrics fm(f);
+    QString text = " A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z";
+    int textWidth = fm.width(text, -1, Qt::TextBypassShaping);
+    QVERIFY(textWidth != 0);
+    int charsWidth = 0;
+    for (int i = 0; i < text.size(); ++i)
+        charsWidth += fm.width(text[i]);
+    // This assertion is needed in QtWebKit's WebCore::Font::offsetForPositionForSimpleText
+    QCOMPARE(textWidth, charsWidth);
+}
+
 template<class FontMetrics> void elidedMultiLength_helper()
 {
     QString text1 = "Long Text 1\x9cShorter\x9csmall";
@@ -251,16 +266,5 @@
     elidedMultiLength_helper<QFontMetricsF>();
 }
 
-void tst_QFontMetrics::bearingIncludedInBoundingRect()
-{
-    QFont font;
-    font.setItalic(true);
-    QRect brectItalic = QFontMetrics(font).boundingRect("ITALIC");
-    font.setItalic(false);
-    QRect brectNormal = QFontMetrics(font).boundingRect("ITALIC");
-
-    QVERIFY(brectItalic.width() >= brectNormal.width());
-}
-
 QTEST_MAIN(tst_QFontMetrics)
 #include "tst_qfontmetrics.moc"