tests/auto/qtextlayout/tst_qtextlayout.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   120     void smallTextLengthNoWrap();
   120     void smallTextLengthNoWrap();
   121     void smallTextLengthWordWrap();
   121     void smallTextLengthWordWrap();
   122     void smallTextLengthWrapAtWordBoundaryOrAnywhere();
   122     void smallTextLengthWrapAtWordBoundaryOrAnywhere();
   123     void testLineBreakingAllSpaces();
   123     void testLineBreakingAllSpaces();
   124     void lineWidthFromBOM();
   124     void lineWidthFromBOM();
       
   125     void textWidthVsWIdth();
   125 
   126 
   126 
   127 
   127 private:
   128 private:
   128     QFont testFont;
   129     QFont testFont;
   129 };
   130 };
  1357         layout.createLine();
  1358         layout.createLine();
  1358         layout.endLayout();
  1359         layout.endLayout();
  1359     }
  1360     }
  1360 }
  1361 }
  1361 
  1362 
       
  1363 void tst_QTextLayout::textWidthVsWIdth()
       
  1364 {
       
  1365     QTextLayout layout;
       
  1366     QTextOption opt;
       
  1367     opt.setWrapMode(QTextOption::WrapAnywhere);
       
  1368     layout.setTextOption(opt);
       
  1369     layout.setText(QString::fromLatin1(
       
  1370                        "g++ -c -m64 -pipe -g -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DCORE_LIBRARY -DIDE_LIBRARY_BASENAME=\"lib\" -DWITH_TESTS "
       
  1371                        "-DQT_NO_CAST_TO_ASCII -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_PLUGIN -DQT_TESTLIB_LIB -DQT_SCRIPT_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XM"
       
  1372                        "L_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qt-qml/mkspecs/linux-g++-64 -I. -I../../../../qt-qml/include/QtCore -I../../../."
       
  1373                        "./qt-qml/include/QtNetwork -I../../../../qt-qml/include/QtGui -I../../../../qt-qml/include/QtXml -I../../../../qt-qml/include/QtSql -I../../../../qt-qml/inc"
       
  1374                        "lude/QtSvg -I../../../../qt-qml/include/QtScript -I../../../../qt-qml/include/QtTest -I../../../../qt-qml/include -I../../../../qt-qml/include/QtHelp -I../."
       
  1375                        "./libs -I/home/ettrich/dev/creator/tools -I../../plugins -I../../shared/scriptwrapper -I../../libs/3rdparty/botan/build -Idialogs -Iactionmanager -Ieditorma"
       
  1376                        "nager -Iprogressmanager -Iscriptmanager -I.moc/debug-shared -I.uic -o .obj/debug-shared/sidebar.o sidebar.cpp"));
       
  1377 
       
  1378     // textWidth includes right bearing, but it should never be LARGER than width if there is space for at least one character
       
  1379     for (int width = 100; width < 1000; ++width) {
       
  1380         layout.beginLayout();
       
  1381         QTextLine line = layout.createLine();
       
  1382         line.setLineWidth(width);
       
  1383         layout.endLayout();
       
  1384 
       
  1385         qreal textWidthIsLargerBy = qMax(qreal(0), line.naturalTextWidth() - line.width());
       
  1386         qreal thisMustBeZero = 0;
       
  1387         QCOMPARE(textWidthIsLargerBy, thisMustBeZero);
       
  1388     }
       
  1389 }
       
  1390 
       
  1391 
  1362 QTEST_MAIN(tst_QTextLayout)
  1392 QTEST_MAIN(tst_QTextLayout)
  1363 #include "tst_qtextlayout.moc"
  1393 #include "tst_qtextlayout.moc"